I was wondering if it is possible, and if anyone has any advice on how to implement versioned DataObjects in modeladmin?
I have done some testing, and it seems I do find myself with a 'Versions' tab in ModelAdmin, but this appears to be empty, even after I have saved the Object multiple times, and have rows in the *_versions table. Also, it displays an 'Add Site Tree' link at the bottom of the page. I guess I can block this field in the form and define my own, so that's more of a curiosity than an issue, but I was also wondering if you can have versions in related objects ie, in the tables generated by the many_many relationships.
I hope someone can make head or tail of my ramblings!
Versioned doesn't seem to be suitable for DataObjects - it is linked too closely with SiteTree to really be suitable for other DataObjects. I believe the problem with ModelAdmin would be that it is not performing the right actions to create a version history. Versioned requires that you you 'publish', instead of just writing.
I've tried a couple of times and always ended up doing something custom based on what I needed.
A generic 'History' extension shouldn't be too hard to make though. Create a decorator, use it to augment the database with an additional 'changes' table per object. Whenever an update is made, intercept the call and copy the object to the history table before updating the object. It doesn't give your the 'multiple stages' functionality of Versioned, but you don't usually need that for DataObjects.
Hamish, what problems did you have with Versioned on non-SiteTree DataObject subclasses? I've used it a couple of times in the past in these scenarios, worked fine for me.
Of course you have to create your own interfaces for showing versioned historical info (perhaps in a TableListField?), and new ModelAdmin subclassed functionality for rolling back etc. - if you get anywhere, experiences and example code would be appreciated. Ideally we'd get this working out of the box, but we need some use cases first so we don't run off in the wrong direction ;)
Actually, I retract some of what I said. It is more a documentation issue than anything else (although, I hope that I echoed your comment that you need to add the actions to ModelAdmin to handle the versioning).
I'm about to give it another crack, so I'll add to this thread with what I've found.
I was just wondering if anyone got any further with this? I find myself in the situation that adding a version history to data objects would be very useful, but an not really sure where the best place to start is.