Re: [Zope] Changing Properties With ZPT

2005-08-10 Thread Andreas Jung



--On 9. August 2005 21:37:11 -0400 Dyyryath [EMAIL PROTECTED] 
wrote:



I'm trying to figure out how I can change the properties of a template
with ZPT. For example, let's say I've got a Page Template with a
property called 'name' and I want to change it in response to something
in the HTTP request:

div tal:condition=python:'name' in context.REQUEST
  SOME CODE TO CHANGE THE PROPERTY TO EQUAL context.REQUEST['name']
/div

I haven't seen anyway to do this with ZPT so I'm assuming that I'll need
to use a python script of some sort, but I'm not sure how to access the
template's properties without hardcoding the template's name.



Your question indicates that you have not understand yet that everything in 
Zope is an object with a unique API. Objects can be modified by calling 
their API from within ZPT, PythonScripts, external methods, product code or 
from wherever as long as the Zope security allows it. This means it makes 
no difference to modify an object from a PythonScript or from a ZPT *as 
long* as you know its API. What you want is provided by the PropertyManager 
API (see Zope Book Appendix B - PropertyManager).


-aj

pgphkqJuMKldS.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] Changing Properties With ZPT

2005-08-10 Thread Dyyryath
Thanks for the reply, Andreas.

Actually, I probably didn't properly explain my question. I do realize
that the template is an object and that all I need to do is access the
template's API to modify it's properties (though, I admit I'm a newbie
here). 

My problem is that the only way I can find to access the template object
is through ZPT's built-in variable 'template'. Since I'd like to change
the property, it seems like I'll need to use a python line that uses the
template's manage_changeProperties() method. I'm just not sure what the
python equivalent of the ZPT 'template' variable is.

An example is probably in order. Take the following code:

div tal:content=template/titleTITLE HERE/div
div tal:content=python:context.titleTITLE HERE/div

The first line does what I'd like it to do, it returns the 'title'
property of the template.

The second line doesn't. It returns the 'title' property of the
template's container.

How do I make the second line do the same thing as the first line. If
someone can give me that, I'll know how to do the rest.



Thanks for the On Wed, 2005-08-10 at 09:00 +0200, Andreas Jung wrote:
 
 --On 9. August 2005 21:37:11 -0400 Dyyryath [EMAIL PROTECTED] 
 wrote: 
 
  I'm trying to figure out how I can change the properties of a template
  with ZPT. For example, let's say I've got a Page Template with a
  property called 'name' and I want to change it in response to something
  in the HTTP request:
 
  div tal:condition=python:'name' in context.REQUEST
SOME CODE TO CHANGE THE PROPERTY TO EQUAL context.REQUEST['name']
  /div
 
  I haven't seen anyway to do this with ZPT so I'm assuming that I'll need
  to use a python script of some sort, but I'm not sure how to access the
  template's properties without hardcoding the template's name.
 
 
 Your question indicates that you have not understand yet that everything in 
 Zope is an object with a unique API. Objects can be modified by calling 
 their API from within ZPT, PythonScripts, external methods, product code or 
 from wherever as long as the Zope security allows it. This means it makes 
 no difference to modify an object from a PythonScript or from a ZPT *as 
 long* as you know its API. What you want is provided by the PropertyManager 
 API (see Zope Book Appendix B - PropertyManager).
 
 -aj

___
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] Changing Properties With ZPT

2005-08-10 Thread Sascha Ottolski
Am Mittwoch, 10. August 2005 16:31 schrieb Dyyryath:
 An example is probably in order. Take the following code:

 div tal:content=template/titleTITLE HERE/div
 div tal:content=python:context.titleTITLE HERE/div

why not using the same name in the python expression? :-)

div tal:content=python: template.titleTITLE HERE/div

just beware that the path expression template/title might do some magic for 
you, like calling a method, or accessing a dictionary etc. if in doubt, you 
can always do

div tal:content=python: path('template/title')TITLE HERE/div


cheers, sascha
___
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] Changing Properties With ZPT

2005-08-09 Thread Dyyryath
I'm trying to figure out how I can change the properties of a template
with ZPT. For example, let's say I've got a Page Template with a
property called 'name' and I want to change it in response to something
in the HTTP request:

div tal:condition=python:'name' in context.REQUEST
  SOME CODE TO CHANGE THE PROPERTY TO EQUAL context.REQUEST['name']
/div

I haven't seen anyway to do this with ZPT so I'm assuming that I'll need
to use a python script of some sort, but I'm not sure how to access the
template's properties without hardcoding the template's name.

Anybody got any suggestions?

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