• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.uri_to_pk函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python views.preload_submit函数代码示例发布时间:2022-05-27
下一篇:
Python utils.check_upload函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap