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)

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

person = db.person[person.id]
-> shortcut syntax for db(db.person.id==person.id).select()[0]
db.person[person.id] = db.person(age=lambda attrs: attrs.age+=1)
-> update a record without having to fetch it first
del db.person[person.id]
-> delete a record without having to fetch it first

What do you think?

Robin



--~--~---------~--~----~------------~-------~--~----~
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