[Zope-dev] Passing parameters to __str__

Michel Pelletier michel@digicool.com
Mon, 15 Nov 1999 12:52:43 -0500


> -----Original Message-----
> From: Itamar Shtull-Trauring [mailto:itamars@ibm.net]
> Sent: Monday, November 15, 1999 11:42 AM
> To: zope-dev@zope.org
> Subject: [Zope-dev] Passing parameters to __str__
> 
> 
> I'm trying to have an object that returns different data 
> based on if it's
> called from <dtml-var> or on its own, so I defined a __str__ function.
> 
> I need to pass REQUEST to __str__, but apparently __str__ 
> doesn't get any
> parameters passed when it gets called.  How do I correct this?

You can acquire REQUEST:

def __str__(self):
  req = self.REQUEST

before using the __str__ of your object, stuff what your looking for in
REQUEST (it it's not allready in there).

-Michel