[Z3-sqlos] Re: [z3] [Fwd: Re: [Zope3-Users] sqlos - getting factory of NoneType]

Christian Lück christian.lueck at ruhr-uni-bochum.de
Fri Jan 20 22:45:00 CET 2006


Hi Brian,

Brian Sutherland wrote:
> Hi Christian,
> 
> I have implemented the changes I have been talking about on a branch,
> you can see the checkins, starting from this post:
> 
> http://codespeak.net/pipermail/z3-checkins/2006q1/001908.html
> 
> Does anyone else have any comments on this?
> 
> On Mon, Jan 09, 2006 at 11:52:54PM +0000, Christian Lück wrote:
>> Brian Sutherland wrote:
>> > On Mon, Jan 09, 2006 at 07:52:38PM +0000, Christian Lück wrote:
>> >> Hi Brian!
>> >> 
>> >> Brian Sutherland wrote:
>> >> > On Sat, Jan 07, 2006 at 06:26:19PM +0000, Christian L�ck wrote:
>> >> >> Hi
>> >> >> 
>> >> >> The problem with sqlos seems: It does only work if ONE AND ONLY ONE
>> >> >> factory for the content component (interface) in question is registered.
>> >> >> And this one-and-only factory has to be registered with the
>> >> >> zcml-directive in a special sqlos namespace, ie.
>> >> >> 
>> >> >>   <sqlos:factory
>> >> >>       id="quotationtool.BookSQLObject"
>> >> >>       component=".book.Book"
>> >> >>       title="BookSQLObject"
>> >> >>       description="A book object for the sql resourcedb."
>> >> >>       />
>> >> >> 
>> >> >> When a second factory is registered for the same interface, ie.
>> >> >> 
>> >> >>   <factory
>> >> >>       id="quotationtool.BookWithInitialValues"
>> >> >>       component=".book.BookFactory"
>> >> >>       title="BookWithInitialValues"
>> >> >>       description="A factory for book object with initial values."
>> >> >>       />
>> >> >> 
>> >> >> sqlos fails to get the objects stored on the database (you get blank
>> >> >> browser pages).
>> >> >> The reason seems to be the implementation of
>> >> >> sqlos.container.SQLObjectContainer, which maps between sql-unique-keys
>> >> >> (SQLObject-names) and zope-object-names. The mapping mechanism makes use
>> >> >> of the factory.
>> >> > 
>> >> > Yes, I have seen this problem before. You cannot mix sqlos:factory and
>> >> > factory and expect things to work.
>> >> > 
>> >> > And yes, this is a _big_ problem which I think requires a re-think of
>> >> > how we do this. But that re-think is not yet thunk.
>> >> > 
>> >> > So please try this patch (untested). If it works for you, I will add it
>> >> > to the source.
>> >> > 
>> >> > Index: container.py
>> >> > ===================================================================
>> >> > --- container.py        (revision 21506)
>> >> > +++ container.py        (working copy)
>> >> > @@ -106,7 +106,9 @@
>> >> >          (name, object) for the objects that appear in the folder.
>> >> >          """
>> >> >          for factoryName in self.allowedFactories():
>> >> > -            factory = zapi.getUtility(IISQLObject, factoryName, context=self)
>> >> > +            factory = zapi.queryUtility(IISQLObject, factoryName, context=self)
>> >> > +            if factory is None:
>> >> > +                continue
>> >> >              for obj in factory.select():
>> >> >                  name = '%s.%s' % (factoryName, obj.id)
>> >> >                  yield (name, contained(obj, parent=self, name=name))
>> >> > 
>> >> 
>> >> No, this does not work for me.
>> > 
>> > Why?
>> 
>> Well, <snip>

I yust checked out from trunk. It works fine now. Thanks!
I had a look at the checkins too. Hey, you got rid of SQLObjectFactory.
Cool.

Kind Regards,
Christian







More information about the z3-sqlos mailing list