[Grok-dev] Managing non-persisted objects

Kevin Teague kevin at bud.ca
Fri Jun 27 14:06:29 EDT 2008


Objects that inherit from the Persistent class (grok.Application, grok.Model,
grok.Container) *can* be stored in the ZODB. They are not automatically
stored, you need to explicitly give them a location within the database.
This happens by assigning the object to a container:

  # myobj inherits for Persistent
  # but that functionality is unused right now
  >>> myobj = MyModel()
  
  # now myobj has been stored in a ZODB database instance
  >>> root['myexistinggrokapp']['myobj'] = myobj

If you have a Model class or something similar that needs to be created on
every request to handle your COM integration, then you can write a custom
grok.Traverser to make it so that your grok.View class has a reference to
this object set at self.context (one approach - there are lots of other ways
to do the integration depending upon what you need your app to do):

See the section on custom Traversing in the Developer's Notes:

http://grok.zope.org/documentation/developers-notes/

And more reading here:

http://grok.zope.org/documentation/tutorial/navigating-to-transient-objects-tutorial/
-- 
View this message in context: http://www.nabble.com/Managing-non-persisted-objects-tp18158171p18160694.html
Sent from the Grok mailing list archive at Nabble.com.



More information about the Grok-dev mailing list