Skip to content

Instantly share code, notes, and snippets.

@swarbhanu
Created June 1, 2012 16:15
Show Gist options
  • Save swarbhanu/2853282 to your computer and use it in GitHub Desktop.
Save swarbhanu/2853282 to your computer and use it in GitHub Desktop.
Script to send an actual email through the user notification service
from interface.objects import DeliveryMode, UserInfo, DetectionFilterConfig
from pyon.event.event import EventPublisher
#---------------------------------------------------------------------------------
# Create email notification
#---------------------------------------------------------------------------------
rr = pn.resource_registry
user = UserInfo(name = 'user')
user_id, _ = rr.create(user)
uns = pn.user_notification
notification_id = uns.create_email(event_type='ResourceLifecycleEvent',
event_subtype=None,
origin='Some_Resource_Agent_ID1',
origin_type=None,
user_id=user_id,
email='schatterjee@asascience.com',
mode = DeliveryMode.DIGEST,
message_header='message_header',
parser='parser',
period=1)
#-------------------------------------------------------
# publish an event for each notification to generate the emails
#-------------------------------------------------------
rle_publisher = EventPublisher("ResourceLifecycleEvent")
rle_publisher.publish_event(origin='Some_Resource_Agent_ID1', description="RLE test event for email")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment