[z3-five] local utility with zope 2.9.5

Dennis Schulz d.schulz81 at gmx.net
Tue Jan 16 14:05:40 CET 2007


Thanks for the help,
 
now I money patched OFS.Application as a site, but unfortunately the 
same error as when I try the register on the Plone Site. (See traceback 
at the end.)

Can't pickle <class 'OFSAnnotationUtility'>, maybe is it bad to mix it 
with OFS.SimpleItem to get it zope2 compatible? Or IOBTree can't be pickled?

Here is the utility I want to register:

class AnnotationUtility( Persistent ):
   
    def __init__(self):
        self.annotations = IOBTree()

    def get( self, context ):
        utility = component.getUtility( IIntIds, context=self )
        iid = utility.getId( context )
        if not self.annotations.has_key( iid ):
            self.create( iid )
        return iid, self.annotations.get( iid )

    def create( self, intid ):
        state = OOBTree()
        self.annotations[ intid ] = state

2007-01-16 14:00:46 ERROR Zope.SiteErrorLog 
http://localhost:8080/dd/portal_quickinstaller/installProducts
Traceback (innermost last):
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 326, in 
installProduct
   - __traceback_info__: ('PurchaseRequisition',)
  Module transaction._manager, line 96, in commit
  Module transaction._transaction, line 366, in commit
  Module transaction._transaction, line 295, in savepoint
  Module transaction._transaction, line 292, in savepoint
  Module transaction._transaction, line 675, in __init__
  Module ZODB.Connection, line 1012, in savepoint
  Module ZODB.Connection, line 526, in _commit
  Module ZODB.Connection, line 553, in _store_objects
  Module ZODB.serialize, line 407, in serialize
  Module ZODB.serialize, line 415, in _dump
PicklingError: Can't pickle <class 'OFSAnnotationUtility'>: attribute 
lookup __builtin__.OFSAnnotationUtility failed
C:\Python\Zope\Instance\Products\CMFQuickInstallerTool\QuickInstallerTool.py:348: 
DeprecationWarning: This will be removed in ZODB 3.7:
subtransactions are deprecated; use sp.rollback() instead of 
transaction.abort(1), where `sp` is the corresponding savepoint captured 
earlier
  transaction.abort(1)   #this is very naughty
2007-01-16 14:00:46 ERROR Zope.SiteErrorLog 
http://localhost:8080/dd/portal_quickinstaller/installProducts
Traceback (innermost last):
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 413, in 
installProduct
   - __traceback_info__: ('PurchaseRequisition',)
  Module Products.CMFQuickInstallerTool.InstalledProduct, line 99, in update
  Module ZODB.Connection, line 857, in register
  Module ZODB.Connection, line 867, in _register
  Module transaction._transaction, line 256, in join
  Module transaction._transaction, line 250, in _prior_operation_failed
TransactionFailedError: An operation previously failed, with traceback:

  File 
"C:\Python\Zope\Zope\lib\python\ZServer\PubCore\ZServerPublisher.py", 
line 23, in __init__
    response=response)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line 395, 
in publish_module
    environ, debug, request, response)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line 196, 
in publish_module_standard
    response = publish(request, module_name, after_list, debug=debug)
  File 
"C:\Python\Zope\Instance\Products\PlacelessTranslationService\PatchStringIO.py", 
line 34, in new_publish
    x = Publish.old_publish(request, module_name, after_list, debug)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line 115, 
in publish
    request, bind=1)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\mapply.py", line 88, 
in mapply
    if debug is not None: return debug(object,args,context)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line 41, 
in call_object
    result=apply(object,args) # Type s<cr> to step into published object.
  File 
"C:\Python\Zope\Instance\Products\CMFQuickInstallerTool\QuickInstallerTool.py", 
line 454, in installProducts
    reinstall=reinstall)
  File 
"C:\Python\Zope\Instance\Products\CMFQuickInstallerTool\QuickInstallerTool.py", 
line 326, in installProduct
    transaction.commit(1)
  File "C:\Python\Zope\Zope\lib\python\transaction\_manager.py", line 
96, in commit
    return self.get().commit(sub, deprecation_wng=False)
  File "C:\Python\Zope\Zope\lib\python\transaction\_transaction.py", 
line 366, in commit
    self._subtransaction_savepoint = self.savepoint(optimistic=True)
  File "C:\Python\Zope\Zope\lib\python\transaction\_transaction.py", 
line 295, in savepoint
    self._saveCommitishError() # reraises!
  File "C:\Python\Zope\Zope\lib\python\transaction\_transaction.py", 
line 292, in savepoint
    savepoint = Savepoint(self, optimistic, *self._resources)
  File "C:\Python\Zope\Zope\lib\python\transaction\_transaction.py", 
line 675, in __init__
    savepoint = savepoint()
  File "C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 1012, 
