[Zope3-dev] How to provide some default utilities for sub-site
Adam Groszer
adamg at fw.hu
Fri Nov 4 07:12:57 EST 2005
Hello Dominik,
I think (that may be stupid, because I'm not an expert) that the
method is not 100% consistent, once it is checking on the passed
folder's SM and then trying to add the utility to a maybe completely
different SM.
By the way, is the (sub) site going to be deprecated? I see some BBB's
around.
Friday, November 4, 2005, 12:48:57 PM, you wrote:
> Hi Adam
> You need location information (-> __parent__) for this setup. Regularly
> the object knows that information not until its addition to a container.
> Subscribe to ObjectAdded event and do the same setup within the handler
> and it will work.
> Regards,
> Dominik
> Adam Groszer wrote:
>>I'd like to provide some default utilities for my sub-site.
>>As I checked there is the nice ensureUtility method but as it turns
>>out it failes with
>>
>>...
>> Module szscreen.app, line 339, in __init__
>> 'WorkflowUtility', WorkflowUtility, 'wfu')
>> Module zope.app.appsetup.bootstrap, line 66, in ensureUtility
>> name, **kw
>> Module zope.app.appsetup.bootstrap, line 74, in addConfigureUtility
>> utility_name = addUtility(root_folder, utility_type, utility_factory, **kw)
>> Module zope.app.appsetup.bootstrap, line 83, in addUtility
>> package = getSiteManagerDefault(root_folder)
>> Module zope.app.appsetup.bootstrap, line 105, in getSiteManagerDefault
>> package = traverse(root_folder, package_name)
>> Module zope.app.traversing.api, line 96, in traverse
>> return traverser.traverse(path, request=request)
>> Module zope.app.traversing.adapters, line 120, in traverse
>> curr = IPhysicallyLocatable(self.context).getRoot()
>> Module zope.app.location.traversing, line 90, in getRoot
>> raise TypeError("Not enough context to determine location root")
>>TypeError: Not enough context to determine location root
>>
>>when it checks the existence of the utility it uses
>> sm = root_folder.getSiteManager()
>>but when it wants to add the non existing utility
>> package = getSiteManagerDefault(root_folder)
>>which in turn wants to traverse like this
>> package_name = '/++etc++site/default'
>> package = traverse(root_folder, package_name)
>>
>>Is there any way to easily solve the task?
>>
>>Excerpt from szscreen.app:
>>
>>class IApplication(IReadContainer, IPossibleSite, IAttributeAnnotatable):
>> ""
>>
>>class Application(Persistent, SampleContainer, SiteManagerContainer):
>>
>> implements(IApplication)
>>
>> def __init__(self):
>> SampleContainer.__init__(self)
>>
>> sm = LocalSiteManager(self)
>> self.setSiteManager(sm)
>>
>> ...
>>
>> ensureUtility(self, IWorkflowUtility,
>> 'WorkflowUtility', WorkflowUtility, 'wfu')
>>
>>
>>
--
Best regards,
Adam mailto:adamg at fw.hu
--
Quote of the day:
Iron rusts from disuse; stagnant water loses its purity and in cold weather becomes frozen; even so does inaction sap the vigor of the mind.
- Leonardo da Vinci
More information about the Zope3-dev
mailing list