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


Python Subscription.put方法代码示例

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


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

示例1: sub_command

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
    def sub_command(self, message=None):
        """Subscribe the user to XMPP or SMS"""
        user = message.sender.split('/')[0]
	
        plist = message.body.split(' ' )
 	service_name = plist[1]

	if len(plist)>2:
	    type = "sms"
            user = plist[2]
	else:
	    type = "xmpp"
		
        service = Service.all().filter('name = ', service_name).get()

        if service:
            subscription = Subscription.all().filter('address =', user).filter('service = ', service).get()
            if subscription:
                message.reply("user %s is already subscribed to service %s" % (user, service.name))
            else:
                subscription = Subscription(key_name=hashlib.sha1(user).hexdigest(), type=type, address=user, service=service)
                subscription.put()
                message.reply("Subscribed %s to service %s" % (user, service.name))
        else:
            message.reply("Sorry, I couldn't find a service called "
                          "%s" % service_name)
开发者ID:feczo,项目名称:splashmon,代码行数:28,代码来源:xmpp.py

示例2: post

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
  def post(self):
    cl = Checklist.get(Key.from_path('Checklist', long(self.request.get('cl_id'))))
    if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False):
      return
    
    user = users.get_current_user()
    
    for sub in Subscription.all().filter("user ==", user).filter("deleted ==", False):
      if sub.source.key() == cl.key():
        helpers.createResponse(self, 'message_already_subscribed.html', 
          {'old_checklist': cl})
        
    sub = Subscription(
        user=user,
        source=cl,
        deleted=False,                       
                       )        

    sub.put()

    for item in cl.item_set:
      subItem = SubscribedItem(
          subscription=sub,
          original=item,
          finished=False,
          deleted=False,                               
                               )
      subItem.put()
    
    helpers.createResponse(self, 'message_subscribed.html')
开发者ID:yoooyle,项目名称:checklist,代码行数:32,代码来源:create.py

示例3: get

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
    def get(self):
        public = Subscription(name='public',
                              level=0)
        public.put()

        subscription = Subscription(name='standard',
                                    level=1)
        subscription.put()

        User(name='test',
             password='test',
             subscription=subscription.level).put()
 
        Page(title='Home',
             slug ='home',
             text ='Lorem ipsum...',
             allowed = subscription.level,
             author = users.User('[email protected]')).put()

        self.redirect('/')
开发者ID:guillemborrell,项目名称:vscontentmanager,代码行数:22,代码来源:main.py

示例4: subscribe_command

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
	def subscribe_command(self, message=None):
		subscriber_mail = self.user_mail(message.sender)
		logging.info('subscribing user: %s' % subscriber_mail)
		im_from = db.IM('xmpp', message.sender)
		domain = RequestUtils.getDomain(message.arg)
		if message.arg == 'all':
			domain = 'all'
		if not domain:
			message.reply('You must provide valide domain for subscription. \'%s\' is not valid domain. Make sure that domain starts with http://'  %message.arg)
			return
		existingSubscription = Subscription.gql('WHERE subscriber_mail = :1 and domain = :2 and active = True', subscriber_mail, domain).get()
		if existingSubscription is not None:
			message.reply('You have already subscribed for this domain %s. Remember?' % domain)
			return
		subscription = Subscription(subscriber = im_from, subscriber_mail = subscriber_mail, domain = domain, activationDate = datetime.datetime.now(), active = True, mute = False)
		invite = IMInvite.gql('WHERE jid = :1 ', subscriber_mail)
		subscription.put()
		if invite:
			invite.subscribed = True
			invite.put()
		message.reply('Subscription added.')
开发者ID:bojanbabic,项目名称:Instaright,代码行数:23,代码来源:xmpp_handler.py

示例5: view_subscribe

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
def view_subscribe(request):

    # login is required here
    # if not ( request.user and request.user.is_authenticated() ):
    #    return HttpResponseRedirect()

    if request.user.subscription_set.count() >= Subscription._MAX_SUBSCRIPTIONS_PER_USER:
        Message(
            user=request.user,
            message=ugettext("You've reached maximum number of subscriptions. Delete some and try again."),
        ).put()
    elif request.method == "GET":
        search_form = AdvancedEventFilterForm(request.GET)

        if search_form.is_valid():

            country = Country.get_by_key_name(search_form.cleaned_data["country"])
            region = Region.get_by_key_name(search_form.cleaned_data["region"])
            free = search_form.cleaned_data["forfree"]

            if search_form.cleaned_data["forwho"] == "custom":
                event_types = 0
                for t in search_form.cleaned_data["typelist"]:
                    event_types += 1 << int(t)
            elif search_form.cleaned_data["forwho"] == "everyone":
                event_types = Event.OPEN_EVENTS_MASK
            else:
                # assert(search_form.cleaned_data['forwho'] == 'members')
                event_types = Event.MEMBERS_EVENTS_MASK

            s = Subscription(user=request.user, country=country, region=region, event_types=event_types, free=free)
            s.put()

            Message(user=request.user, message=ugettext("Subscription created")).put()

            return HttpResponseRedirect(
                reverse("events.views.view_event_list", kwargs={"subscription_id": s.key().id()})
            )

    return HttpResponseRedirect(reverse("events.views.view_event_list"))
开发者ID:fikander,项目名称:aolevents,代码行数:42,代码来源:views.py

示例6: post

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import put [as 别名]
  def post(self):
    cl = Checklist.get(Key.from_path('Checklist', long(self.request.get('cl_id'))))
    subscribe = self.request.get('subscribe')
    if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False):
      return
    
    user = users.get_current_user()
    if subscribe == 'false':
      for sub in Subscription.all().filter("user ==", user).filter("deleted ==", False):
        if sub.source.key() == cl.key():
          for subItem in sub.subscribeditem_set:
            subItem.delete()
          sub.delete()
      cl.subscribers = cl.subscribers - 1
      self.response.write("unsubscribed")
    else:
      sub = Subscription(
          user=user,
          source=cl,
          deleted=False,                       
                       )        

      sub.put()

      for item in cl.item_set.filter("deleted ==", False):
        subItem = SubscribedItem(
            subscription=sub,
            original=item,
            finished=False,
            deleted=False,                               
                               )
        subItem.put()

      cl.subscribers = cl.subscribers + 1
      self.response.write("subscribed")
      
    cl.put()
开发者ID:yoooyle,项目名称:checklist,代码行数:39,代码来源:subscribe.py


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