AW: [Zope3-dev] Re: [ZODB-Dev] Problems with ZODB3-3.9.0_dev_r77011

Roger Ineichen dev at projekt01.ch
Thu Jul 19 10:36:32 EDT 2007


Hi Tobias

> Auftrag von Gary Poster
> Gesendet: Donnerstag, 19. Juli 2007 15:53
> An: Tobias Rodäbel

[...]

> >
> > zope.app.keyreference-3.5.0_dev_r77018-py2.4.egg requires
> > ZODB3>=3.9.0-dev-r77011
> >
> > But there might be a caching problem within ZODB3-3.9.0 dev 
> r77011,  
> > my debug session tells:
> >
> > > /development/Zope3/MyProject/eggs/ZODB3-3.9.0_dev_r77011-py2.4- 
> > macosx-10.4-ppc.egg/ZODB/Connection.py(644)_store_objects()
> > -> raise
> > (Pdb) obj
> > <zope.app.file.image.Image object at 0x3faadb0>
> > (Pdb) oid
> > '\x00\x00\x00\x00\x00\x00\x00\xc6'
> > (Pdb) self._cache[oid]
> > *** KeyError: '\x00\x00\x00\x00\x00\x00\x00\xc6'
> > (Pdb) self._cache[oid] = obj
> > *** TypeError: Cache values must be persistent objects.
> >
> > But zope.app.file.image.Image should be persistent.

[...]

> > Looking forward to some hints or help,
> 
> Hi Tobias.  The ZODB 3.9 dev version is only different from 3.8 in  
> some conflict resolution code, for which I am responsible.  Some  
> thoughts.

I'm pretty shure you ve got a LocationProxy arround your object
because the zope.app.file doesn't implement ILocation.

I've had this issue too and removed the location before I stored
the object.With e.g.

@apply
def photo():
    """See interfaces.IPersonalData"""
    def get(self):
        photo = self._photo
        if zope.proxy.isProxy(photo):
            photo = zope.proxy.getProxiedObject(photo)
        if photo is not None:
            proxy = LocationProxy(photo)
            proxy.__name__ = 'photo'
            proxy.__parent__ = self
            return proxy
    def set(self, photo):
        
        if photo is not None:
            # remove location proxy because the ZODB doesn't like it anymore
            photo = zope.proxy.getProxiedObject(photo)
        self._photo = photo

    return property(get, set)

Note:
This sample only works in our project because the name is allways
``photo``.


Gary
-----

This happens because of the call in 

ZODB.Connection.py
$Id: Connection.py 75693 2007-05-11 22:18:37Z jim $ 
cool that we have the revision info in the file header ;-)
line: 627

except:
    # Dang, I bet it's wrapped:
    # TODO:  Deprecate, then remove, this.
    if hasattr(obj, 'aq_base'):
        self._cache[oid] = obj.aq_base
    else:
        raise

My question is, can we improve the method:
if hasattr(obj, 'aq_base')
and remove the proxy with a method that works?


Tobias 
------
Can you agree this? And probably tell us if the 
"obj" is a proxy?

You can check this by get the type of the object.
e.g.
type(obj)


Regards
Roger Ineichen

> 
> Gary_______________________________________________
> Zope3-dev mailing list
> Zope3-dev at zope.org
> Unsub: 
> http://mail.zope.org/mailman/options/zope3-dev/dev%40projekt01.ch
> 
> 



More information about the Zope3-dev mailing list