On Jan 22, 5:35 pm, Robin B <[email protected]> wrote:
> Here are some more backward compatible DAL syntax extensions:
>
> This:
>   query = db((db.person.last_name=='Obama')&
> (db.person.first_name=='Barack'))
>   query((db.person.party=='Democratic')&(db.person.age>35)).select()
> Could also be:
>   query = db
> (db.person.last_name=='Obama',db.person.first_name=='Barack')
>   query(db.person.party=='Democratic',db.person.age>35).select()
> (less noise, fewer ()'s, easier to generate programmatically)

If I understand, this you can do already

db(...)(...)(...).select(...)

> person = db.person(party='Republican')
> -> returns a person with default= values populated and **attrs set
> person.first_name = 'John'
> response.render(person=person)
> -> the record can be printed on a page without inserting it in db
> person.insert()
> -> actually inserts the record, returns 1 for success, 0 for failure,
> updates person attrs

Not convinced about this one.

> person = db.person[person.id]
> -> shortcut syntax for db(db.person.id==person.id).select()[0]

love this one

> db.person[person.id] = db.person(age=lambda attrs: attrs.age+=1)
> -> update a record without having to fetch it first

this depends on the one above I am not convinced about. One could do
db.person[person.id].update_record(age=...)

> del db.person[person.id]
> -> delete a record without having to fetch it first

love this one too

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to