[Zope-CMF] adding 'context' as an alias for 'object' in action expressions

Tres Seaver tseaver at palladion.com
Mon Dec 1 10:49:35 EST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

yuppie wrote:
> Hi!
> 
> 
> Laurence Rowe wrote:
>> yuppie wrote:
>>> David Glick wrote:
>>>> Does anyone have an objection to me adding 'context' as an alias for 
>>>> 'object' in the expression context that is built when executing CMF 
>>>> action expressions (in getExprContext in CMFCore/Expression.py)?  This 
>>>> would remove one common source of minor confusion for beginning 
>>>> CMF/Plone developers (namely, having to use object in action expressions 
>>>> when you use context everywhere else).
>>> -1
>>>
>>> "There should be one-- and preferably only one --obvious way to do it."
>>>
>>> 'context' is deprecated for this kind of expressions, CMF uses 'object' 
>>> everywhere. Supporting 'object' *and* 'context' or switching from 
>>> 'object' to 'context' will cause even more confusion.
>>>
>>> Please see this thread
>>> http://mail.zope.org/pipermail/zope-cmf/2005-March/021990.html
>>> with this result
>>> http://mail.zope.org/pipermail/zope-cmf/2005-March/021999.html
>> That thread refers to 'content' rather than 'context'.
> 
> The links to the thread were not meant as a contribution to the 
> discussion if 'context' is better than 'object'. My point is that this 
> was discussed before and that using 'object' was an explicit decision. 
> (And 'context' was also considered: 
> http://mail.zope.org/pipermail/zope-cmf/2005-March/021957.html )
> 
>> Page templates have already made 'context' available as an alternative 
>> to 'here'. I don't see why 'object' should be treated any differently.
>>
>> "There should be one-- and preferably only one --obvious way to do it."
> 
> The proposal was to *add* an alias. That means two ways to do it. It 
> makes the chance higher that you guess the right name, but it doesn't 
> make things more obvious.

'context' is the canonical name for the object through which a script or
templated was acquired (its aq_parent, in fact);  'here' is a
long-deprecated alias for 'context'.  'context' is like the 'self'
binding of a normal Python method.

Action expressions aren't scripts / templates, and don't have many of
the stock names ('context', 'container', 'template', 'script',
'traverse_subpath', 'namespace', 'subpath', 'options', 'modules',
'root') which scripts and templates offer;  instead, they offer names
which are useful in writing action URLs (e.g., 'object_url',
'folder_url', 'portal', 'user_id', etc.)  Their 'self' / 'context' would
logically be the ActionInformation object, rather than the "target" for
which the URL / condition is being computed.


> And the proposal was to change the expression context for actions. What 
> about CachingPolicyManager and DCWorkflow?

Exactly.

- -1 to the change from me.  Writing TALES expressions involves knowing
what the appropriate set of names are for the given usage.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJNAeP+gerLs4ltQ4RArqDAJwMckHvg3WN4DG4tpECX47sfxedGgCg2SPB
qO8mWcKPawW7rPgRow89E3A=
=9PP6
-----END PGP SIGNATURE-----



More information about the Zope-CMF mailing list