[z3] [Fwd: Re: [Zope3-Users] sqlos - getting factory of NoneType]
Brian Sutherland
jinty at web.de
Mon Jan 9 02:38:14 CET 2006
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))
> This way it works, I see the sql-objects and can even edit them :) - But
> works yust to run into the next bigger problem... (I can't create
> objects due to rollback problems) :((((
If you post a traceback here, there is a chance someone can give you a
quick answer.
--
Brian Sutherland
Metropolis - "it's the first movie with a robot. And she's a woman.
And she's EVIL!!"
More information about the z3
mailing list