Hi Dave,
Let's take a case of welcome email. A typical welcome email looks like
Hi Dave,
Thanks for creating an account on MyApp. Your account enables to do
the following things:
1. ..
2. .
For your reference, your account username is Dave_123 and your
password is Dave_pass1!.
For any help, send an email to support[AT]myApp.com.
Best Wishes,
The Management.
For this, you can create a Python String Template (http://
docs.python.org/library/string.html#template-strings)
So, while in the admin console the non tech guys have to create the
message, they will type something like
Hi $who,
Welcome to MyApp. Your username is $username and your password is
$password.
For a nice GUI, you can have a large text area where the non tech
people will type the message and a small help sidebar that will tell
them to use $who for user, $username for username and so on,
Later, you can store into the DataStore, this email string template.
class EmailTemplates(db.Model):
template_name = db.StringProperty() # this is the template name,
like welcome email template
template_message = db.TextProperty() #this is the template message
So, when you have to send a welcome email you can do the following
1. Fetch the template from datastore
template = Query(EmailTemplates).filter('template_name = ',
'welcome').fetch(1)
2. Create a dictionary item of the values, something like
template_values = dict(who='SomeOne', username='UserName',
password='Password')
3. Replace the template with the actual values
template.template_message.safe_substitute(template_values)
4. Send the email
This is a little long answer, and i hope it works well for you.
Happy Coding,
Pranav Prakash
On Apr 27, 7:58 am, Dave <[email protected]> wrote:
> I'm looking for a solution to load templates from the datastore. I've
> look at gaebdtemplates but it appears to not be updated for django 1.0
> & new appenginepatch (ie. calls to newforms as other stuff). Overall
> it look like just what I need but can't get it to work. I also have
> flatpages but it seems to not support what I'm after since it's hooked
> to 404.
>
> Specifically I'm wanting to be able to load 'email templates' from the
> datastore. These are the emails sent by the system such as welcome
> email, pasword reset, etc. The goal is to be able allow non tech types
> to update them.
>
> So it needs to a) load templates from datastore, b) support full
> templates with template tags, c) and have a template_loader.
>
> Anyone have suggestions?
>
> Thx,
>
> Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---