本文整理汇总了Python中pylons.session.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: login
def login(self):
""" Show login form.
"""
if request.method != 'POST':
return render('login.html')
# Verify username and password.
auth_fact = AuthFactory()
auth = auth_fact.get_auth(request.params.get('username'), request.params.get('password'), 'nipap')
if not auth.authenticate():
c.error = 'Invalid username or password'
return render('login.html')
# Mark user as logged in
session['user'] = auth.username
session['full_name'] = auth.full_name
session.save()
# Send user back to the page he originally wanted to get to
if session.get('path_before_login'):
log.error(session.get('path_before_login'))
redirect(session['path_before_login'])
else:
# if previous target is unknown just send the user to a welcome page
redirect(url(controller='schema', action='list'))
开发者ID:tobbakko,项目名称:NIPAP,代码行数:27,代码来源:auth.py
示例2: archive
def archive(self, page=1, direction='dsc',
order_by='timestamp', format=None):
"messages archive"
filters = session.get('filter_by', None)
num_items = session.get('msgs_num_items', 50)
if direction == 'dsc':
sort = desc(order_by)
else:
sort = order_by
messages = self._get_archived().order_by(sort)
msgcount = self._get_msg_count(True)
query = UserFilter(Session, c.user, messages, True)
countquery = UserFilter(Session, c.user, msgcount, True)
messages = query.filter()
msgcount = countquery.filter()
if filters:
dynq = DynaQuery(Archive, messages, filters)
dynmsgq = DynaQuery(Archive, msgcount, filters)
messages = dynq.generate()
msgcount = dynmsgq.generate()
c.order_by = order_by
c.direction = direction
msgcount = msgcount.count()
pages = paginate.Page(messages, page=int(page),
items_per_page=num_items,
item_count=msgcount)
if format == 'json':
response.headers['Content-Type'] = 'application/json'
data = convert_to_json(pages,
direction=direction,
order_by=order_by,
section=None)
return data
c.page = pages
return render('/messages/archive.html')
开发者ID:TetraAsh,项目名称:baruwa2,代码行数:35,代码来源:messages.py
示例3: more
def more(self, id=None):
# id will be something like d_ping_[ping.id]
# so, I want to get a ping where id > that one.
pid = id.split('_')[-1]
try:
pid = int(pid)
except:
log.debug("couldn't identify the ping %s "%id)
return ""
c.username = session.get('user')
c.fl_mod = session.get('mod',False)
for ping in PseudoPing.query().filter(
PseudoPing.fl_decided==False).filter(PseudoPing.id>pid).order_by(PseudoPing.id):
img = ping.Image_fromPing()
if img.in_pool():
c.ping=ping
c.image=ping.image
c.atts = img.all_atts()
return render('one_ping.mako')
else:
ping.fl_decided=True
ping.commit()
#Guess what. We're empty. get to bottom, go back to top. But this time, we need
# to send back the newest image, rather than the next oldest one.
if not self._reload():
return
return self.more(id)
开发者ID:wiredfool,项目名称:fmod,代码行数:29,代码来源:browse.py
示例4: autorize
def autorize():
loged_in = session.get("loged_in")
if loged_in:
email = session.get("email")
password = session.get("password")
pers = Session.query(Person).filter_by(email=email, password=password).first()
pers.last_activity = int(time.time())
Session.commit()
return True
if "email" and "password" in request.cookies:
email = request.cookies.get("email")
password = request.cookies.get("password")
elif request.method == "POST" and "email" in request.POST:
email = request.POST.get("password")
password = md5(request.POST.get("password"))
else:
return False
pers = Session.query(Person).filter_by(email=email, password=password).first()
if pers:
print "pers is ", pers
session["email"] = email
session["password"] = password
session["loged_in"] = True
session["name"] = pers.name
session["person_id"] = pers.id
session.save()
return True
return False
开发者ID:redvel2,项目名称:simple_pylon_chat,代码行数:28,代码来源:funcs.py
示例5: old_index
def old_index(self):
user_id = session.get('user_id')
c.user = session['user']
if not user_id:
raise Exception
# User Info
user = meta.Session.query(User).filter(User.id == session.get('user_id')).one()
accounts = meta.Session.query(Account).filter(sa.and_(Account.authkey_id != None , Account.user_id == session.get('user_id')));
dataString = []
accountHost = {}
for account in accounts:
if accountHost.get(account.resource.hostname, True):
accountDict = {}
accountDict['name'] = account.name
accountDict['hostname'] = account.resource.hostname
dataString.append(accountDict)
accountHost[account.resource.hostname] = False
## c.passwordLessAccount = dataString
meta.Session.close()
c.status = "index"
c.results = ""
#return render('/authentication/gsicreds/gsicreds.mako')
redirect(url(controller='gsicreds', action='gsicreds'))
开发者ID:sumukh210991,项目名称:Cyberweb,代码行数:27,代码来源:gsicreds.py
示例6: index
def index(self):
c.clients_quan = meta.Session.query(sidb.Client).count()
c.sorts = [('name', sidb.Client.name), ('prdate', sidb.Tmppricesstorage.price_date), ('tmpitems', sidb.Tmppricesstorage.tmpitems_quan)]
c.sort_col = request.GET.get("sort_field", 'name')
sort_field = dict(c.sorts).get(c.sort_col)
c.sort_rule = request.GET.get("sort_rule", 'asc')
sort_field = (c.sort_rule == 'desc' and sort_field.desc() or sort_field.asc())
for key, value in request.POST.iteritems():
if key in ['s_name', 's_country', 's_city']: session[key] = value
session.save()
c.s_name = session.has_key('s_name') and session.get('s_name') or u''
c.s_country = session.has_key('s_country') and session.get('s_country') or u''
c.s_city = session.has_key('s_city') and session.get('s_city') or u''
clients_list = meta.Session.query(sidb.Client, sidb.City, sidb.Country, sidb.Clientlogo, sidb.User, sidb.Tmppricesstorage.rid.label('storage_rid'),
sidb.Tmppricesstorage.tmpitems_quan, sidb.Tmppricesstorage.price_date).\
join((sidb.City, sidb.Client._cities_rid == sidb.City.rid)).\
join((sidb.Region, sidb.City._regions_rid == sidb.Region.rid)).\
join((sidb.Country, sidb.Region._countries_rid == sidb.Country.rid)).\
outerjoin((sidb.User, sidb.User._clients_rid == sidb.Client.rid)).\
outerjoin((sidb.Clientlogo, sidb.Clientlogo._clients_rid == sidb.Client.rid)).\
outerjoin((sidb.Tmppricesstorage, sidb.Tmppricesstorage._clients_rid == sidb.Client.rid)).\
group_by(sidb.Client.rid).order_by(sort_field)
if c.s_name: clients_list = clients_list.filter(sidb.Client.name.like('%'+c.s_name+'%'))
if c.s_country: clients_list = clients_list.filter(sidb.Country.name.like('%'+c.s_country+'%'))
if c.s_city: clients_list = clients_list.filter(sidb.City.name.like('%'+c.s_city+'%'))
page = paginate.Page(clients_list, items_per_page=15, page=request.GET.get("page", 1), sort_col=c.sort_col, sort_rule=c.sort_rule)
c.pager = page.pager()
c.clients_list = page.items
c.subtempl = 'clients_list'
return render('be/layouts/clients.html')
开发者ID:whocarez,项目名称:saleinform,代码行数:31,代码来源:clients.py
示例7: show
def show(name):
if session.get(ALLKEY, False):
return False
elif session.get(ONEKEY % name):
return False
else:
return True
开发者ID:JonnyWalker,项目名称:adhocracy,代码行数:7,代码来源:tutorial.py
示例8: openid_register
def openid_register(self):
openid_url = session.get('openid_identity')
if not openid_url:
redirect(url('account_register'))
c.openid = session.get('openid_identity')
c.defaults = {}
return render('/accounts/register.mako')
开发者ID:Pylons,项目名称:kai,代码行数:7,代码来源:accounts.py
示例9: index
def index(self):
gd_client = gdata.photos.service.PhotosService()
#token = request.GET.getone('token')
parameters = cgi.FieldStorage()
token = parameters['token']
gd_client.auth_token = token
gd_client.UpgradeToSessionToken()
session['picasa_token'] = token
session.save()
if session.get('user_id'):
# a user is already logged in
user = Session.query(User).filter_by(id=session.get('user_id')).first()
else:
# the user is not already logged in, let's see if they have
# already created an account before
user = Session.query(User).filter_by(picasa_token=token).first()
if user:
user.picasa_token = token
Session.commit()
else:
# the user does not have an account. We need to create a new one
# for them.
user = User(picasa_token=token)
Session.add(user)
Session.commit()
user = Session.query(User).filter_by(picasa_token=picasa_token).first()
session['user_id'] = user.id
session['picasa_token'] = token
session.save()
log.info("Logged in user %s", user)
redirect(url('index'))
开发者ID:gavro,项目名称:thephotosync,代码行数:35,代码来源:picasaauth.py
示例10: __before__
def __before__(self, action, **params):
c.user = session.get('user')
c.messages = session.get('messages', [])
c.errors = session.get('errors', [])
session['messages'] = []
session['errors'] = []
session.save()
开发者ID:jtacoma,项目名称:geometriki,代码行数:7,代码来源:base.py
示例11: set_pos_zoom
def set_pos_zoom(self,latlon=None,zoom=None):
#print "Setting pos to %s"%(latlon,)
if latlon==None:
assert zoom==None
zoomlevel=session.get('zoom',None)
if zoomlevel==None:
zoomlevel=5
merc_x,merc_y=mapper.latlon2merc((58,18),zoomlevel)
else:
merc_x,merc_y=session['last_pos']
else:
assert zoom!=None
zoomlevel=zoom
if zoomlevel<5:
zoomlevel=5
if session.get('mapvariant',None)=='elev':
if zoomlevel>8: zoomlevel=8
else:
if zoomlevel>13: zoomlevel=13
merc_x,merc_y=mapper.latlon2merc(latlon,zoomlevel)
merc_limx1,merc_limy1,merc_limx2,merc_limy2=merc_limits(zoomlevel,conservative=False,hd=True)
if merc_x>merc_limx2: merc_x=merc_limx2
if merc_y>merc_limy2: merc_y=merc_limy2
if merc_x<merc_limx1: merc_x=merc_limx1
if merc_y<merc_limy1: merc_y=merc_limy1
session['last_pos']=(merc_x,merc_y)
session['zoom']=zoomlevel
print "Setting pos to %s, zoom = %d"%(mapper.merc2latlon(session['last_pos'],zoomlevel),zoomlevel)
session.save()
开发者ID:avl,项目名称:SwFlightPlanner,代码行数:32,代码来源:mapview.py
示例12: if_findpasswd
def if_findpasswd(self):
servername = session.get('servername', "NULL")
username = session.get('username', "NULL")
if servername!="NULL":
c.servername = servername
if username!="NULL":
c.username=username
username = request.params.get('username')
newpasswd=request.params.get('newpasswd')
newpasswdrepeat=request.params.get('newpasswdrepeat')
if newpasswd != newpasswdrepeat:
c.errorMsg = "两次输入密码不相同,请重新输入"
return render("result_find_passwd.mako")
if len(base64.decodestring(newpasswd))<6 or len(base64.decodestring(newpasswd))>64:
c.errorMsg="密码长度必须在6-64之间"
return render("result_find_passwd.mako")
try:
con = MySQLdb.connect(host = g.dbhost, user = g.dbuser, passwd = g.dbpasswd, db = g.dbdb, port = g.dbport, charset = "utf8")
cur = con.cursor()
cur.execute("update users set password=%s where username =%s", (newpasswd,username))
con.commit()
except MySQLdb.Error as e:
print "mysql error %d: %s" %(e.args[0], e.args[1])
c.errorMsg = "往数据库插入新密码错误"
finally:
if con != None:
con.close()
return render("index.mako")
开发者ID:gh289054531,项目名称:xppxyy,代码行数:28,代码来源:userRegister.py
示例13: _gccom_jobs
def _gccom_jobs(self, model_key, mode):
c.jobstate = 'build'
c.jobmsg = 'build: setting up the job. before submission.'
c.model_key = model_key
c.mode = mode
c.error_flash = None
if session.has_key('error_flash'):
c.error_flash = session['error_flash']
try: del session['error_flash']
except Exception as _: pass
c.jobname = '%s_%s' % (model_key, mode)
c.cwuser = session.get('user','user')
c.acct = Gccom.gccom_comm_acct
c.model_param_hdrs = Gccom.model_params['hdrs']
c.model_params = Gccom.model_params[c.model_key]
c.model_desc = str(Gccom.model_info[c.model_key]['desc'])
c.title = 'GCOM %s Simulation: Model:%s for JobName: %s' % (
c.mode, str(c.model_desc), c.jobname)
c.resources = h.get_user_resources(session.get('user_id'))
c.hostname = c.resources.keys()[0] if c.resources else '' #used to init/set default host; reset later
c.grid_key = Gccom.model_info[c.model_key]['grid_key']
c.grid_imax = Gccom.bath_grid[c.grid_key]['IMax']
c.grid_jmax = Gccom.bath_grid[c.grid_key]['JMax']
c.grid_kmax = Gccom.bath_grid[c.grid_key]['KMax']
c.grid_name = Gccom.bath_grid[c.grid_key]['name']
c.grid_fname = Gccom.bath_grid[c.grid_key]['fname']
log.info( 'GCOM:: gccom_jobs: building form data for model_key=%s, desc=%s, jobstate= %s, jobname= %s, gridname= %s, gridfnam=%s' % (c.model_key, c.model_desc,c.jobstate, c.jobname, c.grid_name, c.grid_fname))
return render('/gcem/gccom/app_' + c.mode.lower() + '.mako')
开发者ID:sumukh210991,项目名称:Cyberweb,代码行数:30,代码来源:gccom.py
示例14: BaseController_UpdateUserHeader
def BaseController_UpdateUserHeader(self):
# Is the user already logged-in?
if session.get("UserName"):
# User info
c.user_login = "Log Out"
c.user_loginurl = "logout"
c.user_pref = "Preferences"
c.user_prefurl = "preferences"
c.user_name = session.get("UserName")
c.user_points = session.get("UserPoints")
c.user_icon = session.get("UserIconID")
c.is_admin = session.get("IsAdmin")
# Nope! Default to basic URLs
else:
# User info
c.user_login = "Log In"
c.user_loginurl = "login"
c.user_pref = "Register"
c.user_prefurl = "register"
c.user_name = ""
c.user_points = 0
c.user_icon = 0
c.is_admin = False
# Top-bar directory info
c.group_name = ""
c.group_id = -1
c.challenge_name = ""
c.challenge_id = -1
开发者ID:nint22,项目名称:CoreCodex,代码行数:33,代码来源:base.py
示例15: get
def get(self, domain):
username = request.params.get('username')
userid = request.params.get('userid')
group = request.params.get('group', None)
startIndex = int(request.params.get('startindex','0'))
maxResults = int(request.params.get('maxresults','25'))
keys = session.get('account_keys', '').split(',')
if not keys:
error = {'provider': domain,
'message': "no user session exists, auth required",
'status': 401
}
return {'result': None, 'error': error}
provider = get_provider(domain)
# even if we have a session key, we must have an account for that
# user for the specified domain.
acct = None
for k in keys:
a = session.get(k)
if a and a.get('domain') == domain and (not username or a.get('username')==username and not userid or a.get('userid')==userid):
acct = a
break
if not acct:
error = {'provider': domain,
'message': "not logged in or no user account for that domain",
'status': 401
}
return {'result': None, 'error': error}
result, error = provider.api(acct).getcontacts(startIndex, maxResults, group)
return {'result': result, 'error': error}
开发者ID:LeonardoXavier,项目名称:f1,代码行数:32,代码来源:contacts.py
示例16: index
def index(self):
c.results=[]
c.username = session.get('user')
c.fl_mod = session.get('mod',False)
images = {}
flSave = False
for ping in PseudoPing.query().filter(PseudoPing.fl_decided==False).order_by(PseudoPing.id):
if not images.get(ping.image):
img = ping.Image_fromPing()
if img.in_pool():
images[ping.image] = True
c.results.append(ping)
if len(c.results) >= 2:
break
else:
flSave=True
ping.fl_decided=True
if not len(c.results):
if self.reload():
return self.index()
if flSave: ping.commit()
return render('ping.mako')
开发者ID:wiredfool,项目名称:fmod,代码行数:25,代码来源:browse.py
示例17: move_images
def move_images(self, id=1):
# os.rename("J:/Pictures/1.jpg", "J:/Pictures/Marked/1.jpg")
path = ""
move_to_path = "Marked" # Default location
to_be_marked = request.POST.getall("Mark")
id = int(id)
if session.get("directory"):
# If they're in a sub directory use it
path = str(session.get("directory")).replace("\\", "/")
if (
session.get("destination") or session.get("destination") == ""
): # because of the parent path is a blank string
move_to_path = str(session.get("destination"))
picture_list = os.listdir("%s%s." % (g.picture_path, path))
picture_list.sort()
if not os.access("%s%s" % (g.picture_path, move_to_path), os.F_OK):
os.mkdir("%s%s" % (g.picture_path, move_to_path))
for img in [picture_list[int(a)] for a in to_be_marked]:
# return "move \"%s%s%s\" \"%sMarked/\"" % (g.picture_path, path, img, g.picture_path)
os.rename("%s%s%s" % (g.picture_path, path, img), "%s%s/%s" % (g.picture_path, move_to_path, img))
return redirect_to(action="index")
开发者ID:tdyhacker,项目名称:pythonexploration,代码行数:27,代码来源:pictures.py
示例18: _moneyOutSubmit_factura
def _moneyOutSubmit_factura(self):
''' Обработка заявки на вывод средств посредством счёт-фактуры '''
schema = MoneyOutForm_factura()
if not session.get('factura_file_name'):
return h.JSON({'error': True,
'msg': u'Не загружен файл счёт-фактуры!',
'ok': False})
try:
form = schema.to_python(dict(request.params))
except formencode.Invalid as error:
errorMessage = '<br/>\n'.join(
[x.msg for x in error.error_dict.values()])
return h.JSON({'error': True, 'msg': errorMessage, 'ok': False})
req = model.InvoiceMoneyOutRequest()
req.account = model.Account(c.user)
req.ip = request.environ['REMOTE_ADDR']
req.summ = form.get('moneyOut_facturaSumm')
req.contacts = form.get('moneyOut_facturaContact')
req.phone = form.get('moneyOut_facturaPhone')
req.invoice_filename = session.get('factura_file_name')
req.comment = form.get('moneyOut_facturaComment', '')
try:
req.save()
req.send_confirmation_email()
except model.MoneyOutRequest.NotEnoughMoney:
return h.JSON({'error': True,
'msg': u'Недостаточно средств для вывода!',
'ok': False})
except Exception as ex:
log.debug(unicode(ex))
return h.JSON({'error': False,
'ok': True,
'msg': u'Заявка успешно принята'})
开发者ID:testTemtProj,项目名称:OLD_PROJECT,代码行数:34,代码来源:private.py
示例19: __before__
def __before__(self):
c.admin_user = session.get('admin_user')
c.admin_username = session.get('admin_username')
super(PermissionsController, self).__before__()
self.repo_perms_choices = [('repository.none', _('None'),),
('repository.read', _('Read'),),
('repository.write', _('Write'),),
('repository.admin', _('Admin'),)]
self.group_perms_choices = [('group.none', _('None'),),
('group.read', _('Read'),),
('group.write', _('Write'),),
('group.admin', _('Admin'),)]
self.register_choices = [
('hg.register.none',
_('Disabled')),
('hg.register.manual_activate',
_('Allowed with manual account activation')),
('hg.register.auto_activate',
_('Allowed with automatic account activation')), ]
self.create_choices = [('hg.create.none', _('Disabled')),
('hg.create.repository', _('Enabled'))]
self.fork_choices = [('hg.fork.none', _('Disabled')),
('hg.fork.repository', _('Enabled'))]
# set the global template variables
c.repo_perms_choices = self.repo_perms_choices
c.group_perms_choices = self.group_perms_choices
c.register_choices = self.register_choices
c.create_choices = self.create_choices
c.fork_choices = self.fork_choices
开发者ID:jeffjirsa,项目名称:rhodecode,代码行数:33,代码来源:permissions.py
示例20: index
def index(self):
servername = session.get('servername', "NULL")
if servername != "NULL":
c.servername = servername
username = session.get('username', "NULL")
if username != "NULL":
c.username=username
return render('/index.mako')
开发者ID:gh289054531,项目名称:xppxyy,代码行数:8,代码来源:index.py
注:本文中的pylons.session.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论