[Zope] Form to text

vivek singh vikx2 at yahoo.com
Wed Jan 21 18:15:20 EST 2004


Thanks Robert for the prompt response.
I have followed your directions. However when I view
the DTML doc, I do not get the text fields where I can
enter the values. Am I doing something wrong?

Thanks again.
Vivek

--- robert rottermann <robert at redcor.ch> wrote:
> vivek singh wrote:
> 
> >Hi all,
> >
> >I have a form where the users enter the entries as
> a
> >name value pair. I have to save this info as text
> to
> >be used later in a batch mode. I am new to Zope and
> >python and i am having trouble figuring out how
> this
> >can be done. I would highly appreciate if someone
> >could send me some pointers or some sample code. So
> >far i haven't been able to get anything useful from
> >google.
> >
> >Thanks in advance,
> >vikx
> >
> >__________________________________
> >Do you Yahoo!?
> >Yahoo! Hotjobs: Enter the "Signing Bonus"
> Sweepstakes
> >http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >
> >_______________________________________________
> >Zope maillist  -  Zope at zope.org
> >http://mail.zope.org/mailman/listinfo/zope
> >**   No cross posts or HTML encoding!  **
> >(Related lists - 
> >
> http://mail.zope.org/mailman/listinfo/zope-announce
> > http://mail.zope.org/mailman/listinfo/zope-dev )
> >
> >
> >  
> >
> 
> Here you have a form that collects data,
> and two scripts:
> -getAprovelist retrieves the stored data
> -setAprovelist writes the stored data
> And a page-template that displays and sets the data
> 
> just put all the thre in a folder (2 scripts, one
> page template) and 
> name them correctly
> As datastore you need a DTML Method at the same
> place named "aprovelist"
> 
> HTH
> Robert
> 
>
-----------------------------------------------------------------
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
> Transitional//EN"
> 
>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> 
> <html xmlns="http://www.w3.org/1999/xhtml"
> xml:lang="en-US" lang="en-US"
>      
> metal:use-macro="here/main_template/macros/master">
> <body>
> 
> <div metal:fill-slot="main">
> 
> <h1 i18n:translate="">Please adapt the state of the
> accounts</h1>
> 
> 
> <form class="group"
>       action="setAprovelist" 
>       method="post">
> 
> 
>   <span class="legend" i18n:translate="">Known
> users</span>
>   <table style="width:100%;
> margin-left:30;margin-rigth:30">
> 		<tr>
> 			<th align="left" class="field">Member</th>
> 			<th align="left" class="field">Email</th>
> 			<th align="left" class="field">Approval
> Manager</th>
> 			<th align="left" class="field">Approved?</th>
> 		</tr>
> 
> 		<tr class="row" tal:repeat="user
> here/getAprovelist">
> 			<td>
> 				<input type="hidden"
> name="users.username:records" tal:attributes="value
> python:user[0]"/>
> 				<span tal:omit-tag=""
> tal:content="python:user[0]" />
> 				<br />
> 				<hr />
> 			</td>
> 			<td>
> 				<input type="hidden" name="users.email:records"
> tal:attributes="value python:user[1]"/>
> 				<span tal:omit-tag=""
> tal:content="python:user[1]" />
> 				<br />
> 				<hr />
> 			</td>
> 			<td>
> 				<input type="hidden"
> name="users.accessmanager:records"
> tal:attributes="value python:user[2]"/>
> 				<span tal:omit-tag=""
> tal:content="python:user[2]" />
> 				<br />
> 				<hr />
> 
> 			</td>
> 			<td valign="top">
> 				<input type="checkbox"
> name="users.aproved:records"
> 					 tal:attributes="checked
> python:test(user[3].strip()=='1', 1,0)" 
> 					 value="1" />
> 			</td>
>   	</tr>
> 	</table>
>   <input type="submit" value="save" />
> </form>
> 
> </div>
> 		
> </body>
> 
> 
> </html>
> 
> 
> ----------------------------------------
> aprovelist is a DTML--Method
> -----------------------------------------
> -----------------------------------------
> script getAprovelist
> -----------------------------------------
> 
> ## Script (Python) "getAprovelist"
> ##bind container=container
> ##bind context=context
> ##bind namespace=
> ##bind script=script
> ##bind subpath=traverse_subpath
> ##parameters=username='', status=None
> ##title=(hat kein proxy)
> ##
> aprove=container.aprovelist()
> aprove = aprove.replace('\n','\r')
> aprovelines = string.split(aprove, '\r')
> aprovelist = []
> aprovedic = {}
> 
> for person in aprovelines:
>     if len(person.strip()):
>         try:
>             name,email,supervisor,OK =
> person.split(',')[:4]
>            
> aprovelist.append((name,email,supervisor,OK))
>             aprovedic[name] = OK
>         except:
>             continue
> 
> # do we have to check a single person
> if len(username) and aprovedic.has_key(username):
>     return aprovedic[username]
> elif len(username):
>     return 0
> 
> return aprovelist
> 
> 
> -------------------------------------------
> script  setAprovelist
> -----------------------------------------
> 
> ## Script (Python) "setAprovelist"
> ##bind container=container
> ##bind context=context
> ##bind namespace=
> ##bind script=script
> ##bind subpath=traverse_subpath
> ##parameters=users
> ##title=(hat proxy)
> ##
> aprove = getattr(context, 'aprovelist')
> result = []
> for x in users:
> 	if x.has_key('aproved'):
> 		result.append("%s,%s,%s,%s" %
>
(x['username'].strip(),x['email'].strip(),x['accessmanager'].strip(),x['aproved'].strip()))
> 	else:
> 		result.append("%s,%s,%s,%s" %
>
(x['username'].strip(),x['email'].strip(),x['accessmanager'].strip(),'0'))
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus



More information about the Zope mailing list