本文整理汇总了Python中models.Email.save方法的典型用法代码示例。如果您正苦于以下问题:Python Email.save方法的具体用法?Python Email.save怎么用?Python Email.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Email
的用法示例。
在下文中一共展示了Email.save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callback
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import save [as 别名]
def callback():
""" Handles the home page rendering."""
if request.data:
data = json.loads(request.data)
else:
data = request.form
email_from = data['from']
name, email = parse_email(email_from)
user = User.get_or_create(name=name, email=email)
subject = data['subject']
reply_regex = re.compile('[Rr][Ee]\s*\:')
fwd_regex = re.compile('[Ff][Ww][Dd]*\s*\:')
subject = re.sub(reply_regex, '', subject).strip()
subject = re.sub(fwd_regex, '', subject).strip()
thread = Email.get_thread(subject)
if 'time' in data:
time = parse(data['time'])
else:
time = datetime.datetime.now()
text = unquote(data['text'])
if 'html' in data:
html = unquote(data['html'])
else:
html = text
email = Email(
_from=user,
to=data['to'],
subject=subject,
text=text,
html=html,
time=time,
thread=thread,
)
email.save()
return 'Thanks Swift'
示例2: cadastrar_newsletter_ajax
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import save [as 别名]
def cadastrar_newsletter_ajax(request):
try:
email = strip_tags(request.POST['email'])
nome = strip_tags(request.POST['nome'])
try:
cadastro = Email.objects.get(email = email)
resposta = "email_existente"
except Email.DoesNotExist:
novo_cadastro = Email()
novo_cadastro.email = email
novo_cadastro.nome = nome
novo_cadastro.save()
resposta = "sucesso"
except Exception:
resposta = "falha"
pass
return HttpResponse(resposta)
示例3: jsonrpc_logMessage
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import save [as 别名]
def jsonrpc_logMessage(self, body):
"""
Return sum of arguments.
"""
store = Email()
message = email.message_from_string(str(body))
store.to_email = message["To"]
store.from_email = message["From"]
store.subject = message["Subject"]
store.message_id = message["Message-ID"]
headers = []
for k,v in message.items():
headers.append({"header":k, "value": v})
store.headers = json.dumps(headers)
store.save()
return str(store.id)
示例4: email_list_data
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import save [as 别名]
def email_list_data():
with apps.app_context():
val = redis.rpop("email_list")
while(val is not None):
json_obj = json.loads(val)
email_from = json_obj['email_from']
email_to = json_obj['email_to']
if type(email_to) is unicode:
email_to = email_to.split(',')
email_subject = json_obj['email_subject']
email_body = json_obj['email_body']
email_type = json_obj['email_type']
email_password = json_obj['email_password']
apps.config.update(
DEBUG=True,
#EMAIL SETTINGS
MAIL_SERVER='smtp.gmail.com',
MAIL_PORT=465,
MAIL_USE_SSL=True,
MAIL_USERNAME = email_from,
MAIL_PASSWORD = email_password
)
mail=Mail(apps)
send_email(email_subject,email_from, email_password, email_body, email_to)
em = Email(email_subject = email_subject, email_to = email_to,
email_from = email_from, email_body = email_body, email_type = email_type)
em.save()
val = redis.rpop("email_list")
return 0
示例5: index
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import save [as 别名]
def index(request):
email = request.GET.get('email', False)
operation = request.GET.get('op', 'add')
order = request.GET.get('order', False)
if email:
if operation == 'add':
try:
email_model = Email(email=email)
email_model.save()
email = True
except IntegrityError:
pass
elif operation == 'remove':
try:
email_model = Email.objects.get(email=email)
email_model.delete()
email = True
except ObjectDoesNotExist:
pass
template = loader.get_template('store/game_list.html')
drm = request.GET.get('drm', None)
query = request.GET.get('query', None)
if order == 'new':
games = sorted(get_games_with_keys(drm=drm, query=query, new=True))
else:
games = sorted(get_games_with_keys(drm=drm, query=query))
context = {
'game_list': games,
'drm': drm,
'query': query,
'email_added': email,
'email_op': operation
}
return HttpResponse(template.render(context, request))
示例6: Email
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import save [as 别名]
email_succeeded = -1
# IMPORTANT: This marks the key as available again.
key.claimed = False
key.save()
pass
else:
# Somebody else got the key first, or something else unexpected happened.
status = False
email_succeeded = -1
message = 'Sorry but the key seems to have been taken. You have not been charged.'
# If user indicated that they'd like to be added to the emailing list, add them.
if add_to_list and status and email_succeeded > -1:
try:
model_email = Email(email=email)
model_email.save()
except IntegrityError:
pass
context = {
'errors': message,
'transaction_status': status,
'game_price_num': '{:.2f}'.format(get_adjusted_price(game.price)),
'game_title': game.name,
'game_description': game.description,
'game_price': '${:.2f} USD'.format(get_adjusted_price(game.price)),
'drm': drm,
'email': email_succeeded,
'attempted_email': email,
'code': code,
'list': add_to_list,