[Zope3-Users] container protectName

Pete Taylor baldtrol at gmail.com
Wed Mar 29 01:56:21 EST 2006


Hi all (yet again ;) ),
I ran into this issue on a project I worked on before, but I ended up
changing the design before  it became a significant issue.  this time
around, i don't see a way by it.

i have a class that derives from Folder (or BTreeContainer, it doesn't
really matter for this).  in configure.zcml, i set it up as follows:
         <content class=".consumer.Consumer">
            <implements
               
interface="zope.app.annotation.interfaces.IAttributeAnnotatable"      
         />
            <require
                permission="zope.ManageContent"
                interface="zope.app.container.interfaces.IReadContainer"
                />
            <require
                permission="zope.ManageContent"
                interface="zope.app.container.interfaces.IWriteContainer"
                />
            <require
                permission="zope.ManageContent"
                interface=".interfaces.consumer.IConsumer"
                />
            <require
                permission="zope.ManageContent"
                set_schema=".interfaces.consumer.IConsumer"
                />
        </content>

this doesn't work.  putting in the third-down require statement breaks
it, throwing me a traceback that says something about protectName. 
i've looked through zope.app.security.protectclass (where protectName
comes from), and i just honestly don't see what the issue is.  i've
even tried it with removing the I{Read/Write}Container bits...  the
only difference between this class and any other just class
MyClass(Persistent) style is just that it happens to be a container.

is there something about Folder or BTreeContainer that invokes a
different kind of security checking than a simple Persistent class
derivative?

the issue is that I want/need to be able to both have the class
contain other persistent objects, while simultaneously have it be able
to have a view on it that allows the update and modification of
certain attributes...  like the following:
consumer.full_name
consumer['preferences'] = Preferences()

there are, obviously, ways around this.  i can redesign the way i'm
attempting to use the object, if necessary.  but it works from the
interactive interpreter, it just fails in the zcml.  and if i leave
out the relevant zcml bit, it just throws me "Unauthorized" errors.

anyone have any ideas?

I've put the traceback below...

Traceback (most recent call last):
  File "bin/runzope", line 48, in ?
    run()
  File "bin/runzope", line 44, in run
    main(["-C", CONFIG_FILE] + sys.argv[1:])
  File "/opt/zope3//lib/python/zope/app/twisted/main.py", line 74, in main
    service = setup(load_options(args))
  File "/opt/zope3//lib/python/zope/app/twisted/main.py", line 139, in setup
    zope.app.appsetup.config(options.site_definition, features=features)
  File "/opt/zope3//lib/python/zope/app/appsetup/appsetup.py", line
110, in config
    context = xmlconfig.file(file, context=context, execute=execute)
  File "/opt/zope3//lib/python/zope/configuration/xmlconfig.py", line
556, in file
    context.execute_actions()
  File "/opt/zope3//lib/python/zope/configuration/config.py", line
606, in execute_actions
    for action in resolveConflicts(self.actions):
  File "/opt/zope3//lib/python/zope/configuration/config.py", line
1511, in resolveConflicts
    raise ConfigurationConflictError(conflicts)
zope.configuration.config.ConfigurationConflictError: Conflicting
configuration actions
  For: ('protectName', <class 'petetest.consumer.Consumer'>, '__contains__')
    File "/usr/lib/python2.4/site-packages/petetest/configure.zcml",
line 7.3-27.2
         <content class=".consumer.Consumer">
            <implements
               
interface="zope.app.annotation.interfaces.IAttributeAnnotatable"      
         />
            <require
                permission="zope.ManageContent"
                interface="zope.app.container.interfaces.IReadContainer"
                />
            <require
                permission="zope.ManageContent"
                interface="zope.app.container.interfaces.IWriteContainer"
                />
            <require
                permission="zope.ManageContent"
                interface=".interfaces.consumer.IConsumer"
                />
            <require
                permission="zope.ManageContent"
                set_schema=".interfaces.consumer.IConsumer"
                />
        </content>
    File "/usr/lib/python2.4/site-packages/personium/configure.zcml",
line 7.3-27.2
         <content class=".consumer.Consumer">
            <implements
               
interface="zope.app.annotation.interfaces.IAttributeAnnotatable"      
         />
            <require
                permission="zope.ManageContent"
                interface="zope.app.container.interfaces.IReadContainer"
                />
            <require
                permission="zope.ManageContent"
                interface="zope.app.container.interfaces.IWriteContainer"
                />
            <require
                permission="zope.ManageContent"
                interface=".interfaces.consumer.IConsumer"
                />
            <require
                permission="zope.ManageContent"
                set_schema=".interfaces.consumer.IConsumer"
                />
        </content>


--
"All guilt is relative, loyalty counts, and never let your conscience
be your guide."
  - Lucas Buck, American Gothic


More information about the Zope3-users mailing list