[Zope] leave application in zpt + formulator
nagendra prasad
t_nagendraprasad@yahoo.co.in
Fri, 20 Jun 2003 12:19:41 +0100 (BST)
--0-1438040465-1056107981=:32782
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Content-Id:
Content-Disposition: inline
hi
i had downloaded leave.zexp from the following url
http://www.openflow.it/EN/Download/index_html
I have installded open flow 1.1.0
i have plone,zope on ,my linux box.
Now i tried to rewrite the application using zpt +
formulator(originally written in dtml).
I have written the following zpt files
1)leave_startform_zpt
2)leave_start_zpt
& a macro leaveform_macro for leave_startform_zpt
file.
Now my program goes like this
leave_startform_zpt --> macros --> leave_start_zpt -->
gotoOF (this is a python file),
Plz see the files in the attachemnt. These are the
files i have added. the other files remain same. no
change
I get the following error like
Error Type
NameError
Error Value
global name 'workflow' is not defined
what is the problem
plz help me
thanks
prasad
________________________________________________________________________
Send free SMS using the Yahoo! Messenger. Go to http://in.mobile.yahoo.com/new/pc/
--0-1438040465-1056107981=:32782
Content-Type: text/plain; name="file.txt"
Content-Description: file.txt
Content-Disposition: inline; filename="file.txt"
1) leave_startform_zpt
-----------------------------------------------------------------------
<html>
<head><tb>
<title tal:content="template/title">The title</title>
<head>
<body>
<p metal:use-macro="here/common_pages/macros/leaveform_macro" />
</body>
</html>
-----------------------------------------------------------------------
2) leaveform_macro
-----------------------------------------------------------------------
<div metal:define-macro="leaveform_macro">
<form name="leave_startform_formulator" method="post" action="leave_start_zpt">
<table tal:define="form here/leave_startform_formulator" align=center>
<tr tal:define="startdate request/startdate|nothing">
<th align="left">
<font size=5><font face="verdana"><b>
Start Date:
</b></font></font>
</th>
<td><input type="text" name="startdate"
tal:replace="structure python:form.startdate.render(startdate)" />
</td>
</tr>
<tr tal:define="enddate request/enddate|nothing">
<th align="left">
<font size=5><font face="verdana"><b>
End Date:
</b></font></font>
</th>
<td><input type="text" name="enddate"
tal:replace="structure python:form.enddate.render(enddate)">
</td>
</tr>
<tr tal:define="reason request/reason|nothing">
<th align="left">
<font size=4><font face="verdana"><b>
Reason:
</b></font></font>
</th>
<td>><textarea type="text" name="reason"
tal:replace="structure python:form.reason.render(reason)"></textarea>
</td>
</tr>
<tr tal:define="leavetype request/leavetype|nothing">
<th align="left">
<font size=4><font face="verdana"><b>
LEA:
</b></font></font>
</th>
<td><textarea type="text" name="leavetype"
tal:replace="structure python:form.leavetype.render(leavetype)"></textarea>
</td>
</tr>
<tr cols="*,350,*">
<td> </td>
<td align=center><input type="submit" value=" Submit "></td>
<td> </td>
</tr>
</table><br>
</form>
</div>
-----------------------------------------------------------------------
3) leave_start_zpt
-----------------------------------------------------------------------
<html>
<head>
<!-- Put your CSS, meta tags and scripts here. -->
</head>
<body bgcolor="#ffffff">
<p tal:replace="structure python:here.gotoOF()" />
<!--<p tal:replace="structure python:here.gotoOF(startdate,enddate,reason,leavetype,requested,formalia,approved,decision)" />-->
<!--<span tal:define="result python:here.mailScript()"></span>-->
</body>
</html>
-----------------------------------------------------------------------
4) gotoOF
-----------------------------------------------------------------------
no parametres for this.
instance="workflow.addInstance('leaverequest',AUTHENTICATED_USER.getUserName(),'no comment','Request for leave by ' + AUTHENTICATED_USER.getUserName(), activation=0)"
instobj="_.getattr(workflow,instance)"
form = context.leave_startform_formulator
instobj=getattr(workflow,instance)
instobj.manage_addProperty('startdate', startdate, 'string')
instobj.manage_addProperty('enddate', enddate, 'string')
instobj.manage_addProperty('reason', reason, 'text')
instobj.manage_addProperty('leavetype', leavetype, 'string')
instobj.manage_addProperty('requested', '', 'string')
instobj.manage_addProperty('formalia', '', 'string')
instobj.manage_addProperty('approved', '', 'string')
instobj.manage_addProperty('decision', '', 'text')
workflow.startInstance(instance)
print "Done"
return printed
-----------------------------------------------------------------------
--0-1438040465-1056107981=:32782--