本文整理汇总了Python中views.get_list函数的典型用法代码示例。如果您正苦于以下问题:Python get_list函数的具体用法?Python get_list怎么用?Python get_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_list函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getAllListItems
def getAllListItems(self, username, list_id):
try:
# for someList in views.get_list_items(views.get_list(list_id)):
# if someList:
# print someList
return views.get_list_items(views.get_list(list_id))
except Exception, e:
print "List " + str(list_id) + " could not be found for user " + username
print e
return
开发者ID:Insight314,项目名称:GrocerEase,代码行数:11,代码来源:.~c9_invoke_eLAHqh.py
示例2: wrap
def wrap(environ, start_response):
ws = environ["wsgi.websocket"]
MonitorEvents(ws, directory_storage)
while not ws.closed:
message = ws.receive()
if message:
message = json.loads(message)
if message['action'] == 'check-login':
valid_user(ws, message['headers']['authorization'])
elif message['action'] == 'monitor-events' and valid_user(ws, message['headers']['authorization']):
user = get_user(message['headers']['authorization'])
views.monitor_events(ws, message['content'], directory_storage, user)
elif message['action'] == 'login':
views.auth(ws, message['content'])
elif message['action'] == 'get-snapshot' and valid_user(ws, message['headers']['authorization']):
views.get_snapshot(ws, directory_storage)
elif message['action'] == 'pull' and valid_user(ws, message['headers']['authorization']):
views.pull(ws, message['content'], directory_storage)
elif message['action'] == 'push' and valid_user(ws, message['headers']['authorization']):
user = get_user(message['headers']['authorization'])
views.push(ws, message['content'], directory_storage, user)
elif message['action'] == 'get-list' and valid_user(ws, message['headers']['authorization']):
views.get_list(ws, directory_storage)
开发者ID:patrickporto,项目名称:python-box,代码行数:23,代码来源:websocket_server.py
示例3: processEditSettingsRequest
def processEditSettingsRequest(self, request):
# Get the username
username = str(request.GET.__getitem__('username'))
print username
# Get the listId
listId = str(request.GET.__getitem__('listID'))
print listId
# Get the user's user_ids associated with the list
userIds = str(request.GET.__getitem__('listUsers'))
print userIds
# Get the lists tags, NOTE: same format as items [id,tag_name], also split the same way
tags = str(request.GET.__getitem__('listTags'))
print tags
#Should be able to split tags the same way we split items
split_tags = tags.split('|')
for t in split_tags:
t.split(',')
print t
dbAck = "Fail"
#TODO: Add and/or remove any users to and/or from the list
tmpList = views.get_list(listId)
#users add/remove
for user in userIds:
if not tmpList.list_users.get(id = user):
if views.add_user(listId,user) == 1:
dbAck = "Success"
else:
dbAck = "Fail"
elif tmpList.list_users.get(id = user):
if views.remove_user(listId,user) == 1:
dbAck = "Success"
else:
dbAck = "Fail"
#Tags add/remove
for tag in split_tags:
split_tag = tag.split(',')
if split_tag[0] == '-1':
if views.add_tag(listId,username,split_tag[1]) == 1:
dbAck = "Success"
else:
dbAck = "Fail"
if tmpList.list_tags(tag_id = int(split_tag[0])):
if views.remove_tag(listId,split_tag[1]) == 1:
dbAck = "Success"
else:
dbAck = "Fail"
return {
# 'list_ids': self.list_ids,
'Ack': "I got your shit yo",
}
开发者ID:Insight314,项目名称:GrocerEase,代码行数:61,代码来源:.~c9_invoke_eLAHqh.py
示例4: processEditDetailsRequest
def processEditDetailsRequest(self, request):
# Vars
list_id=str(request.GET.__getitem__('listID'))
list_name=str(request.GET.__getitem__('listName'))
list_items=request.GET.__getitem__('listItems')
print list_items
username = str(request.GET.__getitem__('username'))
dbAck = "Fail" # DB ack - Was DB update successful? ("Success/Fail")
# Get list in DB with listI_id and username
# Comapare to see if different
# Add new stuff to database
# Check if successful and store in dbAck
# If new list, add to db and retreive id
print list_id
if list_id == str(-1):
list_id = views.create_list(username, list_name)
tmpList = views.get_list(list_id)
# try:
# except:
# print "Couldn't get list"
try:
# tmpListItems = views.get_list_items(tmpList)
# Changes the name of the list if the name is different when compared
if tmpList.list_name != list_name:
if views.title_edit(list_id,list_name) == 1:
dbAck = "Success"
else:
print "Title edit failed"
dbAck = "Fail"
split_items = list_items.split('|')
for item in split_items:
item.split(',')
# print item
# Add any items to the database/list that are not already in it
for item in split_items:
split_item = item.split(',')
if split_item[0] == '-1':
# TODO
# Things are failing here....
if views.create_item(username,list_name,split_item[1],'','') == 1:
dbAck = "Success"
else:
print "Item creation failed"
dbAck = "Fail"
except:
print "Exception!!!"
print "Packaging edit list ack"
return self.packageListDetails(username, list_id, dbAck)
开发者ID:Insight314,项目名称:GrocerEase,代码行数:62,代码来源:.~c9_invoke_eLAHqh.py
示例5: processEditSettingsRequest
def processEditSettingsRequest(self, request):
print request
# Get the username
username = str(request.GET.__getitem__('username'))
print username
# Get the listId
try:
listId = str(request.GET.__getitem__('listID'))
print listId
except:
print "Edit request did not have listID"
# Get the user's usernames that are associated with the list (.split() with comma)
users = str(request.GET.__getitem__('listUsers'))
print "Users set: "
print users
# Get the lists tags (.split() with comma)
tags = str(request.GET.__getitem__('listTags'))
print "Tags set: "
print tags
# Get the user leave list flag (boolean)
leaveList = str(request.GET.__getitem__('leaveList'))
print "Leave list?: "
print leaveList
# This is what you had written, but we can't use the user_id, I've updated the
# request pulls above to reflect this
# # Get the user's user_ids associated with the list
# userIds = str(request.GET.__getitem__('listUsers'))
# print userIds
# # Get the lists tags, NOTE: same format as items [id,tag_name], also split the same way
# tags = str(request.GET.__getitem__('listTags'))
# print tags
#HOW TO COPY LISTS
'''Deep copy the list that needs to be copied
grab the items from the original list
copy the items and connect them to the newly copied list
'''
#Should be able to split tags the same way we split items
split_tags = tags.split(',')
print "tags given to me: "
print split_tags
split_users = users.split(',')
print "users on my end: "
print split_users
dbAck = "Fail"
#Gather list of users to be removed from the list
if listId:
tmpList = views.get_list(int(listId))
print "is it failing after this?"
tmpListUsers = tmpList.list_users.all()
print tmpListUsers
usersToRemove = []
alreadyAdded = []
tmp_list = []
for i in tmpListUsers:
tmp_list.append(str(i.username))
for i in tmp_list:
for j in split_users:
if str(i) == str(j):
alreadyAdded.append(str(j))
usersToRemove = set(tmp_list).symmetric_difference(alreadyAdded)
usersToRemove.remove(username)
print "users to remove"
print usersToRemove
#Gather list of tags to be removed from the list
tmpListTags = tmpList.list_tags.all()
print tmpListTags
tagsToRemove = []
tagsAlreadyAdded = []
tmp_tag_list = []
for i in tmpListTags:
tmp_tag_list.append(str(i.tag_name))
for i in tmp_tag_list:
for j in split_tags:
if str(i) == str(j):
tagsAlreadyAdded.append(str(j))
#.........这里部分代码省略.........
开发者ID:Insight314,项目名称:GrocerEase,代码行数:101,代码来源:widgets.py
示例6: processEditDetailsRequest
def processEditDetailsRequest(self, request):
# Extract request data
username = str(request.GET.__getitem__('username'))
# Get the list_id
try:
list_id = str(request.GET.__getitem__('listID'))
print list_id
except:
print "Edit requesst did not have listID"
list_name=str(request.GET.__getitem__('listName'))
list_items=str(request.GET.__getitem__('listItems'))
print "Added/Existing: "
print list_items
list_items_modified=str(request.GET.__getitem__('listItemsModified'))
print "Modified:"
print list_items_modified
list_items_removed=str(request.GET.__getitem__('listItemsRemoved'))
print "Removed: "
print list_items_removed
# TODO
# These need to be placed in the request from the front end
list_items_quantity= str(request.GET.__getitem__('listItemsQuantity'))
list_items_details= str(request.GET.__getitem__('listItemsDetails'))
list_items_checked_status = ""
print "These are the list_items: "
print list_items
list_items_modified = list_items_modified.split(',')
for i in list_items_modified:
if i == '':
list_items_modified.remove(i)
print "These are the items to modify: "
print list_items_modified
#split up the list items
split_items = list_items.split('|')
split_quantities = list_items_quantity.split('|')
split_details = list_items_details.split('|')
print "Split items: "
print split_items
print "Split quantities: "
print split_quantities
print "Split details"
print split_details
# Set initially as fail
dbAck = "Fail"
# Handle removing item
if list_items_removed != "":
split_items = list_items_removed.split(',')
if split_items:
for i in split_items:
if i != -1 and i != "":
try:
if views.remove_item(i) == 1:
dbAck = "Success"
else:
dbAck = "Fail"
except:
print "Remove item failed"
#Handle Creating an item
for item in split_items:
split_item = item.split(',')
if split_item[0] == '-1':
try:
print "creating item"
if views.create_item(username,list_id,split_item[1],'','') == 1:
dbAck = "Success"
else:
print "Item creation failed"
dbAck = "Fail"
except:
print "Editing list " + list_id + " item failed"
# Get list
tmpList = views.get_list(list_id)
# Changes the name of the list if the name is different when compared
if tmpList.list_name != list_name:
try:
if views.title_edit(list_id,list_name) == 1:
dbAck = "Success"
else:
print "Title edit failed"
dbAck = "Fail"
except:
#.........这里部分代码省略.........
开发者ID:Insight314,项目名称:GrocerEase,代码行数:101,代码来源:widgets.py
示例7: getAllUsersLists
# Error checking should be in views too, but truly not mandatory yet
def getAllUsersLists(self, username):
try:
return views.get_user_lists(username)
except Exception, e:
print "Username could not be found in the database"
print e
return
def getAllListItems(self, username, list_id):
try:
# for someList in views.get_list_items(views.get_list(list_id)):
for l
# print someList
return views.get_list_items(views.get_list(list_id))
except Exception, e:
print "List " + str(list_id) + " could not be found for user " + username
print e
return
# class LiveListWidget(Widget):
# dashboardHelper = DashboardHelper()
# title = ''
# more_info = ''
# updated_at = ''
# # Keeps lists information updated
# def getUpdates(self):
开发者ID:Insight314,项目名称:GrocerEase,代码行数:30,代码来源:.~c9_invoke_qbvhE1.py
注:本文中的views.get_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论