I dont need history tracking, just revert documents to older ones.
Once get it working on simple form, then perhaps trying optimicing and
feeding only field, that has changed. Version field automatic update
was on my mind lately. Could it be something like this:

Column("version", Integer, default=1, nullable=False,
onupdate=document_versions.select(document_versions.document_id=c.document_id,
order_by=version, order=DESC, limit=1)

I just dont know, how to get current document id, is it just
c.document_id?

On 28 loka, 21:04, [EMAIL PROTECTED] wrote:
> > Next design problem for me is version table. I have Document model
> > with DocumentVersion model, but i dont know how to:
>
> > - get the latest version of document
> > - set creator and updator, automatic behavior for this
> > - update version number
> > - fetch thru Document(s) and DocumentVersion(s)
>
> just to warn you, if u're trying to have a versioned document, i.e.
> document with history of changes/versions, and track them in time,
> that's a rather complicated thing. see bitemporal mixin recipe in
> dbcook:https://dbcook.svn.sourceforge.net/svnroot/dbcook/trunk/dbcook/misc/t...
>
> if u don't realy care about the history, but only need the last one,
> that might be easier, YMMV.
>
> automatic setup of fields in an object, e.g. in your case
> creator/modifier of document, might be done at several places/times:
>  - object's constructor
>  - just before saving the object to DB - mapperEextension.befor_insert
> and friends
>  - maybe other places to hook between these two
> but u'll need a context-like state to keep track of the current user
> (or time or whatever).
> or, u can do it by hand somewhere at proper place within your
> workflow, around saving the object. Beware that either way it must be
> done in a way that does not change/affect objects which have not been
> really modified - else all objects will be always saved/updated, over
> and over.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to