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> portal_url = getToolByName(self, 'portal_url')<br> portal = portal_url.getPortalObject()<br>
portal_membership = getToolByName(self, 'portal_membership')<br> <br> 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> <<a href="mailto:rob_lineberger@med.unc.edu">rob_lineberger@med.unc.edu</a>> 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. 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 "Task" through its lifecycle.
<br><br>The problem comes when I try to add an action to one of the<br>transitions. 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 "global name 'context' is not defined."
<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. 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__ = """Rob Lineberger"""<br>__docformat__ = 'plaintext'<br><br>
<br># Workflow Scripts for: track_task<br><br>def new_task(self, state_change, **kw):<br> obj=state_change.object<br> creator = obj.Creator()<br> history = state_change.getHistory()<br> wf_tool = context.track_task
<br><br> mMsg = """<br> You have been assigned a new task.<br> The url is: %s.<br> The description is: %s.<br> """<br><br> member = context.portal_membership.getMemberById(creator)
<br> creator = {'member':member,<br> 'id':member.getId(),<br> 'fullname':member.getProperty('fullname', 'Fullname<br>missing'),<br> 'email':member.getProperty('email', None)}<br>
<br> actorid = wf_tool.getInfoFor(obj, 'actor')<br> actor = context.portal_membership.getMemberById(actorid)<br> reviewer = {'member':actor,<br> 'id':actor.getId(),<br> 'fullname':actor.getProperty
('fullname', 'Fullname<br>missing'),<br> 'email':actor.getProperty('email', None)}<br><br> mTo = creator['email']<br> mFrom = reviewer['email']<br> mSubj = 'Your item has transitioned'<br> obj_url =
obj.absolute_url() #use portal_url + relative_url<br> comments = wf_tool.getInfoFor(obj, 'comments')<br><br> message = mMsg % (obj_url, comments)<br> 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>