Re: [Zope-dev] Calling DTML methods from Python

2000-05-30 Thread Rik Hoekstra



Andrew Wilcox wrote:
 
 OK, I'll set up a DTML Quick Reference on the ZDP site right now! It's link
 is
 
 http://zdp.zope.org/portals/beginners/DQR
 
 We should be able to get this in place. Contributions sought!
 
 Do you want me to include my text?  Where would it go?

Yes. Hm, this is already rather specific. I'll paste it into a section
(Topic) called Calling DTML. We may need to revise the topics
afterwards, but that doesn't really matter now.

Note that you can make your own topics (at least I think you can). Last
night I couldn't finish it, but I thought the idea would be there as is.
I'll try and work on it a bit today.

thanks

Rik

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Calling DTML methods from Python

2000-05-29 Thread Kevin Dangoor

I believe this is in the Collector... My guess is that no one has yet
figured out a good way to make the client and namespace be passed in
automatically. This may not be desirable anyhow, because there may be times
when you want to change the client... I've actually done this once or twice.

I guess there could be something like dtml-var fooMethod params="x,y,z".
This is another one of those things that trips up newbies almost
universally, so a good solution here could really help...

Kevin

- Original Message -
From: "Chris Withers" [EMAIL PROTECTED]
To: "Zope-Dev Mailing List" [EMAIL PROTECTED]
Sent: Monday, May 29, 2000 12:32 PM
Subject: Re: [Zope-dev] Calling DTML methods from Python


 On more of a ranting rather than a genuine question note,

 Why does this _horrible_ syntax for calling methods with parameters
 still have to be used?

 dtml-[whatever] "someFunc(_.None,_,[parameters])"

 *blech*

 Chris



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Calling DTML methods from Python

2000-05-29 Thread Chris Withers

Kevin Dangoor wrote:
 I believe this is in the Collector... My guess is that no one has yet
 figured out a good way to make the client and namespace be passed in
 automatically. This may not be desirable anyhow, because there may be times
 when you want to change the client... I've actually done this once or twice.

Is it just me or is there a lot of confusion between the terms
namespace, self, client, and the REQUEST object (which, unlike it's name
implies, seems to contain a lot more than stuff relating to the HTTP
request, like the RESPONSE object, for example ;-)

Perhaps this could be shaken down and then, a first for the Zope
community I believe ;-), _documented_ somewhere!!!

cheers,

Chris

PS: what is the client anyway? what exactly is in _? why is the RESPONSE
object an attribute of the REQUEST object?!

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Calling DTML methods from Python

2000-05-29 Thread Andrew Wilcox

Is it just me or is there a lot of confusion between the terms
namespace, self, client, and the REQUEST object (which, unlike it's name
implies, seems to contain a lot more than stuff relating to the HTTP
request, like the RESPONSE object, for example ;-)

Perhaps this could be shaken down and then, a first for the Zope
community I believe ;-), _documented_ somewhere!!!

Well, as far as I've been able to figure out.  But everybody correct me
where I get it wrong:

When a DTML Document is called from the web, it gets itself as the client
argument and a namespace as the second argument.  Note that it gets itself
twice: first as the standard Python object oriented "self" argument and
then as the client argument.

I seem to recall there's some magic in there where the the object is
wrapped in an acquisition class so that it can do a self.REQUEST, but I'm
not sure.

Any DTML methods called by the first object get None passed in as the
client argument.  Importantly, DTML methods do not lookup variables in
themselves (i.e. from the Python "self"), but only from the namespace.  The
original object has been added to the namespace at this point so these
called methods are able to access things.

An example would be if you had a DTML method called "doit" sitting in a
folder next to "standard_html_header".  Because doit acquires from its
container, you could say "doit.standard_html_header" from Python because
standard_html_header is a property of the containing folder.  But using
"dtml-var standard_html_header" from inside doit only works if
standard_html_header is available in the namespace.

External methods add more fun :-).  As noted in the documentation, the
enclosing folder will be passed in automatically if you call the first
argument "self" (and you pass in yourself one fewer argument than the
function calls for).  Note this is NOT the standard python object oriented
"self" argument, which would be the external method sitting in the ZODB if
anything, but the enclosing folder.  You do have to call it "self" or you
don't get anything.  The "self" argument is able to acquire REQUEST so you
can say "self.REQUEST", but you don't get a namespace automatically.




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Calling DTML methods from Python

2000-05-29 Thread Rik Hoekstra

Is it just me or is there a lot of confusion between the terms
namespace, self, client, and the REQUEST object (which, unlike it's name
implies, seems to contain a lot more than stuff relating to the HTTP
request, like the RESPONSE object, for example ;-)

Perhaps this could be shaken down and then, a first for the Zope
community I believe ;-), _documented_ somewhere!!!


OK, I'll set up a DTML Quick Reference on the ZDP site right now! It's link
is

http://zdp.zope.org/portals/beginners/DQR

We should be able to get this in place. Contributions sought!


Rik


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )