[ZODB-Dev] Odd output from checkbtrees.py

Paul Winkler pw_lists at slinkp.com
Tue Sep 2 18:49:02 EDT 2003


On Sun, Aug 31, 2003 at 07:15:06PM +0200, Dieter Maurer wrote:
> Paul Winkler wrote at 2003-8-28 15:55 -0400:
>  > ...
>  > >  > Correct. And in fact, there were 2 issues to deal with:
>  > >  > 1) obj.__dict__.items() sometimes picks things up
>  > >  > through acquisition, as demonstrated by the problem with DCWorkflow
>  > >  > transitions (and states, BTW).
>  > > 
>  > > I do not want to believe this.
>  > > 
>  > > It is impossible unless someone defined "__dict__= Acquired".
>  > > And this is only possible with special classes implemented in C.
>  > 
>  > Nevertheless, go into your debugger, get a ZODB connection to a
>  > database that contains at least one DCWorkflow stuff, find an instance of 
>  > TransactionDefinition, and you will see that its __dict__ contains
>  > items from its container. 
> 
> I did as you suggested and I saw:
> 
> [('actbox_url', '%(content_url)s/RedirectingWorkflowAction?transition=release'), ('id', 'release'), ('__ac_local_roles__', {'dieter': ['Owner']}), ('actbox_name', 'Nachricht online stellen'), ('after_script_name', ''), ('guard', <Guard instance at 935b400>), ('script_name', 'release'), ('actbox_category', 'workflow'), ('title', 'freigeben'), ('trigger_type', 1), ('new_state_id', 'released')]
> 
> There is nothing obtained via acquisition.

I apologize for sending you in the wrong direction. I typed that while unable
to access the server in question, and evidently I mis-remembered.

It's not obj.__dict__ that's the problem, it's obj.items() which is called
a few lines later in checkbtrees.py.  Unless you do the 
obj = obj.aq_base trick, you can get the items() method of the container.
Example:

(PRODUCTS_PATH and PYTHONPATH must be set before doing this...)

[pwinkler at dev-zope-knox01 Tools]$ python2.1 
Python 2.1.3 (#3, Oct 15 2002, 13:16:08) 
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import ZODB
>>> from ZODB.FileStorage import FileStorage
>>> name = '../../../../var/Data.fs'
>>> fs = FileStorage(name, read_only=1)
>>> cn = ZODB.DB(fs).open()
>>> rt = cn.root()
>>> app = rt['Application']
>>> # ok, i happen to know where a cmf instance is...
... 
>>> portal = app.portals
>>> portal.portal_workflow.objectIds()
['default_workflow', 'cti_basic_workflow']
>>> portal.portal_workflow.cti_basic_workflow.transitions
<Transitions instance at 89bfd88>
>>> portal.portal_workflow.cti_basic_workflow.transitions.objectIds()
['publish', 'retract']
>>> portal.portal_workflow.cti_basic_workflow.transitions.publish    
<TransitionDefinition at /portals/portal_workflow/cti_basic_workflow/transitions/publish>
>>> # transitions can acquire...
...
>>> portal.portal_workflow.cti_basic_workflow.transitions.publish.retract
<TransitionDefinition at /portals/portal_workflow/cti_basic_workflow/transitions/retract used for /portals/portal_workflow/cti_basic_workflow/transitions/publish>
>>> # ... but not through __dict__...
...
>>> portal.portal_workflow.cti_basic_workflow.transitions.publish.__dict__['retract']
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
KeyError: retract
>>> # ... the problem is the call to items().
... # e.g. here we see taht publish seems to contain itself and its sibling.
...
>>> portal.portal_workflow.cti_basic_workflow.transitions.publish.items()      
[('publish', <TransitionDefinition at /portals/portal_workflow/cti_basic_workflow/transitions/publish>), ('retract', <TransitionDefinition at /portals/portal_workflow/cti_basic_workflow/transitions/retract>)]
>>> # items comes from the container.
>>> portal.portal_workflow.cti_basic_workflow.transitions.publish.items        
<bound method Transitions.items of <Transitions instance at 89bfd88>>
>>> portal.portal_workflow.cti_basic_workflow.transitions.items
<bound method Transitions.items of <Transitions instance at 89bfd88>>
>>> # aq_base gets rid of the unwanted items.
...
>>> portal.portal_workflow.cti_basic_workflow.transitions.publish.aq_base.items()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: items

-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's FLYING INDEFATIGABLE TROMBONIST!
(random hero from isometric.spaceninja.com)



More information about the ZODB-Dev mailing list