> Date: Tue, 16 May 2000 15:03:26 +0200
> From: Marco Mariani <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: [Zope] I _still_ need help on ZClasses and manage_clone
> 
> I'm banging my head on the wall for this.
> 
> I have a ZClass which derives from Folder, and has permissons for "Documents,
> Images and Files".
> 
> When I try to use manage_clone within an instance of it, I get
> 
>    Error Type: AttributeError
>    Error Value: _getProducts
> 
> [...]
> 
> Traceback (innermost last):
>   File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module
>   File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 179, in publish
>   File /usr/lib/zope/lib/python/Zope/__init__.py, line 202, in 
>zpublisher_exception_hook
>     (Object: ElementWithAttributes)
>   File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 165, in publish
>   File /usr/lib/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply
>     (Object: PuploadMenu)
>   File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 102, in call_object
>     (Object: PuploadMenu)
>   File /usr/lib/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 248, 
>in __call__
>     (Object: PuploadMenu)
>     (Info: ((<Folder instance at 85b2328>, <h3>form</h3> [...]
> 
>   File /var/lib/zope/Extensions/upload.py, line 143, in uploadMenu
>     (Object: ElementWithAttributes)
>   File /var/lib/zope/Extensions/upload.py, line 70, in NewArticolo
>     (Object: ElementWithAttributes)
>   File /usr/lib/zope/lib/python/OFS/CopySupport.py, line 284, in manage_clone
>     (Object: ElementWithAttributes)
>   File /usr/lib/zope/lib/python/OFS/CopySupport.py, line 353, in _verifyObjectPaste
>     (Object: ElementWithAttributes)
>   File /usr/lib/zope/lib/python/App/FactoryDispatcher.py, line 96, in __getitem__
> AttributeError: (see above)
> 
> This is the relevant section of upload.py, where "gruppo" is a list of Image names.
> 
> "self" is the folder containing 'upload', which is a folder full of Images.
> 
> def NewArticolo(self,REQUEST,RESPONSE):
>     r=''
>     gruppo = REQUEST.form.get('gruppo')
> 
>     if gruppo:
>         next_art = self['prossimo_articolo']             # property of folder 'foto'
>         upload=self.upload.this()
>         id = 'art_%s'%next_art
> 
>         newob = upload.Control_Panel.Products.MArticolo.ArtClass(id)
>         newob.id = id
> #       newob.propertysheets.art_info.manage_changeProperties(REQUEST)
>         upload._setObject(id,newob)
> 
>     r=r+ 'Articolo %s aggiunto.<BR>' % next_art
>     next_art = next_art + 1
>     next_foto = self['prossima_foto']
> 
>     for i in gruppo:
> #       upload.manage_clone(upload[i],'foto_%s'%next_foto)
> #       ^^^^^^^ this works
> 
>         newob.manage_clone(upload[i],'foto_%s'%next_foto)
>         ^^^^^^^ this doesn't
> 
>         newob["foto_%s"%next_foto].manage_changeProperties({'filename': i})
>         r=r+ 'Foto %s aggiunta.<BR>' % i
>         next_foto = next_foto + 1
> 
>     self.manage_changeProperties({'prossimo_articolo': next_art})
>     self.manage_changeProperties({'prossima_foto': next_foto})
>     return r
> 
> Thank you for reading this far.

I think a lot of people, myself included, have had problems trying to
clone objects inside of new ZClass instances.  This sounds like the
problem you're having.  I haven't heard of a simple solution to the
problem.  John Morton talked about a possible workaround in a previous
posting.  Don't know if this will work for you, though.

Begin previous post by John Morton, March 28
-------------------------------------------------------------
Tres Seaver writes: 

> > Take three. I've solved the problem for all cases by having the ZClass 
> > add method redirect to a method that copies the default methods into 
> > the new ZClass instance, then redirects back to the management screen. 
> > 
> > Might have to write a howto for this one. 

> I'm glad you found a workaround.  Just offhand, did you try to just call that 
> additional method, before redirecting to it?  I have seen a couple of cases 
> where I refactored code like that into a new method and then things got simpler. 

Tried that - I in-lined it on the list for brevity's sake. The problem
is definitely with manage_clone not wanting to be used on a thing inside
the transaction that creates that thing.
-------------------------------------------------------------
End previous post

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to