本文整理汇总了Python中models.Group.query方法的典型用法代码示例。如果您正苦于以下问题:Python Group.query方法的具体用法?Python Group.query怎么用?Python Group.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Group
的用法示例。
在下文中一共展示了Group.query方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_group
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def _get_group(self, group_id=None, group_name=None):
if group_id is not None:
return Group.query(
ndb.AND(
Group.unique_id == group_id
)
).get()
else:
return Group.query(
ndb.AND(
Group.name == group_name,
Group.user == self.user_key
)
).get()
示例2: check_group
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def check_group(self, *args, **kwargs):
logging.info('check_group')
if not 'groupname' in kwargs:
logging.error('No groupname although expected')
self.display_message('No groupname provided.')
groupName = kwargs['groupname']
print(groupName)
query = Group.query(Group.name == groupName)
groups = query.fetch()
if len(groups) == 1:
thisGroup = groups[0]
else:
thisGroup = None
if not thisGroup:
logging.error('Group "{groupname}" not found'.format(groupname = groupName))
self.redirect(self.uri_for('home'), abort=True)
self.group = thisGroup
if handler:
return handler(self, *args, **kwargs)
return handler
示例3: post
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def post(self, *args, **kwargs):
groupname = kwargs['groupname']
query = Group.query(Group.name == groupname)
groups = query.fetch()
if len(groups) == 1:
thisGroup = groups[0]
else:
thisGroup = None
user = self.user
print(user)
if user:
memberships = GroupMembership.query(GroupMembership.userKey == user.key,
GroupMembership.groupKey == thisGroup.key).fetch()
if len(memberships) == 1:
membership = memberships[0]
print(membership)
else:
self.display_message('You can only post if you\'re a member')
return
if user:
print(self.request.get('message'))
newMessage = Message(parent=thisGroup.key, userKey=user.key, text=self.request.get('message'))
newMessage.put()
self.redirect('/{groupname}/show'.format(groupname = groupname))
示例4: get
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def get(self):
"""Renders the system setup page"""
user_id = users.get_current_user().user_id()
#TODO: Add multiple group functionality
group_list = Group.query(Group.owner_id == user_id).fetch(1)
if group_list:
self.redirect('/')
return
self.render_template('setupdevice.html')
示例5: post
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def post(self):
"""Claims the device registration number provided as the user's"""
registration_code = self.request.get('registration_code')
query = Group.query(Group.registration_code == registration_code)
group_list = query.fetch(1)
if not group_list:
self.render_template('setupdevice.html', {'error': True})
else:
group = group_list[0]
group.registered = True
group.owner_id = users.get_current_user().user_id()
group.put()
self.redirect('/')
#TODO: Redirect to page that waits about 5-10 seconds then redirects
示例6: get
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def get(self):
user, logout = check_user(users.get_current_user())
if user:
u = []
more = True
cursor = None
while more:
d, curs, more = Group.query(
Group.active == True).order(
-Group.when).fetch_page(
10, start_cursor=cursor)
for ditem in d:
u.append(ditem.to_dict())
else:
u = []
self.response.out.headers['Content-Type'] = 'application/json'
self.response.out.write(json.dumps({'data':u}))
示例7: post
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def post(self):
# logging.info("Inside the DB handler stufff now in group.")
# solo_hacker_name = self.request.get("name")
# solo_hacker_slackid = self.request.get("slackid")
solo_hacker_skills = json.loads(self.request.get("skill"))
# logging.warning(solo_hacker_skills)
new_hacker = Hacker (
hacker_name = self.request.get("name"),
slack_id = self.request.get("slackid"),
skills = json.loads(self.request.get("skill"))
)
new_hacker.put()
groups_matching = Group.query(Group.skills_needed.IN(solo_hacker_skills))
for matchedgroup in groups_matching :
logging.warning(matchedgroup)
GROUPS_ENTRIES.append({'groupname': matchedgroup.group_name,'description' : matchedgroup.description,'skills_needed' : matchedgroup.skills_needed})
示例8: get
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def get(self):
groupsQuery = Group.query()
groups = groupsQuery.fetch()
membershipQuery = GroupMembership.query(GroupMembership.userKey==self.user.key)
memberships = membershipQuery.fetch()
membershipStatus = []
for group in groups:
foundMembership = False
for membership in memberships:
if membership.groupKey == group.key:
foundMembership = True
break
membershipStatus.append(foundMembership)
params = {'groupsAndMemberships': zip(groups, membershipStatus)}
self.render_template('listgroups.html', params=params)
示例9: get_groups_for_user
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
def get_groups_for_user(self):
return Group.query(Group.user == self.user_key).fetch()