Jani Tiainen kirjoitti:
> Emmanuel Blot kirjoitti:
>>> Not yet. I'm just looking code in trac.notification but it's not very
>>> descriptive. An example would help...
>>
>> I agree ;-)
>> Sorry, no spare time.
>
> Just for further reference, here is one of the simples approaches I and
> few others from #trac IRC managed to stitch together last night.
>
> For people that asre just reading this: if you want to send e-mail by
> using Trac settings (usernames and such) from some project here is small
> sample how it can be achieved.
>
> I put contents of those two files in xml-like <code></code> tags.
>
> First you need you email template. We put it simple way:
well it can be a bit simpler... :) Just provide full, absolute path to
template_name and you don't need that funny... component anymore.
<code file="send_email.py">
from trac.env import Environment
from trac.notification import NotifyEmail
class SampleNotification(NotifyEmail):
def __init__(self, env):
# Provide full path here so you don't get in the troubles.
self.template_name = '/full/path/to/notify_email.txt'
NotifyEmail.__init__(self, env)
def notify(self, resid, subject):
subject = '[%s] %s' % (self.config.get('project', 'name'), subject)
NotifyEmail.notify(self, resid, subject)
def get_recipients(self, resid):
return ([self.email_map[resid]], [])
# It's advised to use open_environment here
env = Environment('/path/to/project/', create=0)
mtn = SampleNotification(env)
mtn.notify('tracuser', 'Notification from script')
</code>
--
Jani Tiainen
"Tein sein mihin näillä lahjoilla pystyin.
Tein sen, en yhtään enempää." - Martti Servo & Napander
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" 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/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---