Is there any support within the framework for singletons? What I call
singletons are objects that are instanciated and persisted only once, or at
least should be.

I find myself wanting to use these in several instances, notably when I
create a class/object that acts as a gateway to an external system of some
kind (like a web service).

I create an object that provides a pythonic/zope-ish API to the rest of my
objects/product code.  I often like to use a persistent object (vs. a
regular python module/package) in order to take advantage of things like
caching, or giving options for configuration through the ZMI.

Given this use case, it would be nice to have Zope provide a framework to
support such things.  It could enforce the uniqueness of the object in the
entire system (absolutely no way to add more than one), and maybe provide a
global mechanism to "find" the object not needing to know where in the tree
it is, what it is called, or using the catalog (rather expensive?).  Maybe
something like a singleton flag and registry of somekind?

I can kind of achieve this partly by doing things like "visible=0" is my CMF
registration for example, forcing a specific id, enforcing rules in the
manage_add type methods, and so on, but it all seems so kludgy.  Not to
mention I always have to know the name of the object, and possibly even the
path, to get to it ... Redundant when there's always only one!

I'm not looking for solutions, but ideas and thoughts ... Although if
someone knows of ways to do this nicely, maybe with a third-party product
for example, I'd love to hear about it!


Jean-François Doyon
Internet Service Development and Systems Support / Spécialiste de
dèveloppements internet et soutien technique
Canada Centre for Remote Sensing/Centre Canadien de télédétection
Natural Resources Canada/Ressources Naturelles Canada
Tel./Tél.: (613) 992-4902
Fax: (613) 947-2410
Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to