Re: [Zope3-dev] local-utility location and registration
В Втр, 05.07.2005, в 19:22, Fred Drake пишет: > On > 7/5/05, Jim Fulton <[EMAIL PROTECTED]> wrote: > > It is not supported. We really need to clean this area up > > a lot. I hope to make some progress on this in Zope 3.2. > > There won't be any backward-compatibility code to support > > unusual usages like yours. > > I think we should be able to register things in content space as > utilities, at least sometimes. We have a reasonable example in the > project I've been working on recently, though it could be done some > other way as well. (I think the cleanest way would be to have the > registered objects live in content space for our application, > however.) > > > -Fred My own reasoning: Q: That i have and that i want? A: My application is five content-folders: users(as principals), village, people, contracts, classifiers. Each folder has access interface (IUsersStorage, IVillageStorage ...). I do not want hard coded folders name => I want to get this folders by interfaces ( zapi.getUtility(IVillageStorage) ). Therefore, i location my folders in site-object and registration in sitemanager-object. Have i made a mistake? Thanks! ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] local-utility location and registration
On 7/5/05, Jim Fulton <[EMAIL PROTECTED]> wrote: > It is not supported. We really need to clean this area up > a lot. I hope to make some progress on this in Zope 3.2. > There won't be any backward-compatibility code to support > unusual usages like yours. I think we should be able to register things in content space as utilities, at least sometimes. We have a reasonable example in the project I've been working on recently, though it could be done some other way as well. (I think the cleanest way would be to have the registered objects live in content space for our application, however.) -Fred -- Fred L. Drake, Jr. Zope Corporation ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] local-utility location and registration
Garanin Michael wrote: Hello! My app setup code do follow step: 1) create simple AppSite (as ISite) in top 2) create local-utility object, for example PAU = PluggableAuthentication() 3) AppSite['PAU'] = PAU 4) registration the PAU in AppSite/++etc++site/default. In other words: local-utility object location in top/mysite, but registration in top/mysite/++etc++site/default. Q: It's work, but is it legal? Thanks! It is not supported. We really need to clean this area up a lot. I hope to make some progress on this in Zope 3.2. There won't be any backward-compatibility code to support unusual usages like yours. Jim -- Jim Fulton mailto:[EMAIL PROTECTED] Python Powered! CTO (540) 361-1714http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] local-utility location and registration
Garanin Michael wrote: Ok, but my setup code very like your code with little difference: - your code: default[folder_name] = utility - my code: site[folder_name] = utility (my question: is it legal?) As result i have url "MySite/PAU/USERS" instead "MySite/++etc++site/default/PAU/USERS". And it is works. Ok, finally I got it :) You try to register a 'content' component within the utility registry. Certainly the registered component does not have to live directly inside site folder in order to get invoked by the utility mechanism (compare global registrations), but it was a design goal of zope 3 to divide content- and software space (-> convention). In that respect it would a more adequate solution putting your pau regularly into the site manager and adding an additional content component or view that allows to manage the pau-utility within the content space. Regards, Dominik ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] local-utility location and registration
В Пнд, 04.07.2005, в 11:27, Dominik Huber пишет: > > Garanin Michael wrote: > > > > >Hello! > >My app setup code do follow step: > >1) create simple AppSite (as ISite) in top > >2) create local-utility object, > >for example PAU = PluggableAuthentication() > >3) AppSite['PAU'] = PAU > >4) registration the PAU in AppSite/++etc++site/default. > > > >In other words: local-utility object location in top/mysite, but > >registration in top/mysite/++etc++site/default. > >Q: It's work, but is it legal? > >Thanks! > > > > > IMO it makes sense that the default site folder is invoked if a local > utility is added to a site. > > We use the following helper function for the local utility additon and > registration: > > from zope.app import zapi > from zope.app.container.interfaces import INameChooser > from zope.app.component.interfaces.registration import ActiveStatus > from zope.app.component.interfaces import ISite > from zope.app.utility import UtilityRegistration > > def addLocalUtility(site, name, iface, utility, package='default'): > """Add a utility to a site > > The utility is added to the package and activated. > This assumes the site has already a Utility Service. > """ > # preconditions > if not ISite.providedBy(site): > raise TypeError('ISite required.') > > # get site manager and site management folder > sitemanager = site.getSiteManager() > default = sitemanager[package] > > # add utility to site management folder > chooser = INameChooser(default) > folder_name = chooser.chooseName(utility.__name__, utility) > default[folder_name] = utility > > # create service registration > path = zapi.getPath(utility) > registration = UtilityRegistration(name, iface, utility) > key = default.registrationManager.addRegistration(registration) > zapi.traverse(default.registrationManager, key).status = ActiveStatus > > return zapi.traverse(sitemanager, path) > > Regards, > Dominik > > Ok, but my setup code very like your code with little difference: - your code: default[folder_name] = utility - my code: site[folder_name] = utility (my question: is it legal?) As result i have url "MySite/PAU/USERS" instead "MySite/++etc++site/default/PAU/USERS". And it is works. ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] local-utility location and registration
Garanin Michael wrote: Hello! My app setup code do follow step: 1) create simple AppSite (as ISite) in top 2) create local-utility object, for example PAU = PluggableAuthentication() 3) AppSite['PAU'] = PAU 4) registration the PAU in AppSite/++etc++site/default. In other words: local-utility object location in top/mysite, but registration in top/mysite/++etc++site/default. Q: It's work, but is it legal? Thanks! IMO it makes sense that the default site folder is invoked if a local utility is added to a site. We use the following helper function for the local utility additon and registration: from zope.app import zapi from zope.app.container.interfaces import INameChooser from zope.app.component.interfaces.registration import ActiveStatus from zope.app.component.interfaces import ISite from zope.app.utility import UtilityRegistration def addLocalUtility(site, name, iface, utility, package='default'): """Add a utility to a site The utility is added to the package and activated. This assumes the site has already a Utility Service. """ # preconditions if not ISite.providedBy(site): raise TypeError('ISite required.') # get site manager and site management folder sitemanager = site.getSiteManager() default = sitemanager[package] # add utility to site management folder chooser = INameChooser(default) folder_name = chooser.chooseName(utility.__name__, utility) default[folder_name] = utility # create service registration path = zapi.getPath(utility) registration = UtilityRegistration(name, iface, utility) key = default.registrationManager.addRegistration(registration) zapi.traverse(default.registrationManager, key).status = ActiveStatus return zapi.traverse(sitemanager, path) Regards, Dominik ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com