Passing parameters from python to dtml objects..
hi all, I am currently working on a python script that is called from a dtml method. It performs some logic and then calls another dtml method. I am passing 2 parameters into the python script, "hidden_photo" and "photo_name"..my python script looks like this... if photo_name == ' ': if hidden_photo == ' ': return context.scReport(context) elif hidden_photo == 'None': return context.scReport(context) else: return context.Thumbnails.deletePhoto(context) return context.scReport(context) elif photo_name =='None': return context.scReport(context) else: return context.Thumbnails.photoAction(context) return context.scReport(context) The methods photoAction and deletePhoto need to be passed the parameters "hidden_photo" and "photo_name" - however it dosn't seem to be getting them properly- this is the error message Error Type: NameError Error Value: global name 'photo_name' is not defined Can anyone tell me how properly to pass parameters from python to dtml objects? Thanks in advance, Shane
Hi, Try to use the REQUEST object. context.REQUEST.set('something', somevalue) return context.someDTMLObject(REQUEST = context.REQUEST) HTH --Gilles ----- Original Message ----- From: "Shane O'Sullivan" <shane.osullivan@engitech.ie> To: <zope@zope.org> Sent: Wednesday, October 31, 2001 3:26 PM Subject: [Zope] Passing parameters from python to dtml objects.. hi all, I am currently working on a python script that is called from a dtml method. It performs some logic and then calls another dtml method. I am passing 2 parameters into the python script, "hidden_photo" and "photo_name"..my python script looks like this... if photo_name == ' ': if hidden_photo == ' ': return context.scReport(context) elif hidden_photo == 'None': return context.scReport(context) else: return context.Thumbnails.deletePhoto(context) return context.scReport(context) elif photo_name =='None': return context.scReport(context) else: return context.Thumbnails.photoAction(context) return context.scReport(context) The methods photoAction and deletePhoto need to be passed the parameters "hidden_photo" and "photo_name" - however it dosn't seem to be getting them properly- this is the error message Error Type: NameError Error Value: global name 'photo_name' is not defined Can anyone tell me how properly to pass parameters from python to dtml objects? Thanks in advance, Shane
Try this: ...deletePhoto(none, _, hidden_photo=hidden_photo, photo_name = photo_name) hidden_photo and photo_name should now be visible inside your dtml method given that _ is bound to the Namespace on the bindings tab. Alternatively, you can use the REQUEST.set as suggested below. ------------------------------ Chris Kratz chris.kratz@vistashare.com ----- Original Message ----- From: "Gilles Lenfant" <glenfant@bigfoot.com> To: <zope@zope.org> Sent: Wednesday, October 31, 2001 10:18 AM Subject: Re: [Zope] Passing parameters from python to dtml objects..
Hi,
Try to use the REQUEST object.
context.REQUEST.set('something', somevalue) return context.someDTMLObject(REQUEST = context.REQUEST)
HTH
--Gilles
----- Original Message ----- From: "Shane O'Sullivan" <shane.osullivan@engitech.ie> To: <zope@zope.org> Sent: Wednesday, October 31, 2001 3:26 PM Subject: [Zope] Passing parameters from python to dtml objects..
hi all, I am currently working on a python script that is called from a dtml method. It performs some logic and then calls another dtml method. I am passing 2 parameters into the python script, "hidden_photo" and "photo_name"..my python script looks like this...
if photo_name == ' ': if hidden_photo == ' ': return context.scReport(context) elif hidden_photo == 'None': return context.scReport(context) else: return context.Thumbnails.deletePhoto(context) return context.scReport(context) elif photo_name =='None': return context.scReport(context) else: return context.Thumbnails.photoAction(context) return context.scReport(context)
The methods photoAction and deletePhoto need to be passed the parameters "hidden_photo" and "photo_name" - however it dosn't seem to be getting them properly- this is the error message Error Type: NameError Error Value: global name 'photo_name' is not defined
Can anyone tell me how properly to pass parameters from python to dtml objects?
Thanks in advance, Shane
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Wed, 2001-10-31 at 09:26, Shane O'Sullivan wrote:
hi all, I am currently working on a python script that is called from a dtml method. It performs some logic and then calls another dtml method. I am passing 2 parameters into the python script, "hidden_photo" and "photo_name"..my python script looks like this...
if photo_name == ' ': if hidden_photo == ' ': return context.scReport(context) elif hidden_photo == 'None': return context.scReport(context) else: return context.Thumbnails.deletePhoto(context) return context.scReport(context) elif photo_name =='None': return context.scReport(context) else: return context.Thumbnails.photoAction(context) return context.scReport(context)
The methods photoAction and deletePhoto need to be passed the parameters "hidden_photo" and "photo_name" - however it dosn't seem to be getting them properly- this is the error message Error Type: NameError Error Value: global name 'photo_name' is not defined
Can anyone tell me how properly to pass parameters from python to dtml objects?
Thanks in advance, Shane
first, get acquainted with www.zopelabs.com which has all sorts of user submitted recipes. second (from http://www.zopelabs.com/cookbook/992031125 ) the proper way to call dtml from python scripts is: dtmlMethod(context, context.REQUEST) # or if _ is bound to the (Script) Python in the bindings tab dtmlMethod(context, _) third if you pass keyword arguments to a dtml method they will be available for use in the dtml method. so you should call your dtml with context..ThumbNails.deletePhoto(context, context.REQUEST, hidden_photo=hidden_photo, photo_name=photo_name) HTH -- Tom Jenkins Development InfoStructure http://www.devis.com
Excellent...It has started working - thank you all for your help Shane ----- Original Message ----- From: Tom Jenkins <tjenkins@devis.com> To: Shane O'Sullivan <shane.osullivan@engitech.ie> Cc: <zope@zope.org> Sent: Wednesday, October 31, 2001 4:05 PM Subject: Re: [Zope] Passing parameters from python to dtml objects..
On Wed, 2001-10-31 at 09:26, Shane O'Sullivan wrote:
hi all, I am currently working on a python script that is called from a dtml method. It performs some logic and then calls another dtml method. I am passing 2 parameters into the python script, "hidden_photo" and "photo_name"..my python script looks like this...
if photo_name == ' ': if hidden_photo == ' ': return context.scReport(context) elif hidden_photo == 'None': return context.scReport(context) else: return context.Thumbnails.deletePhoto(context) return context.scReport(context) elif photo_name =='None': return context.scReport(context) else: return context.Thumbnails.photoAction(context) return context.scReport(context)
The methods photoAction and deletePhoto need to be passed the parameters "hidden_photo" and "photo_name" - however it dosn't seem to be getting them properly- this is the error message Error Type: NameError Error Value: global name 'photo_name' is not defined
Can anyone tell me how properly to pass parameters from python to dtml objects?
Thanks in advance, Shane
first, get acquainted with www.zopelabs.com which has all sorts of user submitted recipes.
second (from http://www.zopelabs.com/cookbook/992031125 ) the proper way to call dtml from python scripts is:
dtmlMethod(context, context.REQUEST)
# or if _ is bound to the (Script) Python in the bindings tab
dtmlMethod(context, _)
third if you pass keyword arguments to a dtml method they will be available for use in the dtml method. so you should call your dtml with
context..ThumbNails.deletePhoto(context, context.REQUEST, hidden_photo=hidden_photo, photo_name=photo_name)
HTH
--
Tom Jenkins Development InfoStructure http://www.devis.com
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
Chris Kratz -
Gilles Lenfant -
Shane O'Sullivan -
Tom Jenkins