[Zope-DB] updating fields in a zsql method programmatically
onsombal
onsombal at yahoo.com
Mon Aug 27 19:11:38 EDT 2007
So, my script now works!! Thanks to everyone for your input. It is greatly
appreciated. Below is a quick summary of what I did and a relevant excerpt
of the working script.
1) I never was able to get passing the arguments via the context.Statement
to work. I'm sure it's something I've done wrong.
2) I successfully updated the context.REQUEST.form dictionary key:value pair
with my computed value. The computed value was to replace the blank
(hidden) 'fdbkurl' pfg form field with the url of a form object that was
copied from a standard-template to another folder, and then renamed. After
renaming, I re-indexed the object, and then captured its absolute url --
which I then used to update the dictionary key:value.
Code follows:
#copy, paste, rename std-survey to Folder
from Products.CMFCore.utils import getToolByName
urltool = getToolByName(context, "portal_url")
portal = urltool.getPortalObject()
mydoc_folder = getToolByName(context, "my-documents")
crm_folder = getToolByName(context, "crm")
survey_folder = getToolByName(context, "std-forms")
listing_folder = getattr(mydoc_folder, "listings")
#manage_copyObjects(self, ids=None, REQUEST=None, RESPONSE=None)
cb_copy_data = survey_folder.manage_copyObjects(["std-survey"])
dest = getattr(listing_folder, tls_id)
#manage_pasteObjects(self, cb_copy_data=None, REQUEST=None)
#Paste previously copied objects into the current object.
#If calling manage_pasteObjects from python code,
#pass the result of a previous call to manage_cutObjects or
manage_copyObjects as the first argument.
dest.manage_pasteObjects(cb_copy_data)
#manage_renameObjects(self, ids=[], new_ids=[], REQUEST=None)
tls_folder = getattr(listing_folder, tls_id)
survey_id = "survey" + form.get('tls')
survey_title = "Survey" + form.get('tls')
survey_obj = getattr(tls_folder, "std-survey")
tls_folder.manage_renameObjects(ids=["std-survey"], new_ids=[survey_id])
survey_obj.setTitle(survey_title)
survey_obj.reindexObject()
fbkurl = survey_obj.absolute_url()
formresult['fbkurl'] = fbkurl
#create record in usdb listing table
context.listingsCreateRow()
And it works!
Charlie Clark-2 wrote:
>
> Am 27.08.2007, 21:59 Uhr, schrieb onsombal <onsombal at yahoo.com>:
>
>> I'm assuming the form results are stored as an object represented as a
>> dictionary. If so, then there must be a way for my python script to
>> change
>> the key | value pair for field1 before I call my Z SQL Method. Is this
>> reasonable, or am I just going down a rat-hole?
>
> All form values are in the context.REQUEST.form dictionary which can
> overwrite to your heart's content.
>
> Charlie
> --
> Charlie Clark
> eGenix.com
>
> Professional Python Services directly from the Source
>>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
> ________________________________________________________________________
>
> :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
>
> eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
> Registered at Amtsgericht Duesseldorf: HRB 46611
> _______________________________________________
> Zope-DB mailing list
> Zope-DB at zope.org
> http://mail.zope.org/mailman/listinfo/zope-db
>
>
--
View this message in context: http://www.nabble.com/updating-fields-in-a-zsql-method-programmatically-tf4335404.html#a12359442
Sent from the Zope - DB mailing list archive at Nabble.com.
More information about the Zope-DB
mailing list