Rob,<br><br>Here's the code I use in my workflow scripts to get the member. You shouldn't need to use context.<br><br>&nbsp;&nbsp;&nbsp; portal_url&nbsp; = getToolByName(self, 'portal_url')<br>&nbsp;&nbsp;&nbsp; portal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = portal_url.getPortalObject()<br>
&nbsp;&nbsp;&nbsp; portal_membership = getToolByName(self, 'portal_membership')<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; member = portal_membership.getMemberById(obj.Creator())<br><br>Mike<br><br><div><span class="gmail_quote">On 8/23/06, <b class="gmail_sendername">
Rob Lineberger</b> &lt;<a href="mailto:rob_lineberger@med.unc.edu">rob_lineberger@med.unc.edu</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Running into a wall here and hope someone can point me in the right<br>direction.&nbsp;&nbsp;I've programatically added a custom workflow called<br>track_task to a product in Plone. Everything works fine; I tested the<br>product, carrying an instance of &quot;Task&quot; through its lifecycle.
<br><br>The problem comes when I try to add an action to one of the<br>transitions.&nbsp;&nbsp;When the Task is assigned via the 'assign' transition, I<br>want it to send an email to the personResponsible. When I do that I get<br>an error &quot;global name 'context' is not defined.&quot;
<br><br> I followed both the tutorial on <a href="http://plone.org">plone.org</a><br>(<a href="http://plone.org/documentation/how-to/send-mail-on-workflow-transition/#1124212172">http://plone.org/documentation/how-to/send-mail-on-workflow-transition/#1124212172
</a>)<br>and the one in the Definitive guide to Plone.<br><br>This error is causing me more trouble than usual because I don't know<br>how to troubleshoot if there is no context.&nbsp;&nbsp;I though context was always<br>there no matter what?
<br><br>Anyway, here is the offending code:<br><br># File: LabProject.py<br># Copyright (c) 2006 by Rob Lineberger<br><br>__author__ = &quot;&quot;&quot;Rob Lineberger&quot;&quot;&quot;<br>__docformat__ = 'plaintext'<br><br>
<br># Workflow Scripts for: track_task<br><br>def new_task(self, state_change, **kw):<br>&nbsp;&nbsp;&nbsp;&nbsp;obj=state_change.object<br>&nbsp;&nbsp;&nbsp;&nbsp;creator = obj.Creator()<br>&nbsp;&nbsp;&nbsp;&nbsp;history = state_change.getHistory()<br>&nbsp;&nbsp;&nbsp;&nbsp;wf_tool = context.track_task
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;mMsg = &quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;You have been assigned a new task.<br>&nbsp;&nbsp;&nbsp;&nbsp;The url is: %s.<br>&nbsp;&nbsp;&nbsp;&nbsp;The description is: %s.<br>&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;member = context.portal_membership.getMemberById(creator)
<br>&nbsp;&nbsp;&nbsp;&nbsp;creator = {'member':member,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'id':member.getId(),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'fullname':member.getProperty('fullname', 'Fullname<br>missing'),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'email':member.getProperty('email', None)}<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;actorid = wf_tool.getInfoFor(obj, 'actor')<br>&nbsp;&nbsp;&nbsp;&nbsp;actor = context.portal_membership.getMemberById(actorid)<br>&nbsp;&nbsp;&nbsp;&nbsp;reviewer = {'member':actor,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id':actor.getId(),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'fullname':actor.getProperty
('fullname', 'Fullname<br>missing'),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'email':actor.getProperty('email', None)}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;mTo = creator['email']<br>&nbsp;&nbsp;&nbsp;&nbsp;mFrom = reviewer['email']<br>&nbsp;&nbsp;&nbsp;&nbsp;mSubj = 'Your item has transitioned'<br>&nbsp;&nbsp;&nbsp;&nbsp;obj_url = 
obj.absolute_url() #use portal_url + relative_url<br>&nbsp;&nbsp;&nbsp;&nbsp;comments = wf_tool.getInfoFor(obj, 'comments')<br><br>&nbsp;&nbsp;&nbsp;&nbsp;message = mMsg % (obj_url, comments)<br>&nbsp;&nbsp;&nbsp;&nbsp;context.MailHost.send(message, mTo, mFrom, mSubj)<br><br><br><br>
_______________________________________________<br>triangle-zpug mailing list<br><a href="mailto:triangle-zpug@starship.python.net">triangle-zpug@starship.python.net</a><br><a href="http://starship.python.net/mailman/listinfo/triangle-zpug">
http://starship.python.net/mailman/listinfo/triangle-zpug</a><br></blockquote></div><br>