PageTemplates have an undocumented features called defer:. It's a kind of lazy initialization of variables. I've fixed to issues in my tiran-zpt-pydefer branch (svn): * DeferWrappers weren't working inside a python expression because PythonExpr didn't know about them * DeferWrapper didn't cache the result of the expression like ordinary vars do. I would like to merge my branch into 2.7 and 2.8 if I get an ok. Christian
On Mar 28, 2005, at 21:03, Christian Heimes wrote:
PageTemplates have an undocumented features called defer:. It's a kind of lazy initialization of variables.
I've fixed to issues in my tiran-zpt-pydefer branch (svn):
* DeferWrappers weren't working inside a python expression because PythonExpr didn't know about them
* DeferWrapper didn't cache the result of the expression like ordinary vars do.
I would like to merge my branch into 2.7 and 2.8 if I get an ok.
+1 I'm assuming the unit tests still run successfully and you added unit tests for your changes. jens
Jens Vagelpohl wrote:
I'm assuming the unit tests still run successfully and you added unit tests for your changes.
All unit tests are passing with my chances. I've to write some tests before merging my branch. I'll write them after somebody seconds my fix. Christian
Christian Heimes <heimes@faho.rwth-aachen.de> wrote:
PageTemplates have an undocumented features called defer:. It's a kind of lazy initialization of variables.
I've fixed to issues in my tiran-zpt-pydefer branch (svn):
* DeferWrappers weren't working inside a python expression because PythonExpr didn't know about them
* DeferWrapper didn't cache the result of the expression like ordinary vars do.
I would like to merge my branch into 2.7 and 2.8 if I get an ok.
I had trouble finding your branch because you put it in Zope/tiran-zpt-pydefer instead of Zope/branches/tiran-zpt-pydefer. Could you move it ? Florent -- Florent Guillaume, Nuxeo (Paris, France) CTO, Director of R&D +33 1 40 33 71 59 http://nuxeo.com fg@nuxeo.com
Christian Heimes wrote at 2005-3-28 21:03 +0200:
PageTemplates have an undocumented features called defer:. It's a kind of lazy initialization of variables.
I've fixed to issues in my tiran-zpt-pydefer branch (svn):
* DeferWrappers weren't working inside a python expression because PythonExpr didn't know about them
* DeferWrapper didn't cache the result of the expression like ordinary vars do.
I would like to merge my branch into 2.7 and 2.8 if I get an ok.
Maybe, the feature could get documented as well... An undocumented feature is only half valuable... -- Dieter
Dieter Maurer wrote:
Maybe, the feature could get documented as well...
An undocumented feature is only half valuable...
+1 Is there anybody out there who can help me with the docs? I need someone to translate my english into real and nice english and someone with the permissions to update the ZPT docs at zope.org. Christian
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Christian Heimes wrote:
Dieter Maurer wrote:
Maybe, the feature could get documented as well...
An undocumented feature is only half valuable...
+1
Is there anybody out there who can help me with the docs? I need someone to translate my english into real and nice english and someone with the permissions to update the ZPT docs at zope.org.
I'd be glad to help with that, Christian. Tres. - -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCTxsxGqWXf00rNCgRAlBWAJ0bRNxSl988o6bADBS26kiNfdcRfwCbBSZU O211nz1gkQeJA6W/99vPhmM= =UYLo -----END PGP SIGNATURE-----
Tres Seaver wrote:
I'd be glad to help with that, Christian.
I've added a doc string to the DeferExpr module. Do you want me to write more docs is it enough to be added to the ZPT guide? Also I need a little help for the unit tests. How can I emulate tal:content or similar inside an expression test? Except of some missing unit tests the branch is ready to merge. I would like to get the changes into Zope 2.7.6 so we could use them for Plone 2.1.0. Christian
Christian Heimes wrote:
* DeferWrapper didn't cache the result of the expression like ordinary vars do.
This was intended, though you couldn't know that since I never documented this. Consider the following terrible example: <div tal:define="xis defer:string:x is $x"> <p tal:repeat="x python:range(3)" tal:content="xis"></p> </div> This should evaluate to: <div> <p>x is 0</p> <p>x is 1</p> <p>x is 2</p> </div> Why?? I don't remember why I wanted this behavior; it was an experiment, and I can't find any code of mine that uses it. Cheers, Evan @ 4-am
Evan Simpson wrote:
Christian Heimes wrote:
* DeferWrapper didn't cache the result of the expression like ordinary vars do.
This was intended, though you couldn't know that since I never documented this. Consider the following terrible example:
<div tal:define="xis defer:string:x is $x"> <p tal:repeat="x python:range(3)" tal:content="xis"></p> </div>
This should evaluate to:
<div> <p>x is 0</p> <p>x is 1</p> <p>x is 2</p> </div>
Why?? I don't remember why I wanted this behavior; it was an experiment, and I can't find any code of mine that uses it.
That's an interessting use case. Do you want me to keep the code and make up a new expression? I'm thinking about "lazy:". Christian
Christian Heimes wrote:
That's an interessting use case. Do you want me to keep the code and make up a new expression? I'm thinking about "lazy:".
If you have a particular use for "defer:" that would justify the split, please go ahead. I have no particular interest in keeping it. Cheers, Evan @ 4-am
Evan Simpson wrote:
Christian Heimes wrote:
That's an interessting use case. Do you want me to keep the code and make up a new expression? I'm thinking about "lazy:".
If you have a particular use for "defer:" that would justify the split, please go ahead. I have no particular interest in keeping it.
I left defer: like it was coded by you and added a new expression lazy: that is working like a lazy initialization variable. Christian
participants (6)
-
Christian Heimes -
Dieter Maurer -
Evan Simpson -
Florent Guillaume -
Jens Vagelpohl -
Tres Seaver