in savepoint
    self._commit(None)
  File "C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 526, in 
_commit
    self._store_objects(ObjectWriter(obj), transaction)
  File "C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 553, in 
_store_objects
    p = writer.serialize(obj)  # This calls __getstate__ of obj
  File "C:\Python\Zope\Zope\lib\python\ZODB\serialize.py", line 407, in 
serialize
    return self._dump(meta, obj.__getstate__())
  File "C:\Python\Zope\Zope\lib\python\ZODB\serialize.py", line 415, in 
_dump
    self._p.dump(classmeta)
PicklingError: Can't pickle <class 'OFSAnnotationUtility'>: attribute 
lookup __builtin__.OFSAnnotationUtility failed
C:\Python\Zope\Instance\Products\CMFQuickInstallerTool\QuickInstallerTool.py:426: 
DeprecationWarning: This will be removed in ZODB 3.7:
subtransactions are deprecated; use sp.rollback() instead of 
transaction.abort(1), where `sp` is the corresponding savepoint captured 
earlier
  transaction.abort(1)   #this is very naughty
2007-01-16 14:00:46 ERROR Zope.SiteErrorLog 
http://localhost:8080/dd/portal_quickinstaller/installProducts
Traceback (innermost last):
  Module ZPublisher.Publish, line 121, in publish
  Module Zope2.App.startup, line 240, in commit
  Module transaction._manager, line 96, in commit
  Module transaction._transaction, line 370, in commit
  Module transaction._transaction, line 250, in _prior_operation_failed
TransactionFailedError: An operation previously failed, with traceback:

  File 
"C:\Python\Zope\Zope\lib\python\ZServer\PubCore\ZServerPublisher.py", 
line 23, in __init__
    response=response)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line 395, 
in publish_module
    environ, debug, request, response)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line 196, 
in publish_module_standard
    response = publish(request, module_name, after_list, debug=debug)
  File 
"C:\Python\Zope\Instance\Products\PlacelessTranslationService\PatchStringIO.py", 
line 34, in new_publish
    x = Publish.old_publish(request, module_name, after_list, debug)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line 115, 
in publish
    request, bind=1)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\mapply.py", line 88, 
in mapply
    if debug is not None: return debug(object,args,context)
  File "C:\Python\Zope\Zope\lib\python\ZPublisher\Publish.py", line 41, 
in call_object
    result=apply(object,args) # Type s<cr> to step into published object.
  File 
"C:\Python\Zope\Instance\Products\CMFQuickInstallerTool\QuickInstallerTool.py", 
line 454, in installProducts
    reinstall=reinstall)
  File 
"C:\Python\Zope\Instance\Products\CMFQuickInstallerTool\QuickInstallerTool.py", 
line 326, in installProduct
    transaction.commit(1)
  File "C:\Python\Zope\Zope\lib\python\transaction\_manager.py", line 
96, in commit
    return self.get().commit(sub, deprecation_wng=False)
  File "C:\Python\Zope\Zope\lib\python\transaction\_transaction.py", 
line 366, in commit
    self._subtransaction_savepoint = self.savepoint(optimistic=True)
  File "C:\Python\Zope\Zope\lib\python\transaction\_transaction.py", 
line 295, in savepoint
    self._saveCommitishError() # reraises!
  File "C:\Python\Zope\Zope\lib\python\transaction\_transaction.py", 
line 292, in savepoint
    savepoint = Savepoint(self, optimistic, *self._resources)
  File "C:\Python\Zope\Zope\lib\python\transaction\_transaction.py", 
line 675, in __init__
    savepoint = savepoint()
  File "C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 1012, 
in savepoint
    self._commit(None)
  File "C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 526, in 
_commit
    self._store_objects(ObjectWriter(obj), transaction)
  File "C:\Python\Zope\Zope\lib\python\ZODB\Connection.py", line 553, in 
_store_objects
    p = writer.serialize(obj)  # This calls __getstate__ of obj
  File "C:\Python\Zope\Zope\lib\python\ZODB\serialize.py", line 407, in 
serialize
    return self._dump(meta, obj.__getstate__())
  File "C:\Python\Zope\Zope\lib\python\ZODB\serialize.py", line 415, in 
_dump
    self._p.dump(classmeta)
PicklingError: Can't pickle <class 'OFSAnnotationUtility'>: attribute 
lookup __builtin__.OFSAnnotationUtility failed
2007-01-16 14:00:46 ERROR root Exception while rendering an error message
Traceback (most recent call last):
  File "C:\Python\Zope\Zope\lib\python\OFS\SimpleItem.py", line 223, in 
raise_standardErrorMessage
    v = s(**kwargs)
  File "C:\Python\Zope\Instance\Products\CMFCore\FSPythonScript.py", 
