Re: [Zope] Page Template help
Use: /path/to/the/object/with/${some/magic/variables}/to/solve/some/paths/in/a/simplest/way You could do that converting the path above to python: path(path('string:' + '/path/to/the/object/with/${some/magic/variables}/to/solve/some/paths/in/a/simplest/way')) or in a generic way: python: path(path('string:' + expr)) No more than 5 o 6 lines changed and a lot of code saved 2008/8/11 Andreas Jung <lists@zopyx.com>
--On 11. August 2008 15:48:21 +0200 Garito <garito@sistes.net> wrote:
Hi Philipp!
Thank you so much for your response but in this lines is were the engine loads the possibilities but not were evaluate the current expression
I would like to evaluate some condition before to load the class who resolves the expression (and witch is loaded in the code you point me)
Sounds strange to me. Usecase?
-aj
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
Garito wrote:
Use: /path/to/the/object/with/${some/magic/variables}/to/solve/some/paths/in/a/simplest/way
Path expressions already support this. tal:define="pathel some/magic/variables; obj path/to/the/object/with/?pathel/to/solve/some/..." So basically in TALES path expressions you can say foo/?bar and the value of the 'bar' variable will be used to traverse the next step from 'foo'.
Considere this case: I have the sking value in the variable at args/Yanged/Skin How can I do the equivalent to args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url ? In the python way it will be: path(path('string:' + 'args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url')) That's returns the expected value but I can't see how to do with your propossed way Thanks! 2008/8/11 Philipp von Weitershausen <philipp@weitershausen.de>
Garito wrote:
Use:
/path/to/the/object/with/${some/magic/variables}/to/solve/some/paths/in/a/simplest/way
Path expressions already support this.
tal:define="pathel some/magic/variables; obj path/to/the/object/with/?pathel/to/solve/some/..."
So basically in TALES path expressions you can say foo/?bar and the value of the 'bar' variable will be used to traverse the next step from 'foo'.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
Finally it's possible to do what I need without the need to declare any variable? If not my change will be 4-6 lines of code and it's ok for me to make this change I only need to understand were the code decides if the expression is standard, string or python Could you help me? Thanks! 2008/8/11 Garito <garito@sistes.net>
Considere this case:
I have the sking value in the variable at args/Yanged/Skin
How can I do the equivalent to
args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url
?
In the python way it will be:
path(path('string:' + 'args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url'))
That's returns the expected value but I can't see how to do with your propossed way
Thanks!
2008/8/11 Philipp von Weitershausen <philipp@weitershausen.de>
Garito wrote:
Use:
/path/to/the/object/with/${some/magic/variables}/to/solve/some/paths/in/a/simplest/way
Path expressions already support this.
tal:define="pathel some/magic/variables; obj path/to/the/object/with/?pathel/to/solve/some/..."
So basically in TALES path expressions you can say foo/?bar and the value of the 'bar' variable will be used to traverse the next step from 'foo'.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
Garito wrote:
Finally it's possible to do what I need without the need to declare any variable?
Not that I know of.
If not my change will be 4-6 lines of code and it's ok for me to make this change
I only need to understand were the code decides if the expression is standard, string or python
I already pointed you to the code where the different expression types are registered. From there you should be able to deduce where these registrations are used. I don't know this by heart and would have to search for myself.
Sure Philipp! I'm searching for some days and I still searching but if someone else knows the point perhaps he/she accelerate me ;) Thank you so much for your interest, Philipp!!!!! 2008/8/11 Philipp von Weitershausen <philipp@weitershausen.de>
Garito wrote:
Finally it's possible to do what I need without the need to declare any variable?
Not that I know of.
If not my change will be 4-6 lines of code and it's ok for me to make this change
I only need to understand were the code decides if the expression is standard, string or python
I already pointed you to the code where the different expression types are registered. From there you should be able to deduce where these registrations are used. I don't know this by heart and would have to search for myself.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
Garito wrote:
Considere this case:
I have the sking value in the variable at args/Yanged/Skin
How can I do the equivalent to
args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url
?
In the python way it will be:
path(path('string:' + 'args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url'))
That's returns the expected value but I can't see how to do with your propossed way
<a tal:define="skin args/Yanged/Skin; file args/Yanged/raiz/Skins/?skin/arbolYanged.css" tal:attributes="href file/absolute_url">
Yes, it's ok but I can save n variable definitions with 4 lines of code in 1 point Seems quite interesting for me Could someone point me were the page template decides if the expression is a standard, string, python, etc one, please? ;) 2008/8/11 Philipp von Weitershausen <philipp@weitershausen.de>
Garito wrote:
Considere this case:
I have the sking value in the variable at args/Yanged/Skin
How can I do the equivalent to
args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url
?
In the python way it will be:
path(path('string:' +
'args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url'))
That's returns the expected value but I can't see how to do with your propossed way
<a tal:define="skin args/Yanged/Skin; file args/Yanged/raiz/Skins/?skin/arbolYanged.css" tal:attributes="href file/absolute_url">
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
I'm not sure I get what you want to do. It is not the page template that decides about the expression but the engine as Philpp explained before. anyway, I think you are looking for the "compile" method of the ExpressionEngine class (look in zope/tales/tales.py). It's there where the expressions are parsed. HTH Garito wrote:
Yes, it's ok but I can save n variable definitions with 4 lines of code in 1 point Seems quite interesting for me
Could someone point me were the page template decides if the expression is a standard, string, python, etc one, please? ;)
2008/8/11 Philipp von Weitershausen <philipp@weitershausen.de <mailto:philipp@weitershausen.de>>
Garito wrote: > Considere this case: > > I have the sking value in the variable at args/Yanged/Skin > > How can I do the equivalent to > > args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url > > ? > > In the python way it will be: > > path(path('string:' + > 'args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url')) > > That's returns the expected value but I can't see how to do with your > propossed way
<a tal:define="skin args/Yanged/Skin; file args/Yanged/raiz/Skins/?skin/arbolYanged.css" tal:attributes="href file/absolute_url">
_______________________________________________ Zope maillist - Zope@zope.org <mailto:Zope@zope.org> http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
------------------------------------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Yeah, Mustaha! Sometimes I think I'm a little stupid, jejejeje, I have in front of my nose but I don't see it I was solved the problem adding a y: type expression and then subclass the PythonExpr with the __init__ method modified to change the expression Too much difficult to do the job in an acceptable way BUT!!! If you go to usr/lib/zope<version>/lib/python/zope/tales/tales.py and change the 592 and 593: 591 else: 592 type = "standard" 593 expr = expression to else: if expression.find('${') > -1: type = "python" expr = "path(path('string:%s'))" % expression else: type = "standard" expr = expression then you could use expressions like this path/to/render/${with/some/variable}/and/the/rest/of/the/path I think it's an acceptable change to the code for the job it does I don't know if Zope people will introduce this change but I think if not they will be wrong But they are absolute free to do what they want to do, don't misunderstand me, please 2008/8/12 mustapha <mustapha@headnet.dk>
I'm not sure I get what you want to do.
It is not the page template that decides about the expression but the engine as Philpp explained before.
anyway, I think you are looking for the "compile" method of the ExpressionEngine class (look in zope/tales/tales.py). It's there where the expressions are parsed.
HTH
Garito wrote:
Yes, it's ok but I can save n variable definitions with 4 lines of code in 1 point Seems quite interesting for me
Could someone point me were the page template decides if the expression is a standard, string, python, etc one, please? ;)
2008/8/11 Philipp von Weitershausen <philipp@weitershausen.de <mailto:philipp@weitershausen.de>>
Garito wrote: > Considere this case: > > I have the sking value in the variable at args/Yanged/Skin > > How can I do the equivalent to > >
args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url
> > ? > > In the python way it will be: > > path(path('string:' + >
'args/Yanged/raiz/Skins/${args/Yanged/Skin}/arbolYanged.css/absolute_url'))
> > That's returns the expected value but I can't see how to do with
your
> propossed way
<a tal:define="skin args/Yanged/Skin; file args/Yanged/raiz/Skins/?skin/arbolYanged.css" tal:attributes="href file/absolute_url">
_______________________________________________ Zope maillist - Zope@zope.org <mailto:Zope@zope.org> http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
------------------------------------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670
participants (3)
-
Garito -
mustapha -
Philipp von Weitershausen