Assuming that request.args contains the right values, this should work:
category = request.args[1].replace('_', ' ')
query = (db.Supplements.Category == category) & ((db.Supplements.Users ==
request.args[0]) | (db.Supplements.Users == "Both"))
records = db(query).select()
Notes:
- "contains" doe
Use the scheduler. It runs as an *independent* process. If the web server
is running or not have no influence on the scheduler. Read more here:
http://web2py.com/books/default/chapter/29/04?search=scheduler#Scheduler-%28experimental%29
--
You right, the prefix is what makes possible to use the same plugin code
across many apps.
Setting the "alias" for the plugin manager sounds like a good solution to
me.
from gluon.tools import PluginManager
plugins = PluginManager()
plugins.wiki.path = "wiki"
Your description is very confusing. Static content are the files that are
not dynamically generated but simply served over the network, e.g. images,
javascript, css.
If you generate an HTML page using a view (template) and filling it with
data from DB, that is a dynamic page generation.
Now, yo
I might be missing something but it looks to me that there is a very simple
solution to your problem.
Rename the controller from "plugin_wiki" to "pretty_url". Then use the
following routes.py:
routers = dict(
app1 = dict(
domain = "domain1.com",
default_controller = "default
OK, so you want /myapp/args to be mapped to
/myapp/default_controller/default_function/args. By default args would be
interpreted as a function name and will be mapped to
/myapp/default_controller/args. To change that you need to define a list of
functions for the default controller. Then if ar
This is really a GAE question, not related to web2py. By default the
indexes are set automatically when you run your app in dev environment
depending on what queries you use. But you can do it manually to by editing
the index.yaml (above the #AUTOGENERATED line). On the next deploy the
indexes
Where is the opencv installed in your system? When you check python
interpreters in PyDev options is that path on the list?
If you still struggling with it, a workaround could be to add the
installation folder to the system path by hand:
import sys
sys.path.append("opencv")
I think you need to customize the functions for storing/retrieving the
uploaded file.
In you model add:
Field("myfile", "upload", custom_store=store_myfile,
custom_retrieve=retrieve_myfile)
Then implement the functions:
def store_myfile(uploaded_file, filename=None, path=None):
buffer = uploa
You can set the desired logging level in the logging.conf:
[logger_scheduler]
level=DEBUG
handlers=consoleHandler
qualname=scheduler
propagate=0
If that doesn't help, you could try to play with the -D and -l options of
web2py.py,
To instantiate the object once, you could implement the class as
So you have an HTML code as input and would like to change some tags to
some others ones. But why? You should never had the need to build the HTML
page from another HTML page in web2py. You should rather simply combine the
data and a view. In your example, the view could be this:
pages.css
OK, so if I define the list of function, the situation is clear. If I don't
and I want to pass arguments to the default function I need to use the
default function name (/default_function/arg). Arguments alone (/arg) in
that case would be treated as if it is a function name (even if it does not
I would just queue the image processing task (using GAE queue) to have the
work done in the background. Doing it right when the form is submitted is
possible too but will cause delays to the user.
You could insert a logo by converting the image into uncompressed format
(e.g. bmp), modifying the
How do you post it? I'm guessing this is the part that needs fixing.
Not directly. You can't execute scripts on GAE, so you would have to move
the checking/sending code into a controller function and set up the GAE
cron to call it periodically.
However, it might be easier to use the GAE queues and to delegate e-mail
sending to a background task:
https://develope
Hmmm... So how does the router know if /abc is (1) function -
/default_app/default_controller/abc or (2) argument -
/default_app/default_controller/default_function/abc?
For simple things such as thumbnails, you can use the GAE images API (which
internally uses PIL):
https://developers.google.com/appengine/docs/python/images/imageclass
from google.appengine.api import images
blob = db.marcas(id).logotipo_marca_blob
image = images.Image(blob)
image.resize(32, 32)
I've tested in on Ubuntu 11.04, with web2py 1.99.2 and trunk and in both
cases after 35s the memory use is 1GB and growing.
Same results with DAL("sqlite://storage.db").
Oh, so the default for functions is ALL_FUNCTIONS? In the comments it says:
"list of valid functions in the default controller (default None)". From
that I concluded (without testing I admit) that by default no function name
will be mapped unless explicitly specified. It make sense to map all
f
For this type of routing where you don't use complex regular expressions,
it is better to use the simple router.
It could make selected functions of the default controller in the default
application available directly, i.e.
/f1 == /my_app/default_controller/f1
To have "/rules" mapped to "/aggat/
If all what you need is to report th task progress, you could periodically
write the amount of work done to db from within the task. Then query db
asynchronously with ajax to show it to the user. This could be done by
extending the "scheduler_run" table.
I'm not sure if there is a way to stop a
I don't agree that multiprocessing is difficult in Python. Threading is
difficult, multiprocessing is easy. Together with asynchronous I/O this
brings the scalability. You think node.js is multithreading? No, it's
single thread with event loop and non-blocking callbacks based I/O. And so
is Twi
Upgrade. Python 2.7 is backward compatible with 2.6. Pip install is also a
good option.
First you need to change your model. In relation database you would have:
db.define_table("articles", db.Field("title"), ...)
db.define_table("comments", db.Field("article_id", db.articles),
db.Field("author"), ...)
But with datastore you want to do the reverse, keep the comment ids in the
artic
You need web2py >= 1.99.3 for the lambda to work.
You *have to* set the response.files first, then include web2py_ajax.html.
Look how this is done in the example app:
http://code.google.com/p/web2py/source/browse/applications/welcome/views/layout.html
Also notice that web2py_ajax.html already includes jquery and web2py.js:
http://code.google.com
If this processing is done after the form submission you can delegate that
to a background task.
Having a queue of tasks end executing them one by one should solve the
concurrent access
problem. Check out the book section on scheduler:
http://web2py.com/books/default/chapter/29/4#Scheduler-%28exp
When working with GAE datastore you want to execute minimum number of
queries necessary to avoid delays and
limit the use of DB API calls. Fetching comments one by one is not the best
option then (even if done with ajax).
Probably the most efficient way would be to store the list of comment ids
Make a simple model for storing files:
db.define_table("files",
db.Field("name"),
db.Field("content", "text"))
Then use a function similar to the one below to download the file:
def download():
file = db.files(request.args[0])
if not file:
raise HTTP(404, "File not found.")
What do you mean by "I've made skills and items unnecessary"? What about
these references?
Field('Skills','list:reference SkillUser',default=None)
Field('Items','list:reference Item',default=None)
And at which point in your code the error occurs? Why you didn't include
full error message?
>From
So you want a web server on a local machine with a TCP backend to control
the remote device.
You also want some API to be able to access the server problematically.
If this is correct, you will need:
- a web2py application with functions decorated as services
http://web2py.com/books/default/cha
Don't use the web admin. It's for kids :P Copy welcome or example app and
change the files directly.
For me the selling point of web2py was the simplicity of the syntax. See
this comparison:
http://www.web2py.com/examples/static/web2py_vs_others.pdf
Just a blind guess but does this work any better?
query = (comment.id > 0) & (webpage.title == 'FAQ') & (comment.page_id ==
webpage.id) & (comment.id == comment_tags.comment_id) & (tag.id ==
comment_tags.tag_id) & (tag.label == 'Agree')
db(query).select()
This is not the best way. It will run a separate query for each board id.
On GAE you want to do
as much as you can in a single query. So the best way is to construct a
list of GAE keys and
get all entities together. Unfortunately, AFAIK, there is no support for
GAE batch queries in DAL.
You can,
There are two separated things here. One is presentation of required
attributes only, the other is validation of the from.
The first one could be solved with the "conditional field" approach
described in the book. If you are not sure what are
the ids for generated form elements, simply view the g
You can use a format string to define the data representation, read this:
http://web2py.com/books/default/chapter/29/6#Record-representation
To get the icons, instead of a format string, pass a function that
generates the required HTML code.
You can simply loop over a sorted list (first by the state, then by name):
city_list = [('Huntsville', 'AL'), ('Decatur', 'AL'), ('Anchorage', 'NV'),
('Nome', 'AK'),('Selma', 'AL'), ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'),
('Tucson', 'AZ')]
sorted_list = sorted(city_list, key=lambda x: (x[1],[0])
You wrote you know how to do it with mysql. DAL doesn't care what db you
use. Trigonometric functions are not supported by DAL anyway.
So I recommend you to apply your mysql solution using raw sql queries,
suggested already by Alan:
http://web2py.com/books/default/chapter/29/6#Raw-sql
>
> I'm trying to use a single controller for all my functions, including the
> "web/site" controller/function.
OK, but why? While it might be possible to achieve what you want to do this
way too, it is definitely not going to be easier.
The decoder detection seems to focus on 2-4 byte encoding. Many times you
will get a text in iso-8859-1
or cp-1250 or other 1 byte encoding and none of this is covered there. I
might not make sense to extend the
decoder if it is not meant for 1 byte encoding. In that case adding the
alternative
It looks to me that when you say "download" you mean "upload". If a user
sends a file to a server, she uploads it.
I recommend you to read about upload field in the book:
http://web2py.com/books/default/chapter/29/7#SQLFORM-and-uploads
So you are saying the problem is now solved? Can you share with us what was
the cause of this strange "missing pass in view" error?
You can use mysql with web2py:
http://web2py.com/books/default/chapter/29/6#Connection-strings
In a view you can only call functions defined in this view or a one being
extended/included:
http://web2py.com/books/default/chapter/29/5#Functions-in-views
More complex data processing should be done in the controller. Views should
just present the data.
Make the form transformation in the cont
What is the purpose of the "demo" version there? Wouldn't it be easier to
have a separate "demo" controller?
You could then simply define the default for the domains as:
routers = dict(
BASE = dict(
domains = {"domain.com":"app", "demo.domain.com":"app/demo/index"},
default_ap
I assume that you have only one application and you keep it separate from
web2py:
$HOME/workspace/my-project/src <-- your application folder
$HOME/workspace/my-project/web2py <-- web2py folder
To upgrade web2py to a desired version you can run then the following
script. It pulls the changes fr
Does the example app that comes with web2py show flash/errors correctly on
Firefox 10 + Windows?
If so, it would mean you didn't copy all the required CSS rules or you are
missing a class/id/tag in your layout.
You could inherit from DAL and overwrite the methods with wrappers that do
the decoding/encoding where needed.
I guess typically only insert, update, select and the constructor have to
be wrapped.
There is also the "db_codec" keyword argument for DAL constructor defaulted
to "utf-8". But I'm gu
To convert a string to utf-8 you need to do two operations:
- decode the string to unicode (using the original file codec)
- encode the unicode string using utf-8 codec
This is what decoder.decoder function is doing but it is guessing the
original codec.
You need to either provide the right codec
What exactly are you trying to do? Why you don't use the URL function?
It looks like you don't understand how the world wide web works. There is
nothing you can do to stop me from seeing the HTML code of your website.
Blocking right click gets you nowhere as I can still use the browser menu,
numerous plugins or simply download the page code directly without even
u
What pbreit suggested assumes that all the company servers are at the same
location as the company, which I guess is not what you wanted.
It think it should rather be:
db.define_table('company',
Field('name'),
Field('location', db.location))
db.define_table('server',
Field('name'),
The args keywords is used to pass extra parameters to grid URLs. It is only
useful if you implement your own ondelete, onupdate or oncreate functions
and need to get this extra arguments from a request.
I think the easiest is to add your validation code in the controller and
then process
the data after successful validation. I don't know how your data looks like
but here
is a simple example of a controller code with custom validation and db
insert:
def validate_add(form):
pattern = re.compil
Except of websites with very small user base, the use of sqlite is not
recommended as it doesn't
provide concurrent writes. Mysql or postgresql is usually a good first
choice, but web2py supports
about 10 different DBs, so you can choose something else too.
The application code (including instan
If I understand you correctly, you simply want to use the matched scenario
on the next stage of the form.
So, after validation you need to pass the id of the matched scenario either
by:
a) storing it in a session (1) and reading it later in the "next" function
(2)
1) session.scenario = scen
You could simply assume x minutes (eg. 15) without any user action equals
to logout. Then all you need is just a small script that runs periodically
by cron and does a DB update when inactivity is detected.
You kind of do :) There is no way to embed streams in HTML directly. You
need a separate function showing a single image by id (e.g. /show_image/id)
and build a list with links to that function in the list_image view.
{{for img in images:}}
{{= TD(img.title) }}
{{= TD(IMG(_src=URL("sh
The code in controllers is wrapped in web2py with a try except clause that
automatically commits or rolls back the changes to db. I believe this is
not the case for modules and an explicit commit is needed there. Try to add
"db.commit" to your module code.
You can pass a dictionary to a function as if you are passing keyword
arguments.
kwargs = {"a":1, "b":2}
f(**kwargs) # this call is equal to f(a=1, b=3)
There is similar mechanism for positional arguments in Python:
args = [1, 2]
f(*args) # this call is equal to f(1, 2)
I'm sorry, but I think you are on your own on this one :) Anyone who was
ever involved in coding CSS workarounds for IE6 remembers this nightmare
very strongly and would not go back to it even if paid lots of money :) If
you need your app to work perfectly on IE6, I suggest starting the
nightma
Goggle bigtable support in DAL is already GAE specific. You can also access
entities by id (which is returned after insert) or key using DAL. Mixing in
native API is possible if needed too, as app portability is lost anyway
with GAE. And the non web2py specific things such as N:N relations,
deb
You're probably right, access to global variables in mulithreading
environment requires extra care.
You might find reading this helpful:
http://blog.notdot.net/2011/10/Migrating-to-Python-2-7-part-1-Threadsafe
if "students" in request.vars:
students = json.loads(request.vars.students)
print students[0]["student_id"]
For python 2.5 you might need to import the simplejson from contrib (I'm
not sure if this is done automatically):
import gluon.contrib.simplejson as json
You can do tricks like that, but it does not have the best readability:
{{ for i in range(10):
}} text {{=i}} text {{
pass }}
The easiest way to do that is rely on web2py model -> form transformation
and use a validator (instead of the custom form).
model
--
MY_OPTIONS = ["a","b","c"]
db.define_table("my_table",
db.Field("my_options", "list:string", default=MY_OPTIONS))
db.my
I say the book works just fine:
http://web2py.com/book/default/chapter/04#Cron
The syntax you want to use is: @reboot * * * * root
*applications/test/controllers/private.py
Set that in your app/cron/crontab and make sure your controller does
db.commit() at the end.
Also you need SOFTCRON = Tru
The /var/www folder is just an example. You can put the wsgi.py in your
home folder as well.
You can also simply use wsgihandler.py that comes with web2py. One or the
other has to be
set as the WSGI script in the http server configuration.
To learn more on deploying web2py applications read this
Right, my bad, I missed the "args" keyword in the URL call. It should be:
URL("articles", "show", args=article.id).
For more details see the examples given by Anthony.
The intention is not to track changes in user made applications (different
than the default ones). ?! is the negative lookahead operator, so the first
part of the expression will match "applications/" only if it is not
followed with any of the strings in the brackets. The the second part (.*)
m
The directory does not exist. Run "mkdir /var/www" first.
If all what you want to do is to link to individual items from the main
page, you don't need to use redirect at all. Simply add HTML code to your
view that would link to /arcticles/show/[id] or /bussiness/show/[id] as
needed.
{{ for article in articles: }}
{{=LI(A(article.title, _href=URL("ar
Sorry, I was not precise. I was describing a case in which there is a
dependency on a code under a license which is GPL compatible and not
compatible with LGPL. So I meant "simpler" in that context. I agree that
for projects with no such dependency there would be no difference in
"difficulty".
You're right, if you careful enough, you can separate the changes to the
CMS code required by your application and release just them. But this is
just one of the abusive tactics which GPL protects against. Because how
useful would that changes be to others? I believe it would make more sense
if
If it worked with different controller my guess is still that the URL you
are passing is wrong.
Try to simplify it to: taskqueue.add(url=URL('hello'))
LGPL is designed for libraries. Static or dynamic linking to LGPL code is
allowed without enforcing copy-left. That means that the derivative work
can even be a proprietary software. However, if you change the library code
itself, you modification has to be released under LGPL. Since version 3
Check the app engine requests log to make sure the right task URL is being
used.
With web2py being licensed under LGPL it is possible to build applications
which are proprietary software. To some degree it is even possible to build
another web framework that uses unchanged web2py code as back-end. In
practice, however, the latter is too complicated on a technical level. The
What I see you are trying to say is that by keeping the code secret one
gains a temporary advantage over the competition. That might be true. But
this is the way of thinking coming from the proprietary software
philosophy. How much will I loose by making the software free? If this is
your line
If you have just one application all you need to do is set the web2py WSGI
script alias and serve files from the web2py folder excluding admin parts.
WSGIDaemonProcess web2py display-name=%{GROUP}
WSGIProcessGroup web2py
WSGIScriptAlias /prefix /var/www/web2py/wsgihandler.py
Options +Follow
I'm not sure if looking at the problem of license from the business point
of view is reasonable. If Bruno's goal was to make the business people
happy, he would put his software into the public domain. But I'm guessing
he is more interested in getting some help from others and maybe building a
Bruno's work is given for free, and if you don't share your changes back,
keep it secret behind the server, it doesn't help the Movuca project. So
for Bruno the GPL or even AGPL is a good option, as it keeps the code free
(as in freedom).
CMS is very different to a framework like web2py, which
The problem seems to be a redirection loop between this two addresses:
1) http://web2py.com/demo_admin/default/site
2)
http://web2py.com/demo_admin/default/index?send=%2Fdemo_admin%2Fdefault%2Fsite
Both return 303 and redirect 1 -> 2, and 2 -> 1 until the browser gives up
with a message:
"Firef
So how does it work for other form elements? I'm guessing they are stored
in session. So the way to go would be to store the uploaded file in session
too and then on form resubmission check what to display. If file is in
session the input field should look as on update of an existing object
(i.
Thanks! It works with the query using the "long" syntax: *db(db.table_name.id
== key).select().first()*
The short version *db.table_name(key)* does returns *None* as it performs a
check if key is an integer first.
However, using a query instead of a key also works:
*db.table_name(db.table_name.i
I'm getting nothing (None). If the intention was to having it work this way
(by passing key as id) I'll have a look at the DAL code more closely. Maybe
something affects the key outside of the select_raw function. Have this ever
worked for you?
Try to define default values for your fields:
name = Field("name", "boolean", default=False)
Are you using "list:string"? Can you post the relevant parts of your model
and controller?
Is there a way to use DAL to make a GAE query by entity name (not just
numeric id)? I remember a discussion on the list about GAE keys with parents
and a proposed patch for DAL to be able to pass GAE Key instead of if id. I
see this implemented in the DAL code:
http://code.google.com/p/web2py/s
Hmmm... So this means that app-specific routes are not so useful as I
thought. I thought I would be able
to get away without the "web2py/routes.py" having all rules defined per
application. In other words, I was
expecting the default_router to be the default when there is no
"web2py/routes.py".
I want to use app-specific routes to make my application more portable.
Let's assume that there
is no "web2py/routes.py" file and my application name is "init". Now I
created the "routes.py" file
in "web2py/applications/init/" directory and defined my simple router there:
my_router = dict(
con
I've deleted the logging.conf file.
I think you mean the default logging level set to DEBUG as we once discussed
here:
https://groups.google.com/forum/#!msg/web2py/N2O7WrPJdAE/trGuTFU9cssJ
But here we have quite opposite problem, it's not that too much goes to the
log but rather that
errors were not logged.
The exact behaviour of this instance memory control mechanism was not
revealed (see
http://code.google.com/p/googleappengine/issues/detail?id=1646 ). From your
log message
it looks like it was the first request that triggered the limit so the
garbage collection can hardly
be blamed here. And fr
Yes. There is no call to session.connect(). As I'm running the app on GAE I
wanted to avoid the
default file system based session. If this is not default any more and there
is no session at all
until explicitly created I can safely remove it.
The bigger problem here are the logs though. Why woul
The thing is that when you read from datastore you always read all
properties of an entity.
Each entity can take up to 1MB, so I can imagine reading 500 of them could
hit the instance
limit. The solution would be to use GAE cursor and cycle your task. In
pseudo code:
def request_handler():
ma
Why not simply use /sr/action/id without any url remapping? What is the
advantage of having
an argument and function name order reversed? For viewing the record you
still need to call
a specific function, e.g. /sr/view/1. Anyway, if you want it your way, try
this:
routes_in = (
("/sr/(\d+)/(
Yes, if host.domain.tld/meetings/2011/ points to the MYAPP already, you
don't need routes_in.
Probably your outgoing routes mapping should look like this:
routes_out = (
("/MYAPP/(.*)", r"/meetings/2011/MYAPP/\1"),
)
Thanks for the hint! It was the logging indeed. Apparently the logging.conf
that comes with web2py was
hiding the error:
ERROR2011-07-26 18:44:54,452 restricted.py:156] Traceback (most recent
call last):
File "/home/momat/workspace/pm-cmp-python/web2py/gluon/main.py", line 531,
in wsgibase
I'm using the latest GAE 1.5.2 and web2py 1.96.4. When I run the application
with:
python2.5 /opt/gae-python-sdk/dev_appserver.py --port 8001 ./web2py
and open http://localhost:8001 in a browser I get the HTTP 500 internal
server error.
There is no message in the appserver console output, there
1 - 100 of 141 matches
Mail list logo