Re: [Zope] How to render a HTMLFile in a method in a product

2000-11-06 Thread Chris Withers

Max Møller Rasmussen wrote:

> def __call__(self,client=None,mapping={},**kw):
> 
> This method accepts an object in which it will look up values to insert in
> the dtml file, and a mapping object (dictionary) that also will look up
> values to insert.
> 
> So i guess that is what (None,md) does.
> 
> But I dont understand what "ignored" does in  my method, as it is unused,
> unless it is used by md

Nope, ignored is the client, which you don't need to worry about.

> >def test(self,ignored,md):
> 
> Furthermore I dont understand what md is. Some kind of mapping object
> naturally, but where does it come from?

pDocumentTemplate.py has one implementation of it.

it's a stack of dictionaries, basically... When you do md['key'], it
looks for key in the top dictionary, then in the next one down, then in
the one below that, etc, and only throws a key error if one can't be
found at all...

> Also what is testisDocTemp supposed to do?

This is a bit of ExtensionClass wierdness. Think of it has "give the
test object the 'isDocTemp' attribute".

> If I grep the source a "isDocTemp" shows up but is isn't easy to see what
> this does either.

If some arcane bit of Zope's calling machinery finds this (probably in
BaseRequest.py) it sends different parameters to __call__.

HTH,

Chris

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




Re: [Zope] How to render a HTMLFile in a method in a product

2000-11-06 Thread Chris Withers

Max Møller Rasmussen wrote:
> 
> From: Chris Withers [mailto:[EMAIL PROTECTED]]
> 
> Thanks for the reply
> 
> >testisDocTemp = 1
> 
> >def test(self,ignored,md):
> >" A simple test method "
> >return HTMLFile('skins/' + self.skin, globals())(None,md)
> 
> Is this documented anywhere? 

Not that I know of ;-)

> I have a little trouble using code I don't
> understand. Pretty Please.

I think there are only about two people on the face of the planet who
understand this completely. I'm not one of them :-(

cheers,

Chris

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




RE: [Zope] How to render a HTMLFile in a method in a product

2000-10-27 Thread Max Møller Rasmussen

>From: Chris Withers [mailto:[EMAIL PROTECTED]]

I got this answer to my question about how to render a dtml document from a
method.

>testisDocTemp = 1
>def test(self,ignored,md):
>" A simple test method "
>return HTMLFile('skins/' + self.skin, globals())(None,md)

And I have been busy trying to read the source code to understand the
advise:

As far as I understand the story goes a little like this:

HTMLFile returns an object (through inheritance) "String" in file
"DT_String.py" that has "__call__()" implemented, which means that the class
can be called as a function... Hmm ... I had actually not seen this method
used in Python before.

def __call__(self,client=None,mapping={},**kw):

This method accepts an object in which it will look up values to insert in
the dtml file, and a mapping object (dictionary) that also will look up
values to insert.

So i guess that is what (None,md) does.

But I dont understand what "ignored" does in  my method, as it is unused,
unless it is used by md

>def test(self,ignored,md):

Furthermore I dont understand what md is. Some kind of mapping object
naturally, but where does it come from?

Also what is testisDocTemp supposed to do?

If I grep the source a "isDocTemp" shows up but is isn't easy to see what
this does either.

Regards Max M

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




RE: [Zope] How to render a HTMLFile in a method in a product

2000-10-26 Thread Max Møller Rasmussen

From: Chris Withers [mailto:[EMAIL PROTECTED]]

Thanks for the reply

>testisDocTemp = 1

>def test(self,ignored,md):
>" A simple test method "
>return HTMLFile('skins/' + self.skin, globals())(None,md)

Is this documented anywhere? I have a little trouble using code I don't
understand. Pretty Please.

Regards

Max M

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




Re: [Zope] How to render a HTMLFile in a method in a product

2000-10-26 Thread Chris Withers



Max Møller Rasmussen wrote:
> def test(self):
> "A simpe test method"
> return  HTMLFile('skins/' + self.skin, globals())

This is the closest. try the following:


testisDocTemp = 1

def test(self,ignored,md):
" A simple test method "
return HTMLFile('skins/' + self.skin, globals())(None,md)

cheers,

Chris

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




[Zope] How to render a HTMLFile in a method in a product

2000-10-26 Thread Max Møller Rasmussen

I would have thought that the two examples below where equivalent but only
the top one works like expected. (It renders the page.)

The second one just shows the source of the vanilla dtml page.

--
test = HTMLFile('vanilla', globals())

--
def test(self):
"A simpe test method"
return  HTMLFile('vanilla', globals())
--

How do I execute the dtml file in a method. I have searched the
documentation, but it is sketchy to say the least.

I cannot use the first approach as I need to define the filename on the fly
in my method.

def test(self):
"A simpe test method"
return  HTMLFile('skins/' + self.skin, globals())

self.skin is only available in my object, so naturally if I try to say:

test = HTMLFile('skins/' + self.skin, globals())

I get an error.

Regards

Max M

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