本文整理匯總了Python中framework.config.Config.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.get方法的具體用法?Python Config.get怎麽用?Python Config.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類framework.config.Config
的用法示例。
在下文中一共展示了Config.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: send
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def send(phone, message):
log.info("Sending sms...")
message = clean(message)
settings = Config.get('twilio')
account = twilio.Account(settings['sid'], settings['token'])
callback = Config.base_url()
if not callback:
callback = Config.get('default_host')
data = { 'From': settings['phone'],
'To': phone,
'Body': message,
'StatusCallback': "%stwilio/status" % callback
}
log.debug(data)
try:
response = account.request('/%s/Accounts/%s/SMS/Messages.json' % (settings['api'], settings['sid']), 'POST', data)
log.info("--> %s" % response)
response = json.loads(response)
smsid = response['TwilioResponse']['SMSMessage']['Sid']
status = "passed"
except Exception, e:
log.error(e)
smsid = None
status = "blocked"
示例2: showHome
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def showHome(self):
"""
Sets up template data and renders homepage template.
"""
homepage = Config.get("homepage")
features = Config.get("features")
locationData = mLocation.getSimpleLocationDictionary(self.db)
allIdeasData = mIdea.getMostRecentIdeas(self.db, homepage["num_recent_ideas"])
locations = dict(data=locationData, json=json.dumps(locationData))
allIdeas = dict(data=allIdeasData, json=json.dumps(allIdeasData))
news = self.getNewsItems()
if bool(features.get("is_display_leaderboard")):
leaderboardProjects = mProject.getLeaderboardProjects(self.db, 6)
self.template_data["leaderboard"] = leaderboardProjects
if bool(features.get("is_display_featured_projects")):
featuredProjects = mProject.getFeaturedProjects(self.db, 6)
self.template_data["featured_projects"] = featuredProjects
if bool(features.get("is_community_leaders_displayed")):
community_leaders = self.orm.query(models.CommunityLeader).order_by("`order`").all()
self.template_data["community_leaders"] = community_leaders
self.template_data["locations"] = locations
self.template_data["all_ideas"] = allIdeas
self.template_data["news"] = news
return self.render("home", {"locations": locations, "all_ideas": allIdeas})
示例3: emailAccountDeactivation
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def emailAccountDeactivation(email):
"""
Email deleted users. Using template: account_deactivation
@type email: string
@param email: Email address to send to
...
@rtype: Boolean
@returns: Whether emailer was successful or not.
"""
# Create values for template.
emailAccount = Config.get('email')
subject = "Your account has been deactivated"
link = "%stou" % Config.get('default_host')
template_values = {
'link': link,
'config': Config.get_all()
}
# Render email body.
body = Emailer.render('email/account_deactivation', template_values, suffix = 'txt')
# Send email.
try:
return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
from_address = emailAccount['from_email'])
except Exception, e:
log.info("*** couldn't send account deactivation email")
log.error(e)
return False
示例4: emailUnauthenticatedUser
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def emailUnauthenticatedUser(email, authGuid):
"""
Send unauthenticated user a link to authenticate. Using
template: auth_user
@type email: string
@param email: Email address to send to
@rtype: *
@returns: Emailer send response.
"""
# Create values for template.
emailAccount = Config.get('email')
subject = "Please authenticate your account"
link = "%sjoin/auth/%s" % (Config.get('default_host'), authGuid)
template_values = {
'link': link,
'config': Config.get_all()
}
# Render email body.
body = Emailer.render('email/auth_user', template_values, suffix = 'txt')
# Send email.
try:
return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
from_address = emailAccount['from_email'])
except Exception, e:
log.info("*** couldn't send authenticate user email")
log.error(e)
return False
示例5: emailTempPassword
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def emailTempPassword(email, password):
"""
Email temporary password. Using template: forgot_password
@type email: string
@param email: Email address to send to
...
@rtype: Boolean
@returns: Whether emailer was successful or not.
"""
# Create values for template.
emailAccount = Config.get('email')
subject = "Your password has been reset"
link = "%slogin" % Config.get('default_host')
link = "%stou" % Config.get('default_host')
template_values = {
'password': password,
'link': link,
'config': Config.get_all()
}
# Render email body.
body = Emailer.render('email/forgot_password', template_values, suffix = 'txt')
# Send email.
try:
return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
from_address = emailAccount['from_email'])
except Exception, e:
log.info("*** couldn't send forgot password email")
log.error(e)
return False
示例6: emailResourceApproval
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def emailResourceApproval(email, title):
"""
Email resource owner on approval. Using template: resource_approval
@type email: string
@param email: Email address to send to
...
@rtype: Boolean
@returns: Whether emailer was successful or not.
"""
# Create values for template.
emailAccount = Config.get('email')
subject = "Your resource has been approved"
template_values = {
'link': Config.get('default_host'),
'title': title,
'config': Config.get_all()
}
# Render email body.
body = Emailer.render('email/resource_approval', template_values, suffix = 'txt')
# Send email.
try:
return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
from_address = emailAccount['from_email'])
except Exception, e:
log.info("*** couldn't send resource approval email")
log.error(e)
return False
示例7: showHome
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def showHome(self):
"""
Sets up template data and renders homepage template.
"""
homepage = Config.get('homepage')
features = Config.get('features')
locationData = mLocation.getSimpleLocationDictionary(self.db)
allIdeasData = mIdea.getMostRecentIdeas(self.db, homepage['num_recent_ideas']);
locations = dict(data = locationData, json = json.dumps(locationData))
allIdeas = dict(data = allIdeasData, json = json.dumps(allIdeasData))
news = self.getNewsItems()
if (bool(features.get('is_display_leaderboard'))):
leaderboardProjects = mProject.getLeaderboardProjects(self.db, 6)
self.template_data['leaderboard'] = leaderboardProjects
if (bool(features.get('is_display_featured_projects'))):
featuredProjects = mProject.getFeaturedProjects(self.db, 6)
self.template_data['featured_projects'] = featuredProjects
if (bool(features.get('is_community_leaders_displayed'))):
community_leaders = self.orm.query(models.CommunityLeader) \
.order_by('`order`') \
.all()
self.template_data['community_leaders'] = community_leaders
self.template_data['locations'] = locations
self.template_data['all_ideas'] = allIdeas
self.template_data['news'] = news
return self.render('home', {'locations':locations, 'all_ideas':allIdeas})
示例8: getHomepageQuestion
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def getHomepageQuestion(self):
q = None
if (Config.get('homepage').get('is_question_from_cms')):
sql = "select question from homepage_question where is_active = 1 and is_featured = 1"
data = list(self.db.query(sql))
if (len(data) == 1):
q = data[0].question
if (not q):
q = Config.get('homepage').get('question')
return q
示例9: emailProjectEndorsement
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def emailProjectEndorsement(email, title, leaderName):
"""
Email project admins about endorsements. Using template: project_endorsement
@type email: string
@param email: Email address to send to
...
@rtype: Boolean
@returns: Whether emailer was successful or not.
"""
# Create values for template.
emailAccount = Config.get('email')
subject = "%s liked your project!" % leaderName
template_values = {
'title': title,
'leader_name': leaderName,
'config': Config.get_all()
}
# Render email body.
body = Emailer.render('email/project_endorsement', template_values, suffix = 'txt')
# Send email.
try:
return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
from_address = emailAccount['from_email'])
except Exception, e:
log.info("*** couldn't send endorsement email")
log.error(e)
return False
示例10: getS3Path
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def getS3Path(self, fileid):
"""
Get the path to the file given by the fileid on the S3 server.
"""
return "%(file_path)s/%(file_id)s" % {'file_path': Config.get('media').get('file_path'),
'file_id': fileid}
示例11: GET
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def GET(self, action = None):
"""
Get for Blitz.io route
"""
response = Config.get('blitz_io').get('response')
return response
示例12: newProject
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def newProject(self):
if (self.request('main_text')): return False
supported_features = Config.get('features')
if (self.user):
owner_user_id = self.user.id
title = self.request('title')
description = self.request('text')
organization = self.request('organization')
locationId = util.try_f(int, self.request('location_id'), -1)
imageId = self.request('image')
keywords = [word.strip() for word in self.request('keywords').split(',')] if not util.strNullOrEmpty(self.request('keywords')) else []
resourceIds = self.request('resources').split(',')
isOfficial = self.user.isAdmin and supported_features.get('is_official_supported')
projectId = mProject.createProject(self.db, owner_user_id, title, description, ' '.join(keywords), locationId, imageId, isOfficial, organization)
for resourceId in resourceIds:
log.info("*** insert resource id %s" % resourceId)
mProject.addResourceToProject(self.db, projectId, resourceId)
if (projectId):
return projectId
else:
log.error("*** couldn't create project")
return False
else:
log.error("*** only logged in users can create projects")
return False
示例13: directMessageUser
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def directMessageUser(db, toUserId, toName, toEmail, fromUserId, fromName, message):
"""
Email user about direct message. Using template: direct_message
@type email: string
@param email: Email address to send to
...
@rtype: Boolean
@returns: Whether emailer was successful or not.
"""
# Create values for template.
emailAccount = Config.get('email')
#email = "%s <%s>" % (toName, toEmail)
email = toEmail
subject = "Change By Us message from %s" % fromName
link = "%suseraccount/%s" % (Config.get('default_host'), fromUserId)
template_values = {
'name': fromName,
'message': message,
'link': link,
'config': Config.get_all()
}
# Render email body.
body = Emailer.render('email/direct_message', template_values, suffix = 'txt')
# Send email.
try:
isSent = Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
from_address = emailAccount['from_email'])
if (isSent):
db.insert('direct_message', message = message, to_user_id = toUserId, from_user_id = fromUserId)
return True
else:
log.info("*** couldn't log direct message")
# Not sure if best to return False
return False
except Exception, e:
log.info("*** couldn't send direct message email")
log.error(e)
return False
示例14: getLocalPath
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def getLocalPath(self, fileid):
"""
Get the path to the file given by the fileid on the local file system.
This is used only to temporarily save the file before uploading it to
the S3 server.
"""
return "%(file_path)s/%(file_id)s" % {'file_path': Config.get('media').get('file_path'),
'file_id': fileid}
示例15: validate
# 需要導入模塊: from framework.config import Config [as 別名]
# 或者: from framework.config.Config import get [as 別名]
def validate(request):
# this is just a cheap validate that depends on the attacker not knowing our AccountSid, it's not secure
settings = Config.get('twilio')
if request('AccountSid') != settings['sid']:
log.error("Request from Twilio does not have correct sid! Possibly an attack! Blocking message.")
log.error("--> was theirs [%s] vs ours [%s]" % (request('AccountSid'), settings['sid']))
return False
return True