OK. 2 is in trunk.

About 1). Are you asking to be able to extend class Table for a
specific define_table? Or doyou specifically need the move methods?

On Feb 16, 7:16 am, DenesL <denes1...@yahoo.ca> wrote:
> On Feb 16, 7:12 am, elffikk <elff...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > hi,
>
> > I propose to add a few things to DAL
>
> > 1) an 'act_as' parameter in define_table so I can extend Table class
> > and use it as regular table
>
> > for e.g.
>
> > db.define_table("images",
> >     Field("category", db.categories),
> >     Field("title"),
> >     act_as=OrderedList,
> > )
>
> > OrderedList is a class that extends Table class and adds a 'line'
> > column,
> > overrides insert and __del__ methods and adds 2 other methods:
> > move_before, move_after
>
> > required changes to gluon dal:
> > - add 'act_as' to the allowed keyword list in define_table method
> > ['migrate', 'primarykey', 'fake_migrate', 'format', 'trigger_name',
> > 'sequence_name', 'act_as']
> > - act_as = args.get('act_as',Table)  - Table is the default for
> > 'act_as'
> > - t = self[tablename] = act_as(self, tablename, *fields, ....
>
> > usages:
> > _id = db.images.insert(... )
> > db.images.move_before(_id,  2)
>
> Not sure I understand this one.
> Could you expand on it?.
>
> > 2) please add __mod__ to Expression class so I can use it in dal
> > expressions
>
> > I want that
>
> > #move last image to first position and all other images positions are
> > increased by 1
> > db(db.images).update(line=db.images.line % _count +1)
>
> > but I am forced to use raw sql
> > db.executesql('UPDATE images SET line = line %% %s +1', (_count,))
>
> +1 from me, it is easy to add in:
>
> to class BaseAdapter add
>
> def
> MOD(self,first,second):
>     return '(%s %% %s)' %
> (self.expand(first),self.expand(second,first.type))
>
> and to class Expression add
>
> def __mod__(self,
> other):
>     return
> Expression(self.db,self.db._adapter.MOD,self,other,self.type)

Reply via email to