[Zope3-Users] object has no attribute '_SampleContainer__data'

Leticia Larrosa leticia at tesla.cujae.edu.cu
Tue Oct 4 13:55:31 EDT 2005


Hi:

Here are the steps for reproduce the error:

0- Create a package call "pbugs" and inside them:

1- Create a module with this content:
"""
from zope.interface import Interface
from zope.schema import TextLine
from zope.interface import implements
from zope.app.container.btree import BTreeContainer
from persistent import Persistent
from zope.app.container.interfaces import IContainer
from zope.app.container.constraints import ItemTypePrecondition

class IMessage(Interface):
    """A message object."""

    title = TextLine(
        title=u"Title/Subject",
        description=u"Title and/or subject of the message.",
        default=u"",
        required=True)
        
class IMessageContainer(IContainer):

    def __setitem__(name, object):
        """Add a IMessage object."""

    __setitem__.precondition = ItemTypePrecondition(IMessage)

class Message(Persistent):
    
    implements(IMessage)
    
    title = u''
"""

2- create a configure.zcml
"""
<configure
    xmlns="http://namespaces.zope.org/zope">

  <interface 
      interface="pbugs.message.IMessage" 
      type="zope.app.content.interfaces.IContentType"
      /> 

  <content class="pbugs.message.Message">
    <implements
        interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
        />

    <require
        permission="zope.ManageContent"
        interface="pbugs.message.IMessageContainer"/>

    <require
        permission="zope.ManageContent"
        interface="pbugs.message.IMessage"
        />
    <require
        permission="zope.ManageContent"
        set_schema="pbugs.message.IMessage"
        />
  </content>

  <include package=".browser" />

</configure>
"""

3- and create a browser package and a configure.zcml:
"""
<configure
    xmlns="http://namespaces.zope.org/browser">

  <addform
      label="Add Message"
      name="AddMessage.html"
      schema="pbugs.message.IMessage"
      content_factory="pbugs.message.Message"
      fields="title"
      permission="zope.ManageContent"
      />

  <addMenuItem
      class="pbugs.message.Message"
      title="Message"
      description="A Message"
      permission="zope.ManageContent"
      view="AddMessage.html" 
      />

  <editform
      schema="pbugs.message.IMessage"
      for="pbugs.message.IMessage"
      label="Change Message"
      fields="title"
      name="edit.html"
      permission="zope.ManageContent"
      menu="zmi_views" title="Edit" 
      />

  <containerViews
      for="pbugs.message.IMessage"
      index="zope.View"
      contents="zope.View"
      add="zope.ManageContent"
      />

</configure>
"""
4- start zope and add a content object of type "Message" in the ZMI

5- Change in "message.py":
This:
"""
class Message(Persistent):
    
    implements(IMessage)
    
    title = u''
"""
For this:
"""
class Message(BTreeContainer):
    
    implements(IMessage, IMessageContainer)
    
    title = u''
"""

6- Restart zope, and an error occurs when try to delete the old content
object Message, or when I try to see the content. The error is like I send
in a previous message.

Sorry if I can't minimize the steps for reproduce the error.

In the Zope 3 Developer's Handbook, Richter says:
"""
Note: If you make data-structural changes in your package, it might become
necessary to delete old instances of the objects/components. Sometimes even
this is not enough, so that you have to either delete the parent Folder or
best delete the Data.fs (ZODB) file. There are ways to upgrade gracefully to
new versions of objects, but during development the listed methods are
simpler and faster.
"""

If uses the attach files:
1- copy the extracted files into " C:\Zope3-Instance\lib\python\"
2- register the package into "C:\Zope3-Instance\etc\package-includes"
3- reproduce the steps 4, 5 and 6.

Regards
Leticia

-----Original Message-----
From: Jim Fulton [mailto:jim at zope.com] 
Sent: Tuesday, October 04, 2005 5:05 AM
To: Tom Dossis
Cc: Leticia Larrosa; zope3-users at zope.org
Subject: Re: [Zope3-Users] object has no attribute '_SampleContainer__data'

Tom Dossis wrote:
> Leticia Larrosa wrote:
> 
>> When a try to see the view of list of "Service" of one of the 
>> "ServiceList"
>> I get the following error:
>>
>> """
>> 'Service' object has no attribute '_SampleContainer__data'
>> """
>>
>> I'm newcomer in zope 3 and any idea will be appreciated.
>> Thanks in advance.
>>
>> Leticia Larrosa
> 
> 
> In addition to the previous reply; I experienced the above problem when..
> 
> I implementend a simple subclass of SampleContainer, then changed to 
> subclass BTreeContainer, but forget to delete existing instances created 
> in Zope.  A tell tale sign is you can no longer delete the broken 
> instance(s)

This sounds like a bug.  Could you report this with a specific example?

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org



-------------- next part --------------
A non-text attachment was scrubbed...
Name: pbugs.rar
Type: application/octet-stream
Size: 2783 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20051004/9f19dc4b/pbugs.obj


More information about the Zope3-users mailing list