| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
Crud
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
|
|||
|
form=crud.update(db.mytable,myrecord,onaccept=crud.archive) crud.archive will define a new table "mytable_archive" and store the previous record in the newly created table including a reference to the current record. If you want to access such table you need to define it yourself in a model:
db.define_table('mytable_archive',
Field('current_record',db.mytable),
db.mytable)
Notice such table includes all fields of db.mytable plus one:
current_record. crud.archive does not timestamp the stored record unless
your original table has a fields like:
db.define_table(...,
Field('saved_on','datetime',
default=request.now,update=request.now,writable=False),
Field('saved_by',auth.user,
default=auth.user_id,update=auth.user_id,writable=False),
there is nothing special about these fields since they are filled before the record is archived. If you want to change the archive table name and the name of the reference field you can do, for example:
db.define_table('myhistory',
Field('parent_record',db.mytable),
db.mytable)
and use it as:
form=crud.update(db.mytable,myrecord,
onaccept=lambda form:crud.archive(form,
archive_table=db.myhistory,
current_record='parent_record'))
|
.. method:: Crud.update(table, record, [next=DEFAULT
[, onvalidation=DEFAULT [, onaccept=DEFAULT [, log=DEFAULT
[, message=DEFAULT[, deletable=DEFAULT]]]]]])
|
.. method:: Crud.create(table, [next=DEFAULT [, onvalidation=DEFAULT
[, onaccept=DEFAULT [, log=DEFAULT[, message=DEFAULT]]]]])
|
.. method:: Crud.delete(table, record_id, [next=DEFAULT
[, message=DEFAULT]])
|
Creates a search form and its results for a table
Example usage:
form, results = crud.search(db.test,
queries = ['equals', 'not equal', 'contains'],
query_labels={'equals':'Equals',
'not equal':'Not equal'},
fields = [db.test.id, db.test.children],
field_labels = {'id':'ID','children':'Children'},
zero='Please choose',
query = (db.test.id > 0)&(db.test.id != 3) )
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Wed Jun 1 19:20:26 2011 | http://epydoc.sourceforge.net |