Okay,

After some more poking around, I've simplified the problem. I have a product I created with a __call__ method:

  def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):
      """
      Call the selected template in the context of myself.
      """
      print "REQUEST = "
      print str(REQUEST)

When this is called from DTML like this: <dtml-var object> REQUEST is {} when this is called directly REQUEST is the real request information, when it is called from python "object(context, REQUEST)" this works as well.

Any idea why it does not work as desired when calling like <dtml-var object> I can create a python script or another dtml method and call those from a dtml method without any arguments and the REQUEST is available. These other products seem to include the func_code stuff to make the documents methodish? Could that have anything to do with my problem?

Thanks,
-Brian

Brian Brinegar wrote:

Hi,

I'm using some of Casey Duncans code that I got off of zopelabs.com in a product that I created. The code allows you to call any object generically. The code is listed below this message. The problem I have is if my object is called from a DTML Method like <dtml-var object> the "args" attribute of the REQUEST object disappears and I get an attribute error. I can call it like this <dtmi-var "object(this(), REQUEST)"> and it will work. Anyway, somewhere the REQUEST object is changing. Any ideas?

Thanks,
-Brian

import Acquisition
from ZPublisher.mapply import mapply
from ZPublisher.Publish import call_object, missing_name, dont_publish_class


class MyClass(Acquisition.Implicit,...):
  ...
  def __init__(self, some_object_id):
      self.data_source_id = some_object_id

  def index_html(self, REQUEST, RESPONSE):
       object = getattr(self.aq_parent, self.data_source_id)
       result = mapply(object, REQUEST.args, REQUEST,
                       call_object,1,
                       missing_name,
                       dont_publish_class,
                       REQUEST, bind=1)
       ...process the result...
       return result



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




Brian Brinegar wrote:

Hi,

I'm using some of Casey Duncans code that I got off of zopelabs.com in a product that I created. The code allows you to call any object generically. The code is listed below this message. The problem I have is if my object is called from a DTML Method like <dtml-var object> the "args" attribute of the REQUEST object disappears and I get an attribute error. I can call it like this <dtmi-var "object(this(), REQUEST)"> and it will work. Anyway, somewhere the REQUEST object is changing. Any ideas?

Thanks,
-Brian

import Acquisition
from ZPublisher.mapply import mapply
from ZPublisher.Publish import call_object, missing_name, dont_publish_class


class MyClass(Acquisition.Implicit,...):
  ...
  def __init__(self, some_object_id):
      self.data_source_id = some_object_id

  def index_html(self, REQUEST, RESPONSE):
       object = getattr(self.aq_parent, self.data_source_id)
       result = mapply(object, REQUEST.args, REQUEST,
                       call_object,1,
                       missing_name,
                       dont_publish_class,
                       REQUEST, bind=1)
       ...process the result...
       return result



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




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

Reply via email to