[ZPT] writing data to zope objects

Michael A Rowley os2mac at earthlink.net
Mon May 31 13:12:41 EDT 2004


hello all

I am still battling this problem...  I have an application that records 
a lot of data from user input.  Much of this data is repetative, but 
stored independantly.  Specifically, vital signs on patients.  There 
are 5 vital signs... pulse, respirations, blood pressure (stored as 
systolic and diastolic)height and weight.  Now, generally all of these 
are collected everytime a patient comes in, but occasionally, they will 
have to be repeated on the same visit, for example, a repeat 
temperature, so they are all stored in separate objects.

The problem I have is trying to collect the data on the same page.  
Having to select "Save" after each data point entry is not workable. It 
just takes to long.  It means having a minimum of 6 mouse clicks just 
to store the vital signs.  So, I am trying to write a page template 
that will allow the collection of all the data on one page, then update 
the individual objects on submission...

I have figured out that the *_edit.cpt objects handle the data 
collection, and apparently the submission.  The resulting html page has 
the form being submitted back to the *_edit zpt... for example 
base_edit as an attribute of the object in question.  I think that the 
edit macros are using the widget.populate functions to populate the 
objects, but I can't find out how this function actually saves the 
data....

The code looks like :

tal:define =" visState....
		   edit_accessor python:field.getEditAccessor(here);
                       value python:widget.populate and edit_accessor 
and edit_accessor() or '';
		   value python:test(widget.postback and request.has_key(fileName), 
request.get(fieldName, value), value);
		   error_id....

Now, I am assuming the the postback function gets the data from html 
post function, and the populate function, writes the data to the 
object....  but I can't locate these two functions to see how the work, 
and I still haven't solved this problem....

I think that I should be able to use these functions to write the data 
to the relative objects... I thought that the edit_macros would do this 
automatically, as they are passed the appropriate objects, they get the 
accessor data, so I thought that they would write the field data to the 
appropriate objects.  But, _nothing_ happens.  here is the code I am 
using...

	<table cellpadding="0" cellspacing="0" border="1" width="100%">
	<tr tal:define = "global fileDict 
python:here.parentFolderObjsByType()">
	<td>
	    <span tal:repeat="object python:fileDict['Height']">
	    <b metal:use-macro="python:object.widget(object, 'Height', 
mode='edit')">content</b><br/>
	    </span>
	</td>
         </tr>
         </table>

This gives me the relevant object data on the page in edit mode, but 
when I save it, it is not saved.... parentFoldersObjsByType is an 
external method that I wrote, here it is....

def parentFolderObjsByType(self):

    """
    Creates a dicionary of lists of objects in the parent folder by 
meta_type.  This should be the name
    of the object as it appears in the 'allowed_content_types' in the 
archetypes definition, or the registerType name.

    Returns the dictionary of lists.
    """
    filelist = self.getFolderContents()
    fileDict = {}
    for object in filelist:

       typeName = (object.meta_type)

       fileDict.setdefault(typeName,[]).append(object)

    return fileDict



Can anyone help me with this?  Or give me a direction?


any help would be appreciated.

Michael




More information about the ZPT mailing list