本文整理汇总了Python中web.select函数的典型用法代码示例。如果您正苦于以下问题:Python select函数的具体用法?Python select怎么用?Python select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: select
def select(self, cls, where=None, vars=None, order=None, group=None,
limit=None, offset=None):
cls = self.get_cls_type(cls)
if cls._pm_where_ is not None:
where += " and " + cls._pm_where_
self.syslog.debug("Select SQL:" + web.select(cls._pm_db_table_,
vars=vars,
where=where,
limit=limit,
order=order,
offset=offset,
group=group, _test=True))
results = web.select(cls._pm_db_table_,
vars=vars,
where=where,
limit=limit,
order=order,
offset=offset,
group=group)
#print results
return self._mapping_to_model(cls, results)
示例2: testWrongQuery
def testWrongQuery(self):
# It should be possible to run a correct query after getting an error from a wrong query.
try:
web.select('wrong_table')
except:
pass
web.select('person')
示例3: get
def get(self, id, providerName):
ret = {}
id = self._getLocalId(id, providerName)[0].id
for i in web.select('places_description', where='id=%s' % id):
ret[i.name] = i.value
ret['ESTADO_ZAUBER'] = web.select('places', what='state', where='id=%s' % id)[0].state
return ret
示例4: get_revision
def get_revision(page_id, revision=None):
if revision:
try:
revision = int(revision)
except ValueError:
return None
if revision is not None:
d = web.select('revisions', where='page_id=$page_id AND revision=$revision', limit=1, vars=locals())
else:
d = web.select('revisions', where='page_id=$page_id and revision > 0', order='revision DESC', limit=1, vars=locals())
return (d and d[0]) or None
示例5: GET
def GET(self, comparison_name):
"""show a form to create a location"""
if comparison_name == 'nomap':
#showing a list of all locations withour a map
events = web.select(tables='events', what='*', group='place', order='time_start', where='not cancelled and duplicateof is null and id_location is null' )
print render.base(render.show_locations( events))
elif comparison_name:
#updating a specific location
location = [l for l in web.select(tables='locations', where="comparison_name = '%s'" % comparison_name)]
if len(location):
print render.base(render.manage_location(location[0].longitude,location[0].latitude, location[0].originalmapurl, location[0].id, comparison_name))
else:
print render.base(render.manage_location(None, None, None, None, comparison_name))
else:
print "not implemented yet"
示例6: GET
def GET(self, year):
print render.year(
G,
year,
web.select('shirts',
where='shirts.year = %s' % web.db.sqlify(year),
order='college, variant'))
示例7: getperson
def getperson(id):
person = web.select("people", where="id=%s" % web.sqlquote(id), limit=1)
if person:
return person[0]
else:
return None
示例8: getthread
def getthread(id):
thread = web.select('threads', where='id=%s' % web.sqlquote(id), limit=1)
if thread:
return thread[0]
else:
return None
示例9: view
def view(self, found, model, providerName, id):
lid = scrappers[providerName].local(id)
comments = web.select('places_forum', where='idplace=%d' % lid,
order='date asc')
print render.header()
print render.someplace(model, comments, providerName, id)
print render.footer()
示例10: getuser
def getuser(email, password):
""" return a user object if the email and passwords match an entry in the db.
"""
user = web.select('people', where='email=%s and password=%s' % (web.sqlquote(email), web.sqlquote(password)), limit=1)
if user:
return user[0]
else:
return None
示例11: get_events
def get_events(**params):
if not params.has_key("tables"):
params["tables"] = "events left join locations on events.id_location = locations.id"
if not params.has_key("what"):
params[
"what"
] = "events.*, locations.longitude as longitude, locations.latitude as latitude, locations.originalmapurl as mapurl, locations.id as loc_id"
return web.select(**params)
示例12: find
def find(id):
# TODO getthread has the same functionality. replace this with getthread.
thread = web.select('threads', where='id=%s' % web.sqlquote(id), limit=1)
if thread:
return thread[0]
else:
return None
示例13: guest
def guest():
""" returns our default guest user for those that aren't logged in
when you want to chat, you still need to create a new guest user, but just for
browsing we'll use thi temp user. this allows use to program user names and id
into the templates without having to worry about there not being a user present.
"""
return web.select('people', where='email=%s' % web.sqlquote('[email protected]'))[0]
示例14: GET
def GET(self, tag):
bookmarks = []
bs = list(web.select("bookmarks", order="created desc"))
for b in bs:
b.tags = b.tags.split()
if tag in b.tags:
bookmarks.append(b)
empty = (len(bookmarks) == 0)
web.render('search.html')
示例15: select
def select(cls, _test=False, **kwargs):
""" Select and return multiple rows from the database via the web.py
SQL-like query given via kwargs. For example:
>>> print UserTest.select(where='username LIKE $u', vars={'u': 'jo%'}, order='username', limit=5, _test=True)
SELECT * FROM users WHERE username LIKE 'jo%' ORDER BY username LIMIT 5
"""
select = web.select(cls._table, _test=_test, **kwargs)
return select if _test else [cls(row, _fromdb=True) for row in select]