Re: [Zope] Page Template help

2008-08-12 Thread Garito
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/zopeversion/lib/python/zope/tales/tales.py and change
the 592 and 593:

591else:
592type = standard
593expr = 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 [EMAIL PROTECTED]


 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
  [EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED]
 
  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
___
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 )


Re: [Zope] Page Template help

2008-08-11 Thread Garito
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 [EMAIL PROTECTED]

 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@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 )


Re: [Zope] Page Template help

2008-08-11 Thread Andreas Jung



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

pgp144f2ndoz3.pgp
Description: PGP signature
___
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 )


Re: [Zope] Page Template help

2008-08-11 Thread Garito
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 [EMAIL PROTECTED]



 --On 11. August 2008 15:48:21 +0200 Garito [EMAIL PROTECTED] 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
___
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 )


Re: [Zope] Page Template help

2008-08-11 Thread Philipp von Weitershausen
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;
   objpath/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 )


Re: [Zope] Page Template help

2008-08-11 Thread Garito
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 [EMAIL PROTECTED]

 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;
   objpath/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
___
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 )


Re: [Zope] Page Template help

2008-08-11 Thread Garito
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 [EMAIL PROTECTED]

 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 [EMAIL PROTECTED]

 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;
   objpath/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
___
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 )


Re: [Zope] Page Template help

2008-08-11 Thread Philipp von Weitershausen
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 )


Re: [Zope] Page Template help

2008-08-11 Thread Garito
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 [EMAIL PROTECTED]

 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
___
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 )


Re: [Zope] Page Template help

2008-08-11 Thread Philipp von Weitershausen
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 )


Re: [Zope] Page Template help

2008-08-11 Thread Garito
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 [EMAIL PROTECTED]

 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
___
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 )