[Zope] Problems adding attribute to custom object

Jean-Francois.Doyon@CCRS.NRCan.gc.ca Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Thu, 2 May 2002 13:43:43 -0400


Hello,

Thanks for the suggestion, I'l take a lok at that ...

As for the Object, it's completely custom in that I wrote it and doesn't
subclass anything else.

I obviously used the other CMF types as a base to write my own though ...

I guess I'll have ot look at how I wrote it, but from looking at others such
as CMF document and  son I don't *think* I missed anything.

J.F.



-----Original Message-----
From: complaw@hal-pc.org [mailto:complaw@hal-pc.org]
Sent: Thursday, May 02, 2002 12:31 PM
To: Jean-Francois.Doyon@ccrs.nrcan.gc.ca
Cc: zope@zope.org
Subject: Re: [Zope] Problems adding attribute to custom object


Is your new class completely custom, or did you derive it from an existing
class
(e.g., DTML Document)?

Something that has worked for me in the past is to do a search on the set of
objects...

for obj in context.objectValues('MyClassMetaName'):

.. and then use the base class addProperty method to add the additional
property.  You can also put a try/except block in your code to handle
exceptions.

Hope that helps.

Ron



> Hello,
> 
> I'm trying to add a new attribute to all objects of a certain meta_type on
> my site.  These are objects that already exist and are already
instantiated.
> 
> But, no matter how I go about it, I always end up with the same end
result:
> 
> Error Type: TypeError
> Error Value: attribute-less object (assign or del)
> 
> I've treid using portal_catalog search results, and then something like :
> setattr(a,'newporperty',''), but that gives me the error above. I also
tried
> o.property = '', but that didn't help ...
> 
> I also tried creating myobject = o.getObject() ... no go ...
> 
> Then I found some examples on various web sites that use ZopeFind to
locate
> their objects ... tried that, still no luck.
> 
> What am I missing here? One thing, this is a custom object I added to the
> CMFDefault product, could that be part of the problem? This object
otherwise
> works great within Zope and the CMF.
> 
> The traceback output varies depending on how I try to go about it, but
here
> is the lastest one:
> 
> File Script (Python), line 14, in addPropertyToObjectType
>     (Object: english)
>   File /usr/local/Zope-2.5.0/lib/python/RestrictedPython/Guards.py, line
> 107, in guarded_setattr
>     (Object: density)
> File /usr/local/Zope-2.5.0/lib/python/RestrictedPython/Guards.py, line 72,
> in handler
> 
> "English" is a Portal Folder, "density" is one of my custom objects ....
> 
> Help ?
> 
> Thanks in advance,
> 
> J.F.
> 
> 
> 
> _______________________________________________
> 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 )