本文整理汇总了Python中configuration.Configuration.get_instance方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.get_instance方法的具体用法?Python Configuration.get_instance怎么用?Python Configuration.get_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.get_instance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get_instance [as 别名]
def get(self):
config = Configuration.get_instance()
matches = re.match(
r"/(?P<hash>[0-9a-z]+)",
self.request.path)
if matches:
file_hash = matches.group("hash")
current_conversion = get_conversion_from_hash(file_hash)
if current_conversion:
path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/main.html')
colors = current_conversion.get_palette()
self.response.out.write(template.render(path, {'show_file': True,
'key': current_conversion.hash,
'filename': current_conversion.filename,
'palette': simplejson.dumps(
{'filename': current_conversion.filename,
'colors': colors}),
'web_debug': config.web_debug}))
return
path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/error.html')
self.response.out.write(template.render(path, {'status': '404',
'message': "We don't have what you're looking for."}))
self.response.status = 404
示例2: post
# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get_instance [as 别名]
def post(self):
config = Configuration.get_instance()
stripe.api_key = config.private_stripe_key
# Get the credit card details submitted by the form
token = self.request.POST['stripeToken']
file_hash = self.request.POST['key']
current_conversion = get_conversion_from_hash(file_hash)
if current_conversion:
# Create the charge on Stripe's servers - this will charge the user's card
try:
charge = stripe.Charge.create(
amount=200,
currency="usd",
card=token,
description=current_conversion.filename
)
current_conversion.paid_date = datetime.datetime.now()
current_conversion.put()
except stripe.CardError, e:
# The card has been declined
logging.error('Card payment declined' + e.message)
pass
self.redirect("/" + file_hash)
示例3: get
# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get_instance [as 别名]
def get(self):
config = Configuration.get_instance()
path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/main.html')
self.response.out.write(template.render(path, {'show_file': False,
'stripe_key': config.public_stripe_key,
'web_debug': config.web_debug}))