In this case, I would say your code is model related. Note, in trunk you 
can now do:

@db.entry_class.add_method.get_by_entry_class_id
def get_by_entry_class_id(self, entry_class_id, grid=True):
    db = self._db
    query = (self.entry_class_id == entry_class_id)
    if grid:
        query &= (self.grid == True)
    entry_class_attributes = db(query).select(self.ALL, orderby=self.
field_position)
    return entry_class_attributes

rows = db.entry_class.get_by_entry_class_id(5)

Anyway, my point was that in web2py, you can think of the models folder 
more broadly -- imagine instead that it was named "globals" instead of 
"models".

Anthony


On Thursday, May 16, 2013 10:30:57 AM UTC-4, Domagoj Kovač wrote:
>
> Anthony thanks. Previously i worked with various languages and frameworks 
> and my general practice was to use models only for things related to data 
> model. Here i am not sure for what models are intended, firstly i used them 
> for create_table definitions, but as my code grew i moved this definitions 
> to 0.py. Now i use models like Classes that work with data from db.
>
> class EntryClassAttribute():
>
>     @staticmethod
>     def get_by_entry_class_id(entry_class_id, grid=True):
>
>         query = (db.entry_class_attribute.entry_class_id == entry_class_id
> )
>
>         if grid:
>             query &= (db.entry_class_attribute.grid == True)
>
>         entry_class_attributes = db(query).select(db.entry_class_attribute
> .ALL,
>                                                   orderby=db.
> entry_class_attribute.field_position)
>
>         return entry_class_attributes
>

-- 

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


Reply via email to