[ZPT] Re: zope3-dev proposal on changing implicitly calling
Stuart Bishop
zen at shangri-la.dropbear.id.au
Thu Jul 17 18:57:33 EDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday, July 17, 2003, at 02:53 AM, Evan Simpson wrote:
> Florent Guillaume wrote:
>> To be honest, this sucks. I've always wanted to write
>> context/somefunc/something/etc
>> and have TALES realize that somefunc, being a method, is callable and
>> couldn't possibly have a 'something' attribute or key.
>
> Can we get some concrete examples, to nail down this use case? I
> would have no trouble with auto-calling objects that have type
> 'function' or 'instance method', since these are not legitimate
> candidates for attribute or key access. How often are these useful in
> the middle of a path, though? It's much more common in Zope for a
> callable class instance to have a number of interesting attributes and
> even act as a mapping.
I have a method 'getOntology' that returns the Ontology object
being used by our system. My page templates need to
access here.getOntology()['term_id'].descriptionAsHtml().
This cannot be written in a single TALES expression. I work around
it using ontology = ComputedAttribute(getOntology,1) in the object
that defines getOntology to work around this.
A method in the middle of a TALES path could always be called,
unless you really want to allow here/method/__doc__ (which shouldn't
be allowed, as we can't set security on method.__doc__). But the TALES
would break if someone replaced the method with an Object implementing
__call__
> I've come to the conclusion that it was a mistake for us not to set up
> a proper escape mechanism for TALES from the very beginning. We
> should have required that any characters other than alphanumeric,
> space, and ".-_" characters be escaped with backslashes. Then we
> would be free, now, to allow "context/somefunc()/something" while
> still supporting "context/somefile\(\)/something".
A new TALES v2 XML namespace could always be defined, which would switch
on any new rules.
- --
Stuart Bishop <zen at shangri-la.dropbear.id.au>
http://shangri-la.dropbear.id.au/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (Darwin)
iD8DBQE/Flbzh8iUz1x5geARAgwrAKDtYn5tZkKLdHBLtQnMKWvlTN3vtACgl/mI
jGoX33yiIkPQIln8DbU0Fxg=
=LHQB
-----END PGP SIGNATURE-----
More information about the ZPT
mailing list