Hi Arnon,
I really don't see that your requirements in this example are not a good
for web2py's DAL. I'd really like to understand what, if anything, I'm
missing here.
I'm originally an RDBMS developer, and what I think of as the
set-oriented approach of web2py's DAL is a much better fit for my mental
model of what my application is doing. Conversely, I find many ORM
solutions (and Active Record, come to that) to be an anti-pattern [1].
FWIW, my data is typically consumed by more than one application (e.g.
not just web2py), and I've tended to let web2py create and manage the
schema in its own way, and work in the db with views etc. to address
more complex or performance-critical functions, so perhaps my concerns
are different to yours. However, the examples you give don't seem to
take best advantage of the DAL to my eye.
Anthony provided some examples as to how one might do that, but you have
not responded directly to that post (apologies if I've missed your
response if it was elsewhere in the thread). I'd like to take the
liberty of quitting Anthony's responses and asking for your take on them.
On 02/05/13 22:20, Arnon Marcus wrote:
Using the DAL, the best you might get is:
>>> [city for city in db.City.Country.select() if city.Country.Name ==
''France']
[<Row Name:Paris>, <Row Name:Nice>]
Anthony's suggestion: -
>>> db.Country(name='France').City.select()
>>> europe = Continent(Name='Europe')
>>> france = Country(Name='France', Continent=europe)
>>> paris = City(Name='Paris', Country=france)
>>> nice = City(Name='Nice', Country=france)
>>>
>>> europe.Country(Name='France') is france
True
france.City(Name='Paris') is paris
True
>>> europe.Country(Name='France').City.list
[<City Name:Paris>, <City Name:Nice>]
Anthony's suggestion: -
>>> europe = db.Continent.insert(Name='Europe')
>>> france = db.Country.insert(Name='France', Continent=europe)
>>> paris = db.City.insert(Name='Paris', Country=france)
>>> nice = db.City.insert(Name='Nice', Country=france)
>>> db.Country(france).City.select()
[<Row Name:Paris>, <Row Name:Nice>]
This would be so intuitive and easy to use...
Can you expand on this statement and help me understand how this
proposed syntax is any more intuitive or simpler than the web2py
suggestions, which to my eye are clearer by dint of being more explict?
Am I missing something here?
[1] http://seldo.com/weblog/2011/08/11/orm_is_an_antipattern
--
Regards,
PhilK
e: [email protected] - m: 07775 796 747
'work as if you lived in the early days of a better nation'
- alasdair gray
--
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.