I have a python class which I've set up as a zope product and which shows up as such. Now, products installed this way don't show up on menus, so I've more or less followed the instructions and created a product with a zclass which subclasses the installed python product and, sure enough, this zclass shows up on menus. The next step was to create a folder with a dtml page and an instance of the zclass in it, and use the instance of the zclass in the dtml page, and that works. Nonetheless, ultimately, that doesn't seem to be what I want. Unless I'm missing something, that creates a single instance (object) of the class for good and all. I see print statements from the constructor the first time I ever bring the page up; afterwards, the object is still there, but it isn't being created. The systems seems to be saving it. What I really need is for a user to open a dtml page and create (his/her) object in doing so, and then use it. I assume it's possible to do that in dtml but I don't see any descriptions of how to do it. I'd appreciate hearing from anyone who knows how this is done.
On Mon, 2003-10-20 at 08:50, Ted holden wrote:
I have a python class which I've set up as a zope product and which shows up as such.
Super.
Now, products installed this way don't show up on menus, so I've more or less followed the instructions and created a product with a zclass which subclasses the installed python product and, sure enough, this zclass shows up on menus.
That shouldn't be necessary... did you register the class correctly in your product's __init__ module?
The next step was to create a folder with a dtml page and an instance of the zclass in it, and use the instance of the zclass in the dtml page, and that works.
If it works, I suppose that's something... but if you can do it all in your external product code, you might get better results & easier maintainability.
Nonetheless, ultimately, that doesn't seem to be what I want. Unless I'm missing something, that creates a single instance (object) of the class for good and all.
Yep.
I see print statements from the constructor the first time I ever bring the page up; afterwards, the object is still there, but it isn't being created. The systems seems to be saving it.
Correct... because you've created a persistent object, it is being persisted.
What I really need is for a user to open a dtml page and create (his/her) object in doing so, and then use it.
That's certainly possible... but then what? You want this object to only exist during the time the user has a session? To answer the first part, the URL to create a new instance of a product is usually something of the form: container/manage_addProduct/product_name/product_nameAdd As for collecting unused objects, you'll probably want to create a python script that steps over the instances of your product and deletes those that are deemed expired (however you choose to determine that). Then call that script from a cron job or something that can fire it off regularly. With a system that's adding and deleting instances with any regularity, you'll want to be sure to have a cron job pack your database regularly too. HTH, Dylan
participants (2)
-
Dylan Reinhardt -
Ted holden