本文整理汇总了Python中couchdb.Server.view方法的典型用法代码示例。如果您正苦于以下问题:Python Server.view方法的具体用法?Python Server.view怎么用?Python Server.view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchdb.Server
的用法示例。
在下文中一共展示了Server.view方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OnAddTag
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import view [as 别名]
def OnAddTag( self, event ):
bl = Server(self.URL)[BLOG]
p = Post.load(bl, self.blogpost)
tags = [ str(x.key) for x in bl.view("all/tags", group = True) if str(x.key) not in map(str,p.tags) ]
if tags:
dialog = wx.SingleChoiceDialog(None, "Choose a Tag or press Cancel to type it", "Tags", tags)
tag = ""
if dialog.ShowModal() == wx.ID_OK:
tag = dialog.GetStringSelection()
else:
tag = wx.GetTextFromUser( "Type a Tag ", "Tag")
if tag:
tag = tag.upper()
dialog.Destroy()
if tag:
bl = Server(self.URL)[BLOG]
p = Post.load(bl, self.blogpost)
tagList = p.tags
tagList.append(tag)
tagList = list(set(tagList))
tagList.sort()
p.tags = tagList
p.store(bl)
#event = wx.CommandEvent( wx.wxEVT_COMMAND_LIST_ITEM_SELECTED, self.list.GetId())
#self.GetEventHandler().ProcessEvent( event )
self.OnLCtrl(None)
示例2: OnAttachments
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import view [as 别名]
def OnAttachments( self, event):
bl = Server(self.URL)[BLOG]
view = "attachments"
attachmentsview= bl.view("all/{0}".format(view))
attachments = []
attachment_doc_ids = []
for doc in attachmentsview:
attachments.append("{0} - {1}".format(doc.key, doc.value[1]))
attachment_doc_ids.append( doc.value[0])
if len(attachments) > 0:
dialog = wx.SingleChoiceDialog(None, "Choose an attachment", "Attachments", attachments)
attachment = ""
if dialog.ShowModal() == wx.ID_OK:
attachment = dialog.GetStringSelection()
docid = attachment_doc_ids[dialog.GetSelection()]
dialog.Destroy()
示例3: BuildListCtrl
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import view [as 别名]
def BuildListCtrl(self):
"""
Getting information from a couchdb database using a view
and populating a wx.ListCtrl
"""
if not self.user.username:
return
try:
self.list
self.list.ClearAll()
except:
pass
title = "BlogId Date Author Subject"
for i, colTitle in enumerate(title.split(" ")):
self.list.InsertColumn(i, colTitle)
bl = Server(self.URL)[BLOG]
posts = []
view = "by_date"
bg1 = wx.Colour(239,235,239)
bg2 = wx.Colour(255, 207,99)
bg3 = wx.Colour(0xCC,0xFF,0xFF)
blogview = bl.view("all/{0}".format(view), descending = True)
for doc in blogview:
index = self.list.InsertStringItem(sys.maxint, doc.value["_id"])
bgcolor = bg1
if index % 2 == 0:
bgcolor = bg2
try:
if self.tag != "GENERAL" and self.tag in doc.value["tags"]:
bgcolor = bg3
except:
pass
self.list.SetItemBackgroundColour( index , bgcolor )
self.list.SetStringItem( index, 1, doc.value["date"])
self.list.SetStringItem( index, 2, doc.value["author"])
self.list.SetStringItem( index, 3, doc.value["subject"])
for i in range(4):
self.list.SetColumnWidth(i, wx.LIST_AUTOSIZE)
self.Refresh()
示例4: OnTags
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import view [as 别名]
def OnTags( self, event):
bl = Server(self.URL)[BLOG]
tags = [ x.key for x in bl.view("all/tags", group = True)]
if tags:
default_value = "GENERAL"
try:
default_value = self.tag
except:
pass
dialog = wx.SingleChoiceDialog(None, "Choose a Tag", "Tags", tags)
try:
dialog.SetSelection(tags.index( default_value ))
except:
pass
if dialog.ShowModal() == wx.ID_OK:
self.tag = dialog.GetStringSelection()
self.BuildListCtrl()
dialog.Destroy()
示例5: OnAuthors
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import view [as 别名]
def OnAuthors( self, event):
bl = Server(self.URL)[BLOG]
view = "by_author"
by_author_view = bl.view("all/{0}".format(view))
authors = []
for doc in by_author_view:
authors.append( doc.key )
authors = list(set(authors))
authors.sort()
if len(authors) > 0:
dialog = wx.SingleChoiceDialog(None, "Choose an author", "Authors", authors)
author = ""
if dialog.ShowModal() == wx.ID_OK:
author = dialog.GetStringSelection()
dialog.Destroy()
try:
self.author = author
self.BuildListCtrl()
except:
pass
示例6: isuserp
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import view [as 别名]
def isuserp(self, user, pw):
db = Server("http://localhost:8888/")['unit_tasks']
if len(list(db.view('_design/users/isvalid',
key=[user, self.hash(pw)]))) == 1:
return "1"
return "0"