The problem is that Set is superfluous, oddly named, and thereby makes
the whole DAL confusing to learners. I experienced this confusion
myself when learning web2py, and now I find it's a problem when
teaching web2py to others.
A Query is not, as some web2py docs claim, just a WHERE clause. It
sup
@Massimo
So I'm not crazy, at least. Perhaps you can just add the Query and
Table methods, leaving Set "deprecated" but never removed. Isn't this
the current policy anyway? New learners would have a more sensical API
while existing users could stick with what they know. Learnability is
one of web2p
Something like:
(db.mytable.id == 3).ignore_common_filters().select()
Or:
(db.mytable.id == 3).select(ignore_common_filters=True)
'One way of doing it' is an argument for fixing it and officially
deprecating the old way. I'd sympathize with the objections more if it
meant actual legac
@pbreit
> Can't you just explain to people that this is how you query the db:
>
> rows = db(db.item.id==1).select()
>
> How much is gained by dropping the "db"?
Programming is all about taking comprehensible pieces and piecing them
together for your own purposes. A rote formula of syntax tha
Apologies for dragging this out. I don't mean to be combative, but...
@pbreit
It's weird if you're told OR if you think about it (especially if you
aren't already very fluent in Python). If no one tells you, and if you
don't think about it, it's probably fine. Also, the query already
encapsulates
Last argument, I promise.
Here's my version of your summary:
1. We have a connection object that represents a database.
2. From the Fields associated with this connection, Queries are
produced with Field's overloaded operators. Queries can also be
produced from combination of other Queries with
In parts of my app, some needed values take a long time to generate,
so I'm farming the generation of these values out to Scheduled tasks
and designing with the expectation that some values just won't be
ready to include in a page. When ready, the generated values are then
incorporated into the pag
This is actually just a Python quirk:
In Python 2.x, the / operator always returns an integer when both
operands are integers, e.g. (5 / 2) returns 2, not 2.5. The solution
is to simply make one or both operands a float:
percent = float(x) / y * 100 # x/y as a percentage
If you want your perc
After running http://web2py.googlecode.com/hg/scripts/setup-web2py-ubuntu.sh
on ubuntu 10.10 and setting up a postgres db for an app, I was getting
"global name 'psycopg2' is not defined". Fixed it with:
apt-get install python-psycopg2
sudo /etc/init.d/apache2 restart
For 10.10, the line
When using SQLFORM, I'd like to get the default/computed values of
fields not included in the form. Can I do this without making another
query? Can I get, say, the autogen'd id of the new record? For
example:
form = SQLFORM(db.job_post, submit_button='Post Job',
formstyle='table2cols',
fie
esL wrote:
> The new record id will be in form.vars.id after the accepts.
>
> On Mar 26, 7:46 pm, Brian Will wrote:
>
>
>
>
>
>
>
> > When using SQLFORM, I'd like to get the default/computed values of
> > fields not included in the form. Can
n=get_uuid):
vars['poster_name'] = form.vars.poster_name
vars['poster_email'] = form.vars.poster_email
redirect(URL('post_email', vars=vars))
On Mar 26, 6:01 pm, Brian Will wrote:
> Thanks, that's a start, but how now do I get 'uuid&
I have an insert SQLFORM of 8 fields, to which I'd like to add a
single "I agree to terms" checkbox at the bottom. There are probably
tons of ways to do this, but I'm hoping someone has a really simple
method that doesn't require resorting to a manual FORM? Can I simply
tack on another INPUT to the
of the checkbox,
> > which you probably would check using onvalidation.
>
> > Where do I collect my bonus points? ;)
>
> > On Mar 27, 6:43 am, Brian Will wrote:
>
> > > I have an insert SQLFORM of 8 fields, to which I'd like to add a
> > > s
be deprecate 'value' in favor of
'prechecked' for this purpose to avoid the confusion.
On Mar 27, 2:28 pm, Brian Will wrote:
> Thanks, everyone. That's what I was looking for.
>
> On Mar 27, 9:50 am, villas wrote:
>
>
>
>
>
>
>
> > Thanks
I have this table:
db.define_table('region',
Field('name'),
Field('longname'),
Field('subdomain', unique=True),
Field('status_', 'reference region_status')
)
The unique constraint is preventing me in the appadmin from adding
regions with the same subdomain, as intended. However, i
I should add that I'm seeing this with SQLite. Haven't tried it with
Postgres yet.
On Mar 28, 5:25 pm, Brian Will wrote:
> I have this table:
>
> db.define_table('region',
> Field('name'),
> Field('longname'),
> Field(
I should also make clear that I'm talking about
db.export_to_csv_file() and db.import_from_csv_file()
On Mar 28, 5:27 pm, Brian Will wrote:
> I should add that I'm seeing this with SQLite. Haven't tried it with
> Postgres yet.
>
> On Mar 28, 5:25 pm, Brian Will wrot
Just tried it with Postgres and now import_from_csv_file() is throwing
an exception with message "duplicate key value violates unique
constraint "region_subdomain_key", so I guess this is a sqlite
specific thing.
On Mar 28, 5:33 pm, Brian Will wrote:
> I should also make clea
I assumed there would simply be a Storage in the response object I
could just stuff things into, but it seems not. So my question is
what's the easiest way to append POST data to a response (for both
cases: a redirect and a non-redirect)?
Maybe I'm going about this the wrong way. I have a simple '
odd.
So I guess my question is: I want some way to redirect to another
action in the app and pass it data, but I don't want to pass it as URL
vars/args.
On Apr 5, 12:38 am, Brian Will wrote:
> I assumed there would simply be a Storage in the response object I
> could just stuff thing
our data available even after a
> redirect. POST won't have that, so you should either store it on the
> session, with cookies or with the database. If it's just temporary I
> would suggest using session variables.
>
> Regards,
> Arbie
>
> On Apr 5, 3:38 pm, Bria
I'd rather my password reset form not check the db for the existence
of the email and just blindly give an 'an email has been sent' message
regardless of what email address is entered.
In Auth.request_reset_password(), this should require simply making
the second validator conditional upon an opti
That seems to do it.
On Apr 11, 1:42 am, Brian Will wrote:
> I'd rather my password reset form not check the db for the existence
> of the email and just blindly give an 'an email has been sent' message
> regardless of what email address is entered.
>
> In Auth.
I'm trying to add a checkbox that must be ticked to an update SQLFORM,
but I'm getting an internal error.
Here's the create form that works fine with an added checkbox:
form = SQLFORM(db.job_post, submit_button='Post Job',
formstyle='table2cols',
fields=['poster_name', 'poster_email'
rors.terms = 'You must agree to the terms.'
>
> must be
>
> def validateTerms(form):
> if request.vars.terms != 'agree':
> form.errors.terms = 'You must agree to the terms.'
>
> as the request.vars has not yet been co
Done. Thanks Massimo, and for all your hard work.
On Apr 14, 7:29 am, Massimo Di Pierro
wrote:
> Please open an issue in google code and I will fix this asap.
>
> On Apr 14, 8:56 am, Brian Will wrote:
>
>
>
>
>
>
>
> > No, form.vars and request.vars bo
I'd like to use cache.ram with some chunks of content in my templates,
and I'd rather not have to translate the chunks into the helper
equivalents, e.g. to DIV(). Is there something like
{{cacheblock}}stuff{{end}}? Should there be?
28 matches
Mail list logo