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


Python Subscription.get方法代码示例

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


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

示例1: subscribe

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get [as 别名]
def subscribe(subscriber, resource):
    # HACK workaround for using get_or_create / create_or_get with GFKFields.
    try:
        # HACK workaround for querying equality of GFKField. I'd love to do the following:
        # Subscription.get(
        #     (Subscription.subscriber == subscriber) &
        #     (Subscription.resource == resource))

        sub = Subscription.get(
            (Subscription.subscriber_id == subscriber._get_pk_value()) &
            (Subscription.subscriber_type == subscriber._meta.db_table) &
            (Subscription.resource_id == resource._get_pk_value()) &
            (Subscription.resource_type == resource._meta.db_table))

        created = False

    except Subscription.DoesNotExist:
        sub = Subscription.create(
            subscriber=subscriber,
            resource=resource,
        )

        created = True

    return sub, created
开发者ID:franciscod,项目名称:telegram-universal-forwarder-bot,代码行数:27,代码来源:util.py

示例2: get_subscription

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get [as 别名]
def get_subscription(user_id, id):
    try:
        user = User.get(User.id == user_id)
        subscription = Subscription.get(Subscription.id == id)
        return {'subscriptions': [subscription.json_dict_user(user)]}
    except Subscription.DoesNotExist:
        response.status = 404
    except User.DoesNotExist:
        response.status = 401
    return {}
开发者ID:johnliu,项目名称:journal-server,代码行数:12,代码来源:controller.py

示例3: subscribe_subscription_topic

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get [as 别名]
def subscribe_subscription_topic(user_id, sid):
    try:
        user = User.get(User.id == user_id)
        subscription = Subscription.get(Subscription.id == sid)
        user.unsubscribe_all(subscription)
        return {'subscriptions': [subscription.json_dict_user(user)]}
    except Subscription.DoesNotExist:
        response.status = 404
    except User.DoesNotExist:
        response.status = 401
    return {}
开发者ID:johnliu,项目名称:journal-server,代码行数:13,代码来源:controller.py

示例4: unsubscribe_subscription_topic

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get [as 别名]
def unsubscribe_subscription_topic(user_id, sid, tid):
    try:
        user = User.get(User.id == user_id)
        subscription = Subscription.get(Subscription.id == sid)
        topic = subscription.get_topic(tid)
        user.unsubscribe(subscription, topic)
        return {'subscriptions': [subscription.json_dict_user(user)]}
    except (Subscription.DoesNotExist, Topic.DoesNotExist):
        response.status = 404
    except User.DoesNotExist:
        response.status = 401
    return {}
开发者ID:johnliu,项目名称:journal-server,代码行数:14,代码来源:controller.py

示例5: get

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get [as 别名]
  def get(self, **args):
    sub = Subscription.get(Key.from_path("Subscription", long(args['id'])))
    
    if not sub or sub.deleted: 
      helpers.createResponse(self, 'message_not_exist.html')
      return
    
    if not helpers.checkPermissionAndRespond(self, sub=sub, edit=False): return
    
    subItem_q = sub.subscribeditem_set.filter("deleted ==", False).order("original")
    cursor = self.request.get('cursor_subItem')
    if cursor:
      subItem_q = subItem_q.with_cursor(cursor)
    subItems = subItem_q.fetch(10)

    helpers.createResponse(self, 'dashboard_subItems.html', 
        {'subItems': subItems,
        'sub': sub,
        'cursor_subItem': subItem_q.cursor()})    
开发者ID:yoooyle,项目名称:checklist,代码行数:21,代码来源:index.py


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