Re: [Zope-dev] Re: [Zope] Re: [Warning] Zope 3 component architecture (CA) not reliably usable for registrations from Python
Fred Drake wrote at 2007-1-10 17:30 -0500: On 1/10/07, Dieter Maurer [EMAIL PROTECTED] wrote: *It* must be informed whenever it is used in a different thread. Perhaps it could use some thread-local data to keep track of this? threading.local comes to mind. This is a nice idea but in this case not very practical: The module provides lots of functions. Each of these functions would need to get instrumented to interprete the thread-local variable and take appropriate action. -- Dieter ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: [Zope] Re: [Warning] Zope 3 component architecture (CA) not reliably usable for registrations from Python
Martijn Faassen wrote at 2007-1-10 11:45 +0100: I'm a bit surprised why the huge [warning] is necessary. What I understand you're saying is that you cannot use the component architecture before it's done initializing. The warning comes from bad experience. I have tested my registration and in my test it worked because Products.Five.initialize happened to be called before. But during real use, my module was imported before Products.Five.initialize has been called -- leading to strange and not immediately recognizable errors. You also assert that you need a registration to happen at Python import time. I'm curious to hear more about why you need to do this I know that the module needs to get informed about request starts. What is more natural than registering for this event when the module is imported? ... some complex delaying of registrations ... Perhaps you can use a similar strategy. Probably I could but it seems quite complex compared to a slightly more complete initialization of the CA via Python (rather then the late initialization via Five). Moreover, I would have to find the correct time to activate the delayed registrations. This time must be after Products.Five.initialize is called -- and nothing specifies the order in which products are initialized. -- Dieter ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: [Zope] Re: [Warning] Zope 3 component architecture (CA) not reliably usable for registrations from Python
Philipp von Weitershausen wrote at 2007-1-10 15:40 +0100: ... Things changed a bit after Zope 2.8/X3 3.0. Nowadays, the Component Architecture doesn't need any setup anymore and you can do registrations on import. Very good! I'd still recommend against that. Why? ... That's because Five assumes it's responsible for the setup layer. I suggest to register components through ZCML. Five will pick up configure.zcml in products automatically *after* everything has been set up properly. The registration is necessary for the module *and not* any product. It might be possible that any product that uses the module registers for the event -- but it would break modularity and would be slightly inefficient. ... I typically find it quite magic when application policy things happen at import: It is not application policy but a module requirement: *It* must be informed whenever it is used in a different thread. In Zope, this may be approximated via an information about the beginning of each request processing. P.S.: I agree with Martijn, the big warning is uncalled for. You're just trying to fight the semantics of the framework. That the semantics meanwhile has changed (as you note above) indicates that is has not really been right. And fighting against wrong semantics is a good thing :-) On the other hand, I agree that my fight came late as the current release already allows what I was looking for. Apparently, others already fought successfully... -- Dieter ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Re: [Zope] Re: [Warning] Zope 3 component architecture (CA) not reliably usable for registrations from Python
On 1/10/07, Dieter Maurer [EMAIL PROTECTED] wrote: *It* must be informed whenever it is used in a different thread. Perhaps it could use some thread-local data to keep track of this? threading.local comes to mind. -Fred -- Fred L. Drake, Jr.fdrake at gmail.com Every sin is the result of a collaboration. --Lucius Annaeus Seneca ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )