[Zope] Re: Now I'm confused....
Johan Carlsson
johanc at virtutech.com
Mon Aug 30 05:39:15 EDT 2004
Josef Albert Meile wrote:
> Hi Bill,
>
> --- In zope at yahoogroups.com, Bill Hewitt <wphewitt at c...> wrote:
>
>> I have finally given up on the complexity of ZClasses.... So, nowI am
>> porting my ZClasses to Python Classes.. Here is the rub:
>> How do I get the Python Class to recognize DTML Methods
>
You don't. When you write Python Products you use DTMLFile
which isn't really the same thing. But they act pretty much the same
so you don't need to worry about that :-)
>> I have a DTML method called "getDate" and I *assume* that I call it from
>> inside the Python class with something like:
>> getDate = HTMLFile('dtml/getDate', globals())
>
> You are using the wrong method, you have to use:
Yes. DTML Files being "DTML methodish" also have the call
signature method(client, REQUEST).
Calling DTMLFile from the the Python code I usually send
self, REQUEST=REQUEST to it, like this:
class ProductClass(bla bla, inherit stuff):
security = ClassSecurityInfo()
security.declareProtected('View', 'manage_me')
manage_me = DTMLFile('dtml/manage_me', globals())
security.declareProtected('View', 'call_me')
def call_me(self, REQUEST=None):
"""You need a docstring to be web callable"""
return self.manage_me(self,REQUEST=REQUEST)
>>
>> but when I try to use this, "'getDate' is not defined" is what is
>> returned from Zope....
>
Have you setup security?
Are you accessing the getDate directly or do you call it?
>> So, how does one include DTML Methods, PythonScripts, etc.... as methods
>> in Python Classes?
>
> If you are going to use python classes, then you had better define
> your PythonScripts inside your class.
>
> Finally, two advices:
> 1) try to use ZPT instead of DTML. The first one is better since
> content and logic separation is clearer.
Actually it separates logic from markup. You still can write sludgy
logic in a ZPT if you like to as you
could not write logic in DTML. A template file will always have logic in
it if it's not part of an
transformational template system such as XSLT.
But that of course is not a very import piece of information, TAL is the
future proof way in the Zope community
all though I prefer DTML my self because I find my self writing far
more readable stuff in DTML that in TAL.
More information about the Zope
mailing list