Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

Page Template help

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


garito at sistes

Aug 10, 2008, 9:32 PM

Post #1 of 14 (1444 views)
Permalink
Page Template help

Hi!
Could someone point me where the page template code decide if an expression
is a path expression or a string or python one, please?

I'm studying the zope page template classes and I would like to understand
where this decision is taken

Thank you so much!

--
Mis Cosas
http://blogs.sistes.net/Garito
Zope Smart Manager
http://blogs.sistes.net/Garito/670


philipp at weitershausen

Aug 10, 2008, 11:49 PM

Post #2 of 14 (1408 views)
Permalink
Re: Page Template help [In reply to]

Garito wrote:
> Could someone point me where the page template code decide if an
> expression is a path expression or a string or python one, please?
>
> I'm studying the zope page template classes and I would like to
> understand where this decision is taken

Products.PageTemplates.Expressions.createZopeEngine():

for pt in ZopePathExpr._default_type_names:
e.registerType(pt, ZopePathExpr)

ZopePathExpr._default_type_names contains, among others, the name
'standard', which makes this expression type the default expression type.

_______________________________________________
Zope maillist - Zope[at]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 )


garito at sistes

Aug 11, 2008, 6:48 AM

Post #3 of 14 (1395 views)
Permalink
Re: Page Template help [In reply to]

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)

More clear? Thanks!

2008/8/11 Philipp von Weitershausen <philipp[at]weitershausen.de>

> Garito wrote:
>
>> Could someone point me where the page template code decide if an
>> expression is a path expression or a string or python one, please?
>>
>> I'm studying the zope page template classes and I would like to understand
>> where this decision is taken
>>
>
> Products.PageTemplates.Expressions.createZopeEngine():
>
> for pt in ZopePathExpr._default_type_names:
> e.registerType(pt, ZopePathExpr)
>
> ZopePathExpr._default_type_names contains, among others, the name
> 'standard', which makes this expression type the default expression type.
>
> _______________________________________________
> Zope maillist - Zope[at]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


lists at zopyx

Aug 11, 2008, 6:51 AM

Post #4 of 14 (1401 views)
Permalink
Re: Page Template help [In reply to]

--On 11. August 2008 15:48:21 +0200 Garito <garito[at]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


garito at sistes

Aug 11, 2008, 6:56 AM

Post #5 of 14 (1399 views)
Permalink
Re: Page Template help [In reply to]

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[at]zopyx.com>

>
>
> --On 11. August 2008 15:48:21 +0200 Garito <garito[at]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


philipp at weitershausen

Aug 11, 2008, 7:09 AM

Post #6 of 14 (1400 views)
Permalink
Re: Page Template help [In reply to]

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[at]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 )


garito at sistes

Aug 11, 2008, 7:52 AM

Post #7 of 14 (1395 views)
Permalink
Re: Page Template help [In reply to]

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[at]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[at]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 at sistes

Aug 11, 2008, 8:41 AM

Post #8 of 14 (1405 views)
Permalink
Re: Page Template help [In reply to]

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[at]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[at]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[at]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


philipp at weitershausen

Aug 11, 2008, 12:20 PM

Post #9 of 14 (1393 views)
Permalink
Re: Page Template help [In reply to]

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[at]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 )


garito at sistes

Aug 11, 2008, 12:51 PM

Post #10 of 14 (1401 views)
Permalink
Re: Page Template help [In reply to]

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[at]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[at]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


philipp at weitershausen

Aug 11, 2008, 1:05 PM

Post #11 of 14 (1397 views)
Permalink
Re: Page Template help [In reply to]

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[at]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 )


garito at sistes

Aug 11, 2008, 1:32 PM

Post #12 of 14 (1399 views)
Permalink
Re: Page Template help [In reply to]

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[at]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[at]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


mustapha at headnet

Aug 12, 2008, 2:30 AM

Post #13 of 14 (1362 views)
Permalink
Re: Page Template help [In reply to]

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[at]weitershausen.de
> <mailto:philipp[at]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[at]zope.org
> <mailto:Zope[at]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[at]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[at]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 )


garito at sistes

Aug 12, 2008, 6:03 AM

Post #14 of 14 (1363 views)
Permalink
Re: Page Template help [In reply to]

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[at]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[at]weitershausen.de
> > <mailto:philipp[at]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[at]zope.org
> > <mailto:Zope[at]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[at]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[at]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 users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.