-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
getMemberById is a method on the portal_membership tool. You grab the
tool and call the method:
mt = getToolByName(context, 'portal_membership')
member = mt.getMemberById(id)
I highly suggest you get more familiar with Python in general.
Importing a module to somehow make a method on an instance available
makes no sense whatsoever.
jens
On 26 Feb 2007, at 15:13, [EMAIL PROTECTED] wrote:
Hi,
I am playing around trying to make something happen on a workflow
state
change. Beacause I cannot import the module I need in the python
script I
am getting an error:
global name 'getMemberById' is not defined
how can I import this module or better still code this so I am not
importing anything at all (i imagine the restrictions on importing
modules
was done for a reason).
#import the module we need
from Products.CMFCore.utils import getToolByName
# Get the content object we're publishing
review_state.object
# How can I import this module?????
#from Products.CMFDefault.MembershipTool import MembershipTool
mt = getToolByName(context, 'portal_membership')
listed_ids = mt.getRoster()
contentObject = review_state
# Start with an empty list, ready to be filled with the addressed
# of people we're dispatching to
mailList=[]
mailhost = context.MailHost
mailhost = getattr(context, 'MailHost', None)
# Iterate through all the site's users
# context.portal_membership.listMembers():
for id in listed_ids:
member = getMemberById(id)
email = member.getProperty('email')
# add them to the list of people we're emailing
mailList.append(email)
mMsg = 'Crop notification sent'
mTo = email
# and send it
mailhost.send(mMsg, mTo, '[EMAIL PROTECTED]', 'New Crops
available')
# The change in indentation signals the end of the loop, so we've
# now sent all the emails. Let's now send a confirmation that we've
done it.
# We'll be building the email as a string again, but we have to
convert our
# list data elements into a string before we can append the
information
recipients = string.join(mailList)
mMsg = 'These people were sent e-mails'
#mMsg += contentObject.absolute_url() +
mMsg += recipients
mailhost.send(mMsg, '[EMAIL PROTECTED]', '[EMAIL PROTECTED]',
'Lizard Leaves Announcement email confirmation')
thx
[]'s
Ian
F U cn rd dis U mst uz Linux.
_______________________________________________
Zope maillist - Zope@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 )
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iD8DBQFF4vBARAx5nvEhZLIRAlqVAJ9uXfrE6ktRgS2rCOEqhqIPzvWQZACfYge6
ix/M5/TI5w1DyOXu+XTB604=
=eV1e
-----END PGP SIGNATURE-----
_______________________________________________
Zope maillist - Zope@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 )