[Zope] Sending additional parameters to HTMLFile()

Casey Duncan c.duncan@nlada.org
Thu, 3 Jan 2002 17:29:42 -0500


On Thursday 03 January 2002 07:09 am, Max M allegedly wrote:
> In a product I am writing I have defined some lists of options::
>
>     formatTypes = ['format1', 'format2', 'format3']
>
>     userTypes = ['type1', 'type2', 'type3']
>
> In my manage_addProductForm I need to access these lists. But it seems that
> it cannot be done as manage_addProductForm is called in the context of the
> objectmanager it is being added to. And here these attributes naturally
> does not exist yet.
>
> So I just wondered if there is any way to put these lists into the
> namespace of the objectmanager, or in some way pass them onto the HTMLfile
> object.
>
> I have tried to add them like::
>
> manage_addProductForm = HTMLFile('manage_addProductForm', globals(),
>     {'formatTypes ':['format1', 'format2', 'format3'],
>      'userTypes':['type1', 'type2', 'type3']})
>
> But it doesn't work as I get an error saying that I am passing on to many
> parameters.
>
> regards Max M

1. Use DTMLFile instead of HTMLFile.
2. Make manage_addProductForm a regular method that calls the DTMLFile 
object. Like so:

formatTypes = ['format1', 'format2', 'format3']
userTypes = ['type1', 'type2', 'type3']

addProductDTML = DTMLFile('manage_addProductForm')

def manage_addProductForm(self, REQUEST=None):
    return addProductDTML(self, REQUEST, 
                                      formatTypes=formatTypes,                
                                      userTypes=userTypes)

hth,
/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/