当前位置: 首页>>代码示例>>Python>>正文


Python Client.id方法代码示例

本文整理汇总了Python中models.Client.id方法的典型用法代码示例。如果您正苦于以下问题:Python Client.id方法的具体用法?Python Client.id怎么用?Python Client.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Client的用法示例。


在下文中一共展示了Client.id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_and_store

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import id [as 别名]
def get_and_store( request, action = None, val = None ):
    '''
    Triggeres specific API calls to fetch and pupulate Accounts and Campaigns in those accounts
    Use this to populate initial data
    :param request:
    :param action: get_all_account_details, get_all_campaigns 
    :param val: Account 
    '''
    result = {'r':'failed'}
    result['action'] = action
    ai = adwords_utils.Adwords_interactor()

    if action == 'get_all_account_details':
        all_client_details = ai.get_all_account_details()
        for temp_client in all_client_details:
            print temp_client['customerId']
            import pdb; pdb.set_trace()
            try:
                c = Client.objects.get( login = temp_client['login'])
                if c.client_id != temp_client['customerId']:
                    c.client_id = temp_client['customerId']
                    c.name = temp_client['name']
                    c.save()
            except Client.DoesNotExist:
                c = Client( client_id = temp_client['customerId'], name = temp_client['name'], login = temp_client['login'], depth = temp_client['depth'] )
                c.save()
        result['d'] = all_client_details
        result['r'] = 'success'

    elif action == 'get_all_campaigns':
        """
        get all campaigns data
        """
        try:
            temp_client = Client.objects.get( id = val )

            all_campaigns = ai.get_all_campaigns( temp_client.id )
            for temp_campaign in all_campaigns:
                try:
                    c = Campaign.objects.get( name = temp_campaign['name'] )
                    if not c.id:
                        c.id = temp_campaign['id']
                        c.save()
                except Campaign.DoesNotExist: 
                    c = Campaign( client = temp_client,
                                 id = temp_campaign['id'],
                                 name = temp_campaign['name'],
                                 status = temp_campaign['status'],
                                 campaign_stats = temp_campaign['campaignStats'],
                                 frequency_cap = temp_campaign['frequencyCap'],
                                 )
                    c.save()
            result['d'] = all_campaigns
            result['r'] = 'success'

        except Client.DoesNotExist:
            result['d'] = "client doesn't exist"
    elif action == 'gat_':
        pass
    else:
        pass
    return HttpResponse( dumps( result ) )
开发者ID:vivekananda,项目名称:django_adwords,代码行数:64,代码来源:views.py


注:本文中的models.Client.id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。