[Zope] Create zope property from external method?

Pavlos Christoforou pavlos@gaaros.msrc.sunysb.edu
Fri, 12 Mar 1999 11:56:52 -0500 (EST)


On Fri, 12 Mar 1999, Andy Heath wrote:

> I'm a zope newbie
> 
> I have an external method in which I want to check whether a
> property within zope exists and if it doesn't exist to create it.
> 
> How can I do this ?
> 
> Andy

If your external method is called from DTML document 'foo' then something
like this should do it (untested):

def mymethod(self):
	if not self.hasProperty('myproperty'):
		self.manage_addProperty('myproperty','hello','string')

BTW you can achieve the same effect from DTML

<!--# unless myproperty-->
<!--# call "manage_addProperty('myproperty','hello','string')"-->
<!--#/unless-->

Pavlos