I've got an app which is using Pylons for the web portion, but have a
bunch of cron jobs that do data gathering and reporting by email.  I
put this code in the pylons projectname/lib/ subdir so I can get at
the app's database code and such.
I didn't find any simple doc on myghty.org about creating html/text
emails  outside of a web framework or the myghty server mechanism.  An
example got me started at:

http://code.djangoproject.com/wiki/MyghtyTemplatesInDjango

My take on it is like:

   def create_report_text(self, msg, 
template_dir='/home/chris/projects/foo/support'):
       import myghty.interp as mi
       import StringIO
       sio = StringIO.StringIO()
       i = mi.Interpreter(component_root=template_dir)
       i.execute('support_report_text.myt', out_buffer=sio,
                 request_args={'vendor': 'Veni Vedi Vici', 'client': 'Ann 
Elke', 'sysid': 'SYSTEMID'})
       debug("support_report_text sio:\n-----\n%s\n-----" % sio.getvalue())

with template support_report_text.myt (not actually indented):

   <%args>
   vendor
   client
   sysid
   </%args>
   #
   AUTO SUPPORT REPORT (not in templates dir with autohandler)

   Vendor       <%vendor%>
   Client       <%client%>
   SysId        <%sysid%>

and resulting (debug logging) output looks like (not actually indented):

   DEBUG:parse: asup_report_text sio:
   -----
   AUTO SUPPORT REPORT (not in templates dir with autohandler)

   Vendor       Veni Vidi Vici
   Client       Ann Elke
   SysId        SYSTEMID

   -----

This works but seems suboptimal.

Is there a different way to pass vars into the template than the
request_args param?  Do I have to specify the args in the template
with the <%args/> tags?

I have no access to Pylons nice helper functions in the
usual 'h'.
If I put this with my Pylons templates, it breaks because it can't
find 'h' to resolve stylesheets in the autohandler:

   Error(NameError): global name 'h' is not defined
Any recommendations for generating self-contained email messages with
embedded CSS information rather than separate, included CSS as you
would within pylons?
Thanks for any pointers, especially if there are docs on this usage
I've missed.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to