Programmatically adding my product
Hey All, I have a product, MyProduct, and am not able to add it programmatically. For Example.. inside a python script I do: folder_id = "yada" folder_obj = getattr( container, folder_id ) folder_obj.manage_addMyProduct( id, title, etc ) This raises an AttributError with value of 'manage_addMyProduct'. I can add/edit/view my product from the ZMI without any problem. I'm stumped, could someone help? I have no idea what direction to pursue on this one. Damon.
Damon Eckhoff wrote:
Hey All,
I have a product, MyProduct, and am not able to add it programmatically.
For Example.. inside a python script I do:
folder_id = "yada" folder_obj = getattr( container, folder_id ) folder_obj.manage_addMyProduct( id, title, etc )
This raises an AttributError with value of 'manage_addMyProduct'. I can add/edit/view my product from the ZMI without any problem. I'm stumped, could someone help? I have no idea what direction to pursue on this one.
please see http://www.zopelabs.com/cookbook/1012279676 for an explanation how to do that. cheers, oliver
I have the same problem as Damon. I have a product based on a ZClass. I have followed the example of the cookbook, and can easily get OFS products to add because they seem to have a manage_addXXXXXX(id='yyyy') attribute. However, my product based on the ZClass has no such attribute, hence the attribute error. The only attributes it appears to have are '_product' and '_d' and none of those appear to have an attributed 'manage_addXXXXXX(id='yyyy'). Any further help greatly appreciated. Rob Oliver Bleutgen wrote:
Damon Eckhoff wrote:
Hey All,
I have a product, MyProduct, and am not able to add it programmatically.
For Example.. inside a python script I do:
folder_id = "yada" folder_obj = getattr( container, folder_id ) folder_obj.manage_addMyProduct( id, title, etc )
This raises an AttributError with value of 'manage_addMyProduct'. I can add/edit/view my product from the ZMI without any problem. I'm stumped, could someone help? I have no idea what direction to pursue on this one.
please see http://www.zopelabs.com/cookbook/1012279676
for an explanation how to do that.
cheers, oliver
_______________________________________________ Zope maillist - Zope@zope.org 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 )
________________________________________________________________________ Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!! visit http://in.autos.yahoo.com
I have the same problem as Damon. I have a product based on a ZClass. I have followed the example of the cookbook, and can easily get OFS products to add because they seem to have a manage_addXXXXXX(id='yyyy') attribute.
However, my product based on the ZClass has no such attribute, hence the attribute error. The only attributes it appears to have are '_product' and '_d' and none of those appear to have an attributed 'manage_addXXXXXX(id='yyyy').
Any further help greatly appreciated.
Did Oliver's link not help?? tim
please see http://www.zopelabs.com/cookbook/1012279676
for an explanation how to do that.
cheers, oliver
Yes, it was helpful, in that up to now, I had not been able to programmatically add anything. Now can add OFS products and I'm sure anything else supplied with the distro. The problem is that the recipe in the cookbook did not work for my own ZClass based product and the reason I believe is that the ZClass derived product does not have a method of the form manage_addXXXX(id='yyyy'). Always reports an attribute error. Investigating using type() and dir() help somewhat, but I'm no further on. Tim Hicks wrote:
I have the same problem as Damon. I have a product based on a ZClass. I have followed the example of the cookbook, and can easily get OFS products to add because they seem to have a manage_addXXXXXX(id='yyyy') attribute.
However, my product based on the ZClass has no such attribute, hence the attribute error. The only attributes it appears to have are '_product' and '_d' and none of those appear to have an attributed 'manage_addXXXXXX(id='yyyy').
Any further help greatly appreciated.
Did Oliver's link not help??
tim
please see http://www.zopelabs.com/cookbook/1012279676
for an explanation how to do that.
cheers, oliver
_______________________________________________ Zope maillist - Zope@zope.org 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 )
________________________________________________________________________ Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!! visit http://in.autos.yahoo.com
Yes, it was helpful, in that up to now, I had not been able to programmatically add anything. Now can add OFS products and I'm sure anything else supplied with the distro.
The problem is that the recipe in the cookbook did not work for my own ZClass based product and the reason I believe is that the ZClass derived product does not have a method of the form manage_addXXXX(id='yyyy'). Always reports an attribute error. Investigating using type() and dir() help somewhat, but I'm no further on.
You do need a method for adding instances of your zclass. If you don't have one, add one, then call it like context.manage_addProduct['YourZClass'].theNameOfYourAddingMethod(id='foo') or something like that. hth, tim
participants (4)
-
Damon Eckhoff -
Oliver Bleutgen -
rra42 -
Tim Hicks