[Zope-dev] Python Product as DataSkin

Michael R. Bernstein webmaven@lvcm.com
Wed, 21 Feb 2001 07:26:26 -0800


Steve Alexander wrote:
> 
> Michael R. Bernstein wrote:
>  >
>  > File /home/webmaven/Products/ZPatterns/DataSkins.py, line 208, in
>  > __set_attr__ (Object: ElementWithAttributes) KeyError: (see above)
> 
> What version of ZPatterns are you using?

0.4.3b2 on Zope 2.2.0

> I certainly don't have the __set_attr__ method covering line 208 in my
> version.

In my DataSkins.py, line 208 is the one marked below:

>      def __set_attr__(self,name,val,_v_dm_=_v_dm_):
>          try:
> 208>>>       dm = self.__dict__[_v_dm_]
>          except KeyError:
>              if name=='id' and val==self.__dict__['id']: return
>              raise
> 
> If they don't, you'll get the error that you're reporting.

Well, that's the version I've got, and that is how the
__set_attr__ method reads. What do I check next?

Backtracking a bit more, line 46 in ArchiveImage.py is in
the manage_addArchiveImage method, marked below:

def manage_addArchiveImage(self, id, file, title='',
displays=None, precondition='',
                           content_type='', REQUEST=None):
      """
      Add a new ArchiveImage object.
      """
   # This constructor basically ripped off from Image/File
       id, title = cookId(id, title, file)
       self=self.this()
   # First, we create the ArchiveImage without data:
46>    self._setObject(id,
ArchiveImage(id,title,'',displays,content_type,precondition))
   # Now we "upload" the data.  By doing this in two steps,
we
   # can use a database trick to make the upload more
efficient.
       self._getOb(id).manage_upload(file)
       if REQUEST:
           try:    url=self.DestinationURL()
           except: url=REQUEST['URL1']
           REQUEST.RESPONSE.redirect('%s/manage_main' % url)
       return id

Does this help?

Thanks,

Michael Bernstein.