[Zope] Zope Products and keeping existing objects uptodate
kapil thangavelu
kthangavelu@earthlink.net
Mon, 7 Jan 2002 13:23:38 -0800
On Monday 07 January 2002 07:19 pm, Andreas Leitner wrote:
> Hi,
>
<snip>
>
> Now, I noticed that when I create an instance of a Product, then change
> the source code of the Product restart Zope the changes won't make it to
> the instance. Zope seems to copy all the dtml pages into it's db.
>
<snip>
> Is there an easy way to update already existing instances of Products to
> the latest version of the Product?
>
yes, use class based dtml files. if you store it as an instance attribute
than it will be. this is somewhat of a tradeoff as instance based dtml files
can be edited ttw while class based ones can not.
so to illustrate
from OFS.Folder import Folder
from Globals import DTMLFile
class FileFoo(Folder):
index_html = DTMLFile('ui/FileFooView', globals())
which is a class based view, actually this is more a property of using a dtml
file than it is of using a class based syntax. so now you can change the file
and changes will be reflected in all instances.
the other option which it seems like you're using is something similiar to
class FileFoo(Folder):
def manage_afterAdd(self, item, container):
# adds to dtml methods here
self.manage_addProduct['OFSP'].manage_addDTMLMethod() # adds dtml here
in the second case, your adding a separate persistent object to your
*instance* not class, in which case updates to your class definition will not
result in alteration. in this case using something like Craig suggested (an
upgrade method/script) as an upgrade path is a good idea.
i tend to use the class attribute approach myself, cause i prefer to have the
dtml/zpt on the fs for versioning, which ttw editing tends to defeat.
cheers
kapil