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)
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,))