Here's the beef: I've got a product I wrote in python that defines what amounts to a factory function that creates new objects of type 'foo' - let's call it manage_addFoo. The 'foo' class is of course defined in this same product. I've also created another class called fooFolder which simply contains the line: addFoo = manage_addFoo I then inherit this class into a new ZClass I define, simply so I can access the method manage_addFoo without needing the Manager role. However, when I call the addFoo function from dtml, I get an object which dissapears whenever I restart zope -- it appears in the management interface but when I try to access it, it can't be found. Even more interesting is that when I create the exact same object via the management interface, it works fine, and is still there after I restart zope. What gives?
Sometimes I'm not clear on when Zope commits a transaction for you and when it doesn't. It may be that the transaction you start by calling the factory method never gets committed. To commit it manually, in your Python code after you've done your magic, do: get_transaction().commit() (get_transaction is a global function, it needs not be qualified or imported from a particular module if you're working in a Product or in an external method). Brett Carter wrote:
Here's the beef: I've got a product I wrote in python that defines what amounts to a factory function that creates new objects of type 'foo' - let's call it manage_addFoo. The 'foo' class is of course defined in this same product. I've also created another class called fooFolder which simply contains the line: addFoo = manage_addFoo I then inherit this class into a new ZClass I define, simply so I can access the method manage_addFoo without needing the Manager role. However, when I call the addFoo function from dtml, I get an object which dissapears whenever I restart zope -- it appears in the management interface but when I try to access it, it can't be found. Even more interesting is that when I create the exact same object via the management interface, it works fine, and is still there after I restart zope. What gives?
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
-- Chris McDonough Digital Creations Publishers of Zope - http://www.zope.org
participants (2)
-
Brett Carter -
Chris McDonough