[Zope] Assignment to Properties (not intuitive!)

Evan Simpson evan@tokenexchange.com
Fri, 23 Jul 1999 15:31:14 -0500


>> Try <!--#call "manage_changeProperties(prop1=1)"--> in the
>> DTML method.

> Is there any reason why the syntax can't just be <!--#call "prop1 = 1"-->.
> Manage_changeProperties is not intuitive at all.

There are a few:

1. Any tag expression is evaluated as a Python expression, and Python only
allows '=' as a statement.
2. Even if Python allowed it, we wouldn't want to use it; Property changes
must pass through a function which can enforce security, notify the object
store, etc.
3. All operations on objects are supposed to be performed by methods
starting with 'manage_'.
4. People would be tempted to create new properties this way, which would
fail since there's no way to specify the property type.

That said, there are flavors of sugar which someone could write for this, if
they felt motivated to do so:

1. Make a #setprop tag.  This could allow type specifier for new properties.
2. Hack the call tag to check for '=' in an expression and convert it
(Yech).
3. Use an external method. (WARNING: You can accidentally bypass the
property type system this way!)