yes
On Mar 19, 1:40 am, desfrenes <[email protected]> wrote:
> ok... so basically I can create classes that will use the DAL
> instead ?
> Can I still define these classes in db.py ?
>
> On 19 mar, 07:36, mdipierro <[email protected]> wrote:
>
> > You cannot because web2py has DAL not an ORM. This means records are
> > not objects, they are dictionaries.
>
> > You can define functions
>
> > def myCustomMethod(record):
> > return record.my_favorite_field
>
> > for record in db().select(.....): print myCustomMethod(record)
>
> > Massimo
>
> > On Mar 19, 1:23 am, Desfrênes Mickaël <[email protected]> wrote:
>
> > > Hello web2py fans,
>
> > > I was playing with web2py and I thought "where can I put my domain logic
> > > ?".
> > > Models/db.py only defines tables and fields but what if I want to add some
> > > logic on top ? Should I define classes that will use db like this:
>
> > > import db
>
> > > class myClass:
> > > def doSmth(self):
> > > # use db.table here
>
> > > In other frameworks I would just add methods to classes that inherits from
> > > Record class like this:
>
> > > class myClass extends Doctrine_Record
> > > {
> > > public function setTableDefinition()
> > > {
> > > $this->hasColumn('name','string');
> > > }
>
> > > // add some logic here
> > > public function myCustomMethod()
> > > {
> > > /// do something here.
> > > }
>
> > > }
>
> > > thanks for the advice.
>
> > > Mickaël.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---