本文整理汇总了Python中mkt.developers.utils.uri_to_pk函数的典型用法代码示例。如果您正苦于以下问题:Python uri_to_pk函数的具体用法?Python uri_to_pk怎么用?Python uri_to_pk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uri_to_pk函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: product_create
def product_create(self, account, app):
secret = generate_key(48)
generic = self.generic_create(account, app, secret)
# These just pass straight through to zippy to create the product
# and don't create any intermediate objects in solitude.
#
# Until bug 948240 is fixed, we have to do this, again.
try:
created = self.client.products.get(
external_id=generic['external_id'],
seller_id=uri_to_pk(account.uri))
except HttpClientError:
created = []
if len(created) > 1:
raise ValueError('Zippy returned more than one resource.')
elif len(created) == 1:
return created[0]['resource_uri']
# Note that until zippy get some persistence, this will just
# throw a 409 if the seller doesn't exist.
created = self.client.products.post(data={
'external_id': generic['external_id'],
'seller_id': uri_to_pk(account.uri),
'name': unicode(app.name),
})
return created['resource_uri']
开发者ID:aricha,项目名称:zamboni,代码行数:29,代码来源:providers.py
示例2: get_seller_product
def get_seller_product(account):
"""
Get the solitude seller_product for a payment account object.
"""
bango_product = client.api.bango.product(uri_to_pk(account.product_uri)).get_object_or_404()
# TODO(Kumar): we can optimize this by storing the seller_product
# when we create it in developers/models.py or allowing solitude
# to filter on both fields.
return client.api.generic.product(uri_to_pk(bango_product["seller_product"])).get_object_or_404()
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:9,代码来源:views_payments.py
示例3: account_retrieve
def account_retrieve(self, account):
data = {'account_name': account.name}
package_data = (self.client.package(uri_to_pk(account.uri))
.get(data={'full': True}))
data.update((k, v) for k, v in package_data.get('full').items() if
k in self.package_values)
return data
开发者ID:aricha,项目名称:zamboni,代码行数:7,代码来源:providers.py
示例4: get_generic_product
def get_generic_product(app):
if app.app_payment_accounts.exists():
for account in app.app_payment_accounts.all():
print (
'Looking up public_id for app '
'{app} using account {account}'
).format(
app=app,
account=account.payment_account.seller_uri)
try:
generic_product = Provider.generic.product.get_object(
seller=uri_to_pk(account.payment_account.seller_uri),
external_id=make_external_id(app))
print (
'Found generic product {product} for '
'app {app} using account {account}'
).format(
product=generic_product['public_id'],
app=app,
account=account)
return generic_product
except ObjectDoesNotExist:
pass
except MultipleObjectsReturned:
print 'Found multiple generic products for app {app}'.format(
app=app)
print 'Unable to find a generic product for app {app}'.format(app=app)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:27,代码来源:populate_solitude_public_ids.py
示例5: test_show_secret
def test_show_secret(self, solitude):
self.set_mocks(solitude)
resp = self.client.get(self.url)
eq_(resp.content, 'shhh!')
pk = uri_to_pk(self.account.product_uri)
solitude.api.bango.product.assert_called_with(pk)
solitude.api.generic.product.assert_called_with('prod-pk')
开发者ID:prodigeni,项目名称:zamboni,代码行数:7,代码来源:test_views_payments.py
示例6: get_generic_product
def get_generic_product(app):
if app.app_payment_accounts.exists():
account = app.app_payment_accounts.all()[:1].get()
generic_product = Provider.generic.product.get_object(
seller=uri_to_pk(account.payment_account.seller_uri),
external_id=make_external_id(app),
)
return generic_product
开发者ID:BIGGANI,项目名称:zamboni,代码行数:8,代码来源:populate_solitude_public_ids.py
示例7: generic_create
def generic_create(self, account, app, secret):
# This sets the product up in solitude.
external_id = webpay.make_ext_id(app.pk)
data = {'seller': uri_to_pk(account.seller_uri),
'external_id': external_id}
# Create the generic product.
try:
generic = self.generic.product.get_object_or_404(**data)
except ObjectDoesNotExist:
generic = self.generic.product.post(data={
'seller': account.seller_uri, 'secret': secret,
'external_id': external_id, 'public_id': str(uuid.uuid4()),
'access': ACCESS_PURCHASE,
})
return generic
开发者ID:aricha,项目名称:zamboni,代码行数:17,代码来源:providers.py
示例8: generic_create
def generic_create(self, account, app, secret):
# This sets the product up in solitude.
external_id = WebAppProduct(app).external_id()
data = {"seller": uri_to_pk(account.seller_uri), "external_id": external_id}
# Create the generic product.
try:
generic = self.generic.product.get_object_or_404(**data)
except ObjectDoesNotExist:
generic = self.generic.product.post(
data={
"seller": account.seller_uri,
"secret": secret,
"external_id": external_id,
"public_id": str(uuid.uuid4()),
"access": ACCESS_PURCHASE,
}
)
return generic
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:20,代码来源:providers.py
示例9: account_retrieve
def account_retrieve(self, account):
data = {"account_name": account.name}
package_data = self.client.package(uri_to_pk(account.uri)).get(data={"full": True})
data.update((k, v) for k, v in package_data.get("full").items() if k in self.package_values)
return data
开发者ID:cvan,项目名称:zamboni,代码行数:5,代码来源:providers.py
注:本文中的mkt.developers.utils.uri_to_pk函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论