On Friday, April 19, 2019 at 10:54:11 AM UTC-4, Carlos Cesar Caballero wrote: > > As almost everything in our world ORMs has advantages and disadvantages. > The main criticism about ORMs is that they are leaky abstractions, that > means they leaks details that it is supposed to abstract away, because > there are times when you just need to use, for example, SQL directly or > work with raw rows when making complex queries or improving performance > because that is one of the ORMs disadvantages, they include an extra > logical layer that, depending on the implementation can affect performance > more or less. > > But there are lot of people out there using ORMs and this is because they > have advantages, compared with PyDAL, mostly when you are using big models, > for example, compare this PyDAL model: > > def _get_somethig_plus_age(row, extra): > return row.person.age + extra > > db.define_table('person', > Field('name') > Field('age', 'integer') > Field.Method('get_somethig_plus_age', _get_somethig_plus_age) > ) > > against this ORM-style model: > > class Person(Model): > name = Field() > age = Field('integer') > > def get_somethig_plus_age(self, extra): > return self.age + extra > > In an ORM, a model class represents a table, and when you query the DB, > you get the class instance objects representing rows. Using this approach > you can directly benefit from the advantages of the OOP and the code > readability and organization improves a lot, mostly when models starts grow > big. >
In the case of the weppy ORM in particular, though, I think it really is just alternative syntax for everything that can already be done via pyDAL, typically with the same number of lines of code (note, the above examples would have the same number of lines if you added the @rowattr('get_something_plus_age') decorator required by weppy to the instance method). Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.