[Zope] Renderable Base ZClass

Kevin Howe ap619@chebucto.ns.ca
Tue, 2 Nov 1999 16:34:53 -0400


This solves the REQUEST problem,  but an error then occurs with the DTML
<!--#in object--> tag, which is the next tag down in the DTML method.

How can I enable DTML tag parsing, for "in", "with", and other tags tags?
Is it just a matter of passing the right arguments?

The script and the error traceback are included below.

Cheers
Kevin


SCRIPT
--------------------------------------
import Acquisition

class Renderable:
def __str__(self):
   theRequest=self.REQUEST
          if theRequest:
           theObject = getattr(self, 'render')
           return theObject(theRequest)
          else:
           return "no request"

TRACEBACK
--------------------------------------
Error Type: KeyError

Traceback (innermost last):
  File C:\Programs\Internet\kevin\kevin\lib\python\ZPublisher\Publish.py,
line 214, in publish_module
  File C:\Programs\Internet\kevin\kevin\lib\python\ZPublisher\Publish.py,
line 179, in publish
  File C:\Programs\Internet\kevin\kevin\lib\python\Zope\__init__.py, line
201, in zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File C:\Programs\Internet\kevin\kevin\lib\python\ZPublisher\Publish.py,
line 165, in publish
  File C:\Programs\Internet\kevin\kevin\lib\python\ZPublisher\mapply.py,
line 160, in mapply
    (Object: test)
  File C:\Programs\Internet\kevin\kevin\lib\python\ZPublisher\Publish.py,
line 102, in call_object
    (Object: test)
  File C:\Programs\Internet\kevin\kevin\lib\python\OFS\DTMLMethod.py, line
145, in __call__
    (Object: test)
  File
C:\Programs\Internet\kevin\kevin\lib\python\DocumentTemplate\DT_String.py,
line 502, in __call__
    (Object: test)
  File
C:\Programs\Internet\kevin\kevin\lib\python\Products\Renderable\Renderable.p
y, line 16, in __str__
    (Object: Renderable)
  File C:\Programs\Internet\kevin\kevin\lib\python\OFS\DTMLMethod.py, line
145, in __call__
    (Object: render)
  File
C:\Programs\Internet\kevin\kevin\lib\python\DocumentTemplate\DT_String.py,
line 502, in __call__
    (Object: render)
  File
C:\Programs\Internet\kevin\kevin\lib\python\DocumentTemplate\DT_In.py, line
630, in renderwob
    (Object: activeURLs)
KeyError: (see above)

-----Original Message-----
From: Brian Lloyd <Brian@digicool.com>
To: 'alex@mop.no' <alex@mop.no>; 'ap619@chebucto.ns.ca'
<ap619@chebucto.ns.ca>
Cc: 'zope@zope.org' <zope@zope.org>
Date: November 2, 1999 11:25 AM
Subject: RE: [Zope] Renderable Base ZClass


>
>> >If there is no way to pass REQUEST to __str__(), I believe this is a
>> >minor shortcoming and should be remedied in the Zope DTML
>> core. Such as
>> >by testing for the presence of an alternative method called
>> >__render__(), for example, and using that instead.
>
>While it is not passed explicitly, remember that REQUEST
>can almost always be accessed through acquisition:
>
>def __str__(self):
>  theRequest=self.REQUEST
>  ...
>  return theResult
>
>
>> Below is a forward of a discussion about the Renderable Base
>> ZClass Product
>> and how it could be integrated into the ZOPE Core.
>>
>> I'd like to see it incorporated into ZClasses - Under the
>> "Basic" tab of the
>> ZClass, having a selectlist labelled "Render Method" from
>> which you'd choose
>> the DTML method to be be displayed when the object is called
>> as <!--#var
>> myObject-->.
>>
>> Can anyone offer suggestions or comments as to a better way
>> to accomplish
>> this?
>
>After reading this, I'm not sure I understand what the core
>problem is - is it that the REQUEST was not available as an
>explicit argument, or am I missing something deeper here?
>
>
>
>Brian Lloyd        brian@digicool.com
>Software Engineer  540.371.6909
>Digital Creations  http://www.digicool.com
>
>
>