當前位置: 首頁>>代碼示例>>Python>>正文


Python Channel.all方法代碼示例

本文整理匯總了Python中models.Channel.all方法的典型用法代碼示例。如果您正苦於以下問題:Python Channel.all方法的具體用法?Python Channel.all怎麽用?Python Channel.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Channel的用法示例。


在下文中一共展示了Channel.all方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: list_command

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
 def list_command(self, msg):
   """Handle /list commands."""
   lines = []
   q = Channel.all().order('-num_members').filter('num_members >', 0)
   channels = q.fetch(self._LIST_LIMIT + 1)
   if not len(channels):
     msg.reply('* No channels exist!')
     return
   if len(channels) <= self._LIST_LIMIT:
     # Show all, sorted by channel name.
     channels.sort(key=lambda c: c.name)
     lines.append('* All channels:')
   else:
     # Show the top N channels, sorted by num_members.
     channels.pop()
     lines.append('* More than %d channels; here are the most popular:' %
                  self._LIST_LIMIT)
   for c in channels:
     if c.num_members == 1:
       count = '1 person'
     else:
       count = '%d people' % c.num_members
     s = '* - %s (%s)' % (c, count)
     lines.append(s)
   msg.reply('\n'.join(lines))
開發者ID:hasantayyar,項目名稱:robot-talk,代碼行數:27,代碼來源:xmpp.py

示例2: list_command

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
 def list_command(self, msg):
   """Handle /list commands."""
   lines = []
   q = Channel.all().order('-num_members').filter('num_members >', 0)
   channels = q.fetch(self._LIST_LIMIT + 1)
   if not len(channels):
     msg.reply(u'* 沒有任何頻道!')
     return
   if len(channels) <= self._LIST_LIMIT:
     # Show all, sorted by channel name.
     channels.sort(key=lambda c: c.name)
     lines.append('* 所有頻道清單如下:')
   else:
     # Show the top N channels, sorted by num_members.
     channels.pop()
     lines.append('* 頻道數超過 %d; 底下是最受歡迎的清單:' %
                  self._LIST_LIMIT)
   for c in channels:
     if c.num_members == 1:
       count = '1 個人'
     else:
       count = '%d 個人' % c.num_members
     s = '* - %s (%s)' % (c, count)
     lines.append(s)
   msg.reply(u'\n'.join(lines))
開發者ID:wade-fs,項目名稱:mud-fs,代碼行數:27,代碼來源:xmpp.py

示例3: get

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
 def get(self, op):
   if op == 'channels':
     channels = Channel.all().order('-num_members').fetch(self._MAX_CHANNELS)
     self.Render('channels.html', {
         'channels': channels,
         'max': min(len(channels), self._MAX_CHANNELS),
     })
   elif op == 'transcript':
     self.RenderTranscript()
開發者ID:FerHarris,項目名稱:google-app-engine-samples,代碼行數:11,代碼來源:transcript.py

示例4: get

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
 def get(self):
     global is_modified
     is_modified = True
     for ch in Channel.all():
         ch.delete()
     for c in CHANNELS_LIST:
         channel = Channel(img_url=c["img_url"], name=c["name"])
         channel.put()
         taskqueue.add(url="/tvfeed/update", method="POST", params={"key": channel.key(), "gogo_id": c["c_id"]})
     self.response.out.write("Started")
開發者ID:erdenezul,項目名稱:tv-feeder,代碼行數:12,代碼來源:tv.py

示例5: post

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
    def post(self, hash):
        hash = hash.lower()
        target = Account.all().filter("hash =", hash).get()
        if not target:
            target = Account.all().filter("hashes =", hash).get()
        source = Account.all().filter("api_key =", self.request.get("api_key")).get()

        channel = Channel.all().filter("target =", target).filter("source =", source).get()
        approval_notice = None
        if not channel and source and target:
            channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
            channel.put()
            approval_notice = channel.get_approval_notice()
            channel.send_activation_email()

        if channel:
            notice = Notification(channel=channel, text=strip_tags(self.request.get("text")), icon=source.source_icon)
            for arg in ["title", "link", "icon", "sticky", "tags"]:
                value = strip_tags(self.request.get(arg, None))
                if value:
                    setattr(notice, arg, value)
            notice.put()

            # Increment the counter on the channel to represent number of notices sent
            channel.count += 1
            channel.put()

            if channel.status == "enabled":
                notice.dispatch()
                self.response.out.write("OK\n")

            elif channel.status == "pending":
                self.response.set_status(202)
                if approval_notice:
                    approval_notice.dispatch()
                    self.response.out.write("OK\n")
                else:
                    self.response.out.write("202 Pending approval")
            elif channel.status == "disabled":
                self.response.set_status(202)
                self.response.out.write("202 Accepted but disabled")
        else:
            self.error(404)
            self.response.out.write("404 Target or source not found")
開發者ID:Mondego,項目名稱:pyreco,代碼行數:46,代碼來源:allPythonContent.py

示例6: post

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
 def post(self): 
     hash = self.request.path.split('/')[-1]
     target = Account.all().filter('hash =', hash).get()
     if not target:
         target = Account.all().filter('hashes =', hash).get()
     source = Account.all().filter('api_key =', self.request.get('api_key')).get()
     
     channel = Channel.all().filter('target =', target).filter('source =', source).get()
     approval_notice = None
     if not channel and source and target:
         channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
         channel.put()
         approval_notice = channel.get_approval_notice()
         channel.send_activation_email()
         
     if channel:
         notice = Notification(channel=channel, text=strip_tags(self.request.get('text')), icon=source.source_icon)
         for arg in ['title', 'link', 'icon', 'sticky', 'tags']:
             value = strip_tags(self.request.get(arg, None))
             if value:
                 setattr(notice, arg, value)
         notice.put()
         
         # Increment the counter on the channel to represent number of notices sent
         channel.count += 1
         channel.put()
         
         if channel.status == 'enabled':
             self.response.out.write(notice.dispatch())
             
         elif channel.status == 'pending':
             self.response.set_status(202)
             if approval_notice:
                 self.response.out.write(":".join([channel.outlet.hash, approval_notice.to_json()]))
             else:
                 self.response.out.write("202 Pending approval")
         elif channel.status == 'disabled':
             self.response.set_status(202)
             self.response.out.write("202 Accepted but disabled")
     else:
         self.error(404)
         self.response.out.write("404 Target or source not found")
開發者ID:DFectuoso,項目名稱:notify-io,代碼行數:44,代碼來源:api.py

示例7: get

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
 def get(self):
     channels = [channel for channel in Channel.all().order('channel') 
                     if channel.channel.startswith('#')]
     self.response.out.write(render('templates/index.html', locals()))
開發者ID:sanyaade,項目名稱:ircarchive,代碼行數:6,代碼來源:archive.py

示例8: delete_all_channels

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
def delete_all_channels():
    while Channel.all().fetch(CHUNK):
        db.delete(Channel.all().fetch(CHUNK))
開發者ID:qmacro,項目名稱:coffeeshop,代碼行數:5,代碼來源:cutils.py

示例9: get

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
 def get(self):
     self.render("admin.html", boards=Channel.all())
開發者ID:GunioRobot,項目名稱:whitebrd.me,代碼行數:4,代碼來源:app.py

示例10: get

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import all [as 別名]
 def get(self):
     for chan in Channel.all().fetch(1000):
         channel.send_message(chan.key().name(),"hi")
         self.response.out.write(str(chan.key().name())+"<br>")
開發者ID:dillongrove,項目名稱:TheHackers,代碼行數:6,代碼來源:main.py


注:本文中的models.Channel.all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。