line 108, in __call__
    return Script.__call__(self, *args, **kw)
  File "C:\Python\Zope\Zope\lib\python\Shared\DC\Scripts\Bindings.py", 
line 311, in __call__
    return self._bindAndExec(args, kw, None)
  File "C:\Python\Zope\Zope\lib\python\Shared\DC\Scripts\Bindings.py", 
line 348, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "C:\Python\Zope\Instance\Products\CMFCore\FSPythonScript.py", 
line 164, in _exec
    result = f(*args, **kw)
  File "Script (Python)", line 16, in standard_error_message
  File "C:\Python\Zope\Zope\lib\python\Shared\DC\Scripts\Bindings.py", 
line 311, in __call__
    return self._bindAndExec(args, kw, None)
  File "C:\Python\Zope\Zope\lib\python\Shared\DC\Scripts\Bindings.py", 
line 348, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "C:\Python\Zope\Instance\Products\CMFCore\FSPageTemplate.py", 
line 195, in _exec
    result = self.pt_render(extra_context=bound_names)
  File "C:\Python\Zope\Instance\Products\CMFCore\FSPageTemplate.py", 
line 134, in pt_render
    result = FSPageTemplate.inheritedAttribute('pt_render')(
  File 
"C:\Python\Zope\Zope\lib\python\Products\PageTemplates\PageTemplate.py", 
line 104, in pt_render
    tal=not source, strictinsert=0)()
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 238, 
in __call__
    self.interpret(self.program)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 281, 
in interpret
    handlers[opcode](self, args)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 749, 
in do_useMacro
    self.interpret(macro)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 281, 
in interpret
    handlers[opcode](self, args)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 457, 
in do_optTag_tal
    self.do_optTag(stuff)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 442, 
in do_optTag
    return self.no_tag(start, program)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 437, 
in no_tag
    self.interpret(program)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 281, 
in interpret
    handlers[opcode](self, args)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 749, 
in do_useMacro
    self.interpret(macro)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 281, 
in interpret
    handlers[opcode](self, args)
  File "C:\Python\Zope\Zope\lib\python\TAL\TALInterpreter.py", line 507, 
in do_setLocal_tal
    self.engine.setLocal(name, self.engine.evaluateValue(expr))
  File "C:\Python\Zope\Zope\lib\python\Products\PageTemplates\TALES.py", 
line 221, in evaluate
    return expression(self)
  File 
"C:\Python\Zope\Zope\lib\python\Products\PageTemplates\Expressions.py", 
line 185, in __call__
    return self._eval(econtext)
  File 
"C:\Python\Zope\Zope\lib\python\Products\PageTemplates\Expressions.py", 
line 180, in _eval
    return render(ob, econtext.vars)
  File 
"C:\Python\Zope\Zope\lib\python\Products\PageTemplates\Expressions.py", 
line 85, in render
    ob = ob()
  File "C:\Python\Zope\Instance\Products\CMFPlone\browser\plone.py", 
line 66, in globalize
    self._initializeData(options=options)
  File "C:\Python\Zope\Instance\Products\CMFPlone\browser\plone.py", 
line 118, in _initializeData
    self._data['actions'] = actions = (options.get('actions', None) or
  File "C:\Python\Zope\Instance\Products\CMFPlone\ActionsTool.py", line 
46, in listFilteredActionsFor
    [self._getActions(provider_name, actions, object) \
  File "C:\Python\Zope\Instance\Products\CMFPlone\ActionsTool.py", line 
34, in _getActions
    actions.extend( provider.listActionInfos(object=object) )
  File "C:\Python\Zope\Instance\Products\CMFCore\ActionProviderBase.py", 
line 86, in listActionInfos
    actions = self.listActions(object=object)
  File "C:\PLONE\Data\Products\CMFonFive\fiveactionstool.py", line 139, 
in listActions
    for menu_id in _listMenuIds():
  File "C:\PLONE\Data\Products\CMFonFive\fiveactionstool.py", line 32, 
in _listMenuIds
    return [id for id, utility in zapi.getUtilitiesFor(IBrowserMenu)]
  File "C:\Python\Zope\Zope\lib\python\zope\component\__init__.py", line 
263, in getUtilitiesFor
    return getSiteManager(context).getUtilitiesFor(interface)
  File "C:\PLONE\Data\Products\Five\site\localsite.py", line 142, in 
getUtilitiesFor
  File "C:\PLONE\Data\Products\Five\site\localsite.py", line 121, in 
utilities
  File "C:\Python\Zope\Zope\lib\python\zope\interface\interface.py", 
line 682, in __call__
    raise TypeError("Could not adapt", obj, self)
TypeError: ('Could not adapt', <Application at >, <InterfaceClass 
Products.Five.site.interfaces.IFiveUtilityRegistry>)




More information about the z3-five mailing list