Re: [Zope] python: calling DTML-methods without quoting

2005-10-08 Thread Dieter Maurer
Chris wrote at 2005-10-4 17:00 +0200:
 ...
If I call a DTML-Method from an other Method (e.g. dtml-var someDTML), 
  HTML entities are not converted.

This calls (renders) the DTML object

However if I call it from python (e.g. dtml-var somePath.someDTML 
the entities are html_quoted.

this does not call (render) the DTML object but means the object itself.
The using environment converts the DTML object into a string by
calling str. str(dtmlObject) returns the object's source -- html quoted.


When you are using Python syntax (expr attribute),
you must yourself take care of calling the object (it
happens by magic when you use the name attribute (no Python syntax)).

Note, that calling DTML objects yourself has a caveat: you must
pass the two positional arguments None, _ (in order not
to loose the DTML namespace).

More info in Calling DTML objects of

  http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html


-- 
Dieter
___
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] python: calling DTML-methods without quoting

2005-10-04 Thread Chris

Hi,

I hope this is not a FAQ, but I looked for some info to no avail.

If I call a DTML-Method from an other Method (e.g. dtml-var someDTML), 
 HTML entities are not converted.


However if I call it from python (e.g. dtml-var somePath.someDTML 
the entities are html_quoted.


This changed with Zope 2.7.x (?). Before that DTMLMethods were not 
quoted when called from python.


I know the easy workaround is to dtml-with to the namespace of the 
object and call it the zope-way.


I have a customer with several large applications which run on an old 
Zope only for the described reason. The applications relay heavily on 
calling DTML-Methods to include pieces of HTML, JavaScript, etc. 
Changing the old code would be an enormous effort.


Is there a way to patch zope to show the old behavior?

Regards
Chris
___
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] python: calling DTML-methods without quoting

2005-10-04 Thread Peter Bengtsson
No.
dtml-var somePath.someDTML returns a pointer to that object
called someDTML. Not it's rendered content.
dtml-var somePath.someDTML(_, REQUEST) does the same as dtml-with
somePathdtml-var someDTML/dtml-with (sort of)

There's a big difference between
dtml-var somePath.someDTML(_, REQUEST)
and
dtml-var somePath.someDTML(_, REQUEST) html_quote

Either I didn't understand your question or this answers it for you.


2005/10/4, Chris [EMAIL PROTECTED]:
 Hi,

 I hope this is not a FAQ, but I looked for some info to no avail.

 If I call a DTML-Method from an other Method (e.g. dtml-var someDTML),
   HTML entities are not converted.

 However if I call it from python (e.g. dtml-var somePath.someDTML
 the entities are html_quoted.

 This changed with Zope 2.7.x (?). Before that DTMLMethods were not
 quoted when called from python.

 I know the easy workaround is to dtml-with to the namespace of the
 object and call it the zope-way.

 I have a customer with several large applications which run on an old
 Zope only for the described reason. The applications relay heavily on
 calling DTML-Methods to include pieces of HTML, JavaScript, etc.
 Changing the old code would be an enormous effort.

 Is there a way to patch zope to show the old behavior?

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



--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
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] python: calling DTML-methods without quoting

2005-10-04 Thread Chris

Hi Peter,


dtml-with somePath.someDTML
  dtml-var foo
/dtml-with


Now I'm very confused. What the heck is someDTML and what is foo.
I thought someDTML was a DTML Method/Document. Then what is foo?


Sorry, my fault. This should read
dtml-with somePath
   dtml-var someDTML
/dtml-with


I could be wrong but it seems your DTML usage is flawed. Then yes,
you'll have to write some regular expression scripts that recodes them
to call templates the correct way.


This would be no problem. However I need zope to do this automatically 
so I don't have to change the dtml-var calls in the customer's code. So 
my thought is to alter the __call__ method of DTMLMethod.py which is 
kind of ugly in case I want to update Zope later on.



PS. Do you need convincing that Page Templates are better than DTML
for HTML stuff?


I KNOW that :-) I don't use DTML myself. As I said I try to get a 
customer's stuff run on a curent version of zope. I would love to clean 
up his stuff and convert is to tal.


Regards
Chris
___
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] python: calling DTML-methods without quoting

2005-10-04 Thread Peter Bengtsson
2005/10/4, Chris [EMAIL PROTECTED]:
 Hi Peter,

 dtml-with somePath.someDTML
dtml-var foo
 /dtml-with
 
  Now I'm very confused. What the heck is someDTML and what is foo.
  I thought someDTML was a DTML Method/Document. Then what is foo?

 Sorry, my fault. This should read
 dtml-with somePath
 dtml-var someDTML
 /dtml-with

  I could be wrong but it seems your DTML usage is flawed. Then yes,
  you'll have to write some regular expression scripts that recodes them
  to call templates the correct way.

 This would be no problem. However I need zope to do this automatically
 so I don't have to change the dtml-var calls in the customer's code. So
 my thought is to alter the __call__ method of DTMLMethod.py which is
 kind of ugly in case I want to update Zope later on.


Like I said, Good luck!
Wouldn't it be easier to change the DTML source inside the customers zodb?


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
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] python: calling DTML-methods without quoting

2005-10-04 Thread Chris Withers

Chris wrote:

I hope this is not a FAQ, but I looked for some info to no avail.


And my answer to this FAQ, as always, is use ZPT.

If I call a DTML-Method from an other Method (e.g. dtml-var someDTML), 
 HTML entities are not converted.


This is calling and rendering whatever someDTML is...

However if I call it from python (e.g. dtml-var somePath.someDTML 
the entities are html_quoted.


This is likely inserting a python repr of whatever somePath.someDTML 
resolves too...


This changed with Zope 2.7.x (?). Before that DTMLMethods were not 
quoted when called from python.


Where are you calling one from python?

I know the easy workaround is to dtml-with to the namespace of the 
object and call it the zope-way.


Huh?

I have a customer with several large applications which run on an old 
Zope only for the described reason. The applications relay heavily on 
calling DTML-Methods to include pieces of HTML, JavaScript, etc. 
Changing the old code would be an enormous effort.


...but likely worth it in the long run ;-)

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
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 )