Hi Thierry!
Thanks for your lat response, meanwhile things are getting more and more
clear to me.

I got it meanwhile to register utilities through the globalSiteManager,
and I am now very familiar now with zca basics (though that I have much
more to learn of it's API)

There is something totally unclear to me!

I got 2 applications registered in the

tamer@office /storage/PyProjects/ztfyAPP/src $ ls -lA
insgesamt 16
drwxr-xr-x 2 tamer tamer 4096  9. Jun 07:40 appsx
drwxr-xr-x 2 tamer tamer 4096 20. Mai 16:13 appsx.egg-info
drwxr-xr-x 4 tamer tamer 4096  9. Jun 07:43 webapp
drwxr-xr-x 2 tamer tamer 4096 20. Mai 02:35 webapp.egg-info

that is "webapp" and "appsx"

so far so good.

At /storage/PyProjects/ztfyAPP/src/appsx/__init__.py:

I globally registered a class, which definied previously as a utility.

from Services import *
from zope.component import getGlobalSiteManager
from zope.component import getUtilitiesFor,queryUtility

gsmx = getGlobalSiteManager()

VAT = VATServices()

now I want to have access this utility in the global sitemanager from
one other app.


from myhello import HelloView
from zope.component import getGlobalSiteManager

#print list(getUtilitiesFor('IVatServices'))

gsmx2 = getGlobalSiteManager()

I thought it is in the memory. Okay, that the interface is not available
in the other application is clear.

But, how do I access components or utilities registered in a different
application globally, at one other application at all ?!


Am 14.05.2013 09:22, schrieb Thierry Florac:
> Hi,
> Le Tue, 14 May 2013 06:55:38 +0200,
>   Tamer Higazi <th9...@googlemail.com> a écrit:
>> 1. What is the difference between a global and a localSiteManager from
>> the zope.component package?!
>> How do I have to understand that a "globalSiteManager" resists in
>> memory, and a localSiteManager is persistent ?!
>> Could somebody of you explain it to me?!
> Yes, there are two kinds of complementary "registries" (or "site
> managers"):
>  - a global one, mainly build by ZCML (or "static") declarations
>  - a local one, which is made of persistent components registered into
>    the ZODB. Local components are "contextual", so are only available
>    (by default) to objects "attached" to the site manager inside which
>    these components are defined. This registry is mainly specific to
>    Zope applications so if you build a ZCA-based application outside of
>    Zope, you will probably don't have a local registry.
> Where you are looking for a component, search is made at first in the
> local registry, then in the global one.
>> 2. What is the difference between an adapter and a utility ?! I
>> register an adapter as well the same way as I do with a utility, and
>> I query those 2 as well. But what's the point there?!
> A utility is a simple named component which provides an interface;
> it's generally a singleton.
> An adapter, on the opposite, takes one or more objects arguments (each
> providing a given interface) to return an object providing another
> interface.
> Regards,
> Thierry
> P.S.: please avoid cross-posts!

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to