Tres Seaver wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Peter Bengtsson wrote:
I'm trying to upload a Photo into a newly create object in my product
class. The code looks something like this::
def manage_addSomething(dispatcher, id, title, photofile):
destination = dispatcher.Destination()
instance = Something(id, title)
destination._setObject(id, instance)
obj = destination._getOb(id)
# at this point, is 'obj' wrapped in aq stuff???
_adder = obj.manage_addProduct['Photo'].manage_addPhoto
_adder(id='', title='', file=photofile)
class Something(Folder):
def __init__(self, id, title):
self.id = id
self.title = title
The error I get is:
File "/home/peterbe/zope/zope285/Products/Photo/Photo.py", line 664,
in manage_addPhoto
dest._setObject(id, photo)
AttributeError: _setObject
I'm using Photo product 1.2.3 but I don't think it matters if it's a
Photo I'm trying to add or any other product.
If I add the photo after the transaction has been completed in a
separate request it works fine to add the photo to the recently created
object.
Any idea?
I don't actually use the 'Destination' bit, ever (in fact, I don't
remember ever even seeing it used). By inspection (in
'App.FacdtoryDispatcher'), it looks as though the metho returns an
unwrapped object, which would be a Bad Thing.
Using just the dispatcher instead of dispatcher.Destination() didn't
help but if you recommend, I'll stop using the Destination() thing from
now on.
The reason _setObject() didn't work was really silly and even embarrasing.
The base class I used was NOT FOLDERISH! :)
In my example I used "Folder" as the base class. In reality I used a
more oddly named class which confused me.
This happened because it was decided later to add photos into these kind
of objects.
Thanks for the help Tres!
--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
_______________________________________________
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )