本文整理汇总了Python中tg.session.save函数的典型用法代码示例。如果您正苦于以下问题:Python save函数的具体用法?Python save怎么用?Python save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: customer_fetch
def customer_fetch(self, page, rows, sidx, sord, cmp_id, **kw):
''' Function called on AJAX request made by FlexGrid
Fetch data from DB, return the list of rows + total + current page
'''
# Try and use grid preference
grid_rows = session.get('grid_rows', None)
if rows=='-1': # Default value
rows = grid_rows if grid_rows is not None else 25
# Save grid preference
session['grid_rows'] = rows
session.save()
rows = int(rows)
try:
page = int(page)
rows = int(rows)
offset = (page-1) * int(rows)
except:
offset = 0
page = 1
rows = 25
data = DBSession.query(Customer). \
filter(Customer.cmp_id==cmp_id). \
filter(Customer.active==True)
total = 1 + data.count() / rows
column = getattr(Customer, sidx if sidx!='name' else 'lastname')
data = data.order_by(getattr(column,sord)()).offset(offset).limit(rows)
rows = [ { 'id' : a.cust_id, 'cell': customer_row(a) } for a in data ]
return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:33,代码来源:cc_outcall.py
示例2: check_tequila
def check_tequila(self):
if not 'repoze.who.identity' in request.environ:
session['check_tequila'] = True
session.save()
raise redirect(url('/login'))
else:
raise redirect('/search')
开发者ID:bbcf,项目名称:biorepo,代码行数:7,代码来源:public.py
示例3: fetch
def fetch(self, page, rows, sidx='lastname', sord='asc', _search='false',
searchOper=None, searchField=None, searchString=None, **kw):
''' Function called on AJAX request made by Grid JS component
Fetch data from DB, return the list of rows + total + current page
'''
# Try and use grid preference
grid_rows = session.get('grid_rows', None)
if rows=='-1': # Default value
rows = grid_rows if grid_rows is not None else 25
# Save grid preference
session['grid_rows'] = rows
session.save()
rows = int(rows)
try:
page = int(page)
rows = int(rows)
offset = (page-1) * rows
except:
offset = 0
page = 1
rows = 25
pb = sorted(phonebook_list(request.identity['user'].user_id,
searchOper,
searchField,
searchString),
key = itemgetter(sidx),
reverse = True if sord=='desc' else False)
total = len(pb)/rows+1
data = [ { 'id' : b['pb_id'], 'cell': row(b) } for b in pb[offset:offset+rows] ]
return dict(page=page, total=total, rows=data)
开发者ID:sysnux,项目名称:astportal,代码行数:35,代码来源:phonebook.py
示例4: index
def index(self):
reload(sys);
sys.setdefaultencoding("utf-8");
print "Index maintenance";
"""Handle the front-page."""
set_lang("th");
session['lang'] = "th";
session.save();
userid = "";
sectionid ="";
level = "1"; #Admin; 0 user;
if request.identity:
userid = request.identity['repoze.who.userid'];
section = UserRiskSection.getByUserName(userid);
if(section):
sectionid = section.risk_section_id;
section = RiskSection.listBySectionbyId(sectionid);
if(section):
userid = section.description;
level = "0";
print "section : " + str(sectionid);
else:
#redirect('/computer/add');
pass;
log.info("computer");
#print "user : " + str(userid);
return dict(page='computer',user=str(userid),sectionid=str(sectionid),level=level);
开发者ID:tongpa,项目名称:bantakCom,代码行数:32,代码来源:computermanagecontroller.py
示例5: extern_create
def extern_create(self, *args, **kw):
'''
used to upload a file from another web application
kw must contain :
:file_path == file path
:description == verbose to explain some stuff
:project_name == name of the external web app
:sample_name == name of the plugin web app / or another thing
:sample_type == name of the webapp (and type of analysis if asked)
kw can contain :
:project_description == HTSstation project description
:task_id == task_id for BioScript files from HTSstation/BioScript
'''
#test if the essential kw are here
essential_kws = ["file_path", "description", "project_name", "sample_name", "sample_type"]
missing_kw = []
for k in essential_kws:
if k not in kw.keys():
missing_kw.append(k)
if len(missing_kw) > 0:
flash(str(missing_kw) + " not found in keywords. External application error.", "error")
raise redirect(url("/"))
session['backup_kw'] = kw
session.save()
#test if the user who was redirected on BioRepo is logged in it
if not 'repoze.who.identity' in request.environ:
session['extern_meas'] = True
session.save()
raise redirect(url('/login'))
else:
raise redirect(url('/measurements/external_add'))
开发者ID:bbcf,项目名称:biorepo,代码行数:33,代码来源:public.py
示例6: post_login
def post_login(self,userid,came_from=url('/')):
"""
Redirect the user to the initially requested page on successful
authentication or redirect her back to the login page if login failed.
"""
result=''
if not userid:
result = "{success:false,msg:'session expired'}"
return result
u=User.by_user_name(to_unicode(userid))
g=Group.by_group_name(to_unicode('adminGroup'))
auth=AuthorizationService()
auth.user=u
session['username']=u.user_name
session['user_firstname']=u.firstname
session['has_adv_priv']=tg.config.get(constants.ADVANCED_PRIVILEGES)
session['PAGEREFRESHINTERVAL']=tg.config.get(constants.PAGEREFRESHINTERVAL)
session['TASKPANEREFRESH']=tg.config.get(constants.TASKPANEREFRESH)
session['userid']=userid
session['auth']=auth
session['edition_string']=get_edition_string()
session['version']=get_version()
is_admin = u.has_group(g)
session['is_admin']=is_admin
session.save()
TopCache().delete_usercache(auth)
result = "{success:true}"
return result
开发者ID:RDTeam,项目名称:openconvirt,代码行数:32,代码来源:ControllerImpl.py
示例7: nuevo
def nuevo(self, *args, **kw):
"""Despliega una pagina donde se completan los campos para crear una nueva linea base"""
if not 'fase' in kw:
flash(('Direccion no valida'), 'error')
raise redirect("/index")
try:
fase, navegacion = self.getNavegacionFromIdFase(kw['fase'])
except:
flash(('Direccion no valida'), 'error')
raise redirect("/index")
if not(Secure().FiltrarByFase(int(kw['fase']),'crear_lb')):
flash(('USTED NO CUENTA CON PERMISOS SUFICIENTES'), 'error')
raise redirect("/index")
tmpl_context.widget = self.table_item
self.table_filler_item.init(fase)
values = self.table_filler_item.get_value(**kw)
if not session['creacion_lb']:
session['items_lb']=[]; session.save()
if len(values)==0 and not(session['creacion_lb']):
flash(('No existen items Aprobados'), 'warning')
raise redirect ('/lineaBase', id_fase=fase.id_fase)
if not session['creacion_lb']:
session['creacion_lb']=True; session.save()
return dict(value_list=values, model = "Linea Base" ,navegacion=navegacion, id_fase=kw['fase'])
开发者ID:vanecan,项目名称:SGP14,代码行数:25,代码来源:lineaBase.py
示例8: ajaxSavetoCart
def ajaxSavetoCart( self, **kw ):
_k = kw.get( "_k", None )
if not _k : return {'flag' : 1 , 'msg' : 'No ID provided!'}
try:
items = session.get( 'items', [] )
for index, item in enumerate( items ):
if item['_k'] != _k : continue
p = qry( Product ).get( item['id'] )
item['values'], item['optionstext'] = self._formatKW( kw , p )
qs = []
for qk, qv in self._filterAndSorted( "option_qty", kw ):
if not qv : continue
q, _ = qv.split( "|" )
if not q.isdigit() : continue
qs.append( int( q ) )
item['qty'] = sum( qs ) if qs else 0
items[index] = item
session['items'] = items
session.save()
return {'flag' : 0 , 'optionstext' : item['optionstext'], }
except:
traceback.print_exc()
return {'flag' : 1 , 'msg' : 'Error occur on the sever side!'}
return {'flag' : 1 , 'msg' : 'No such item!'}
开发者ID:LamCiuLoeng,项目名称:aeo,代码行数:25,代码来源:ordering.py
示例9: removeall
def removeall( self, **kw ):
try:
del session['items']
session.save()
except:
pass
return redirect( '/ordering/listItems' )
开发者ID:LamCiuLoeng,项目名称:aeo,代码行数:7,代码来源:ordering.py
示例10: ajaxAddtoCart
def ajaxAddtoCart( self, **kw ):
_id = kw.get( 'id', None ) or None
if not _id : return {'flag' : 1 , 'msg' : 'No ID provided!'}
try:
items = session.get( 'items', [] )
tmp = {
'_k' : "%s%s" % ( dt.now().strftime( "%Y%m%d%H%M%S" ), random.randint( 100, 10000 ) ) ,
'id' : _id,
}
qs = []
for qk, qv in self._filterAndSorted( "option_qty", kw ):
if not qv : continue
q, _ = qv.split( "|" )
if not q.isdigit() : continue
qs.append( int( q ) )
tmp['qty'] = sum( qs ) if qs else 0
p = qry( Product ).get( _id )
tmp['values'], tmp['optionstext'] = self._formatKW( kw, p )
items.append( tmp )
session['items'] = items
session.save()
return {'flag' : 0 , 'total' : len( session['items'] )}
except:
traceback.print_exc()
return {'flag' : 1, 'msg':'Error occur on the sever side!'}
开发者ID:LamCiuLoeng,项目名称:aeo,代码行数:27,代码来源:ordering.py
示例11: fetch
def fetch(self, page, rows, sidx, sord, **kw):
''' Function called on AJAX request made by FlexGrid
Fetch data from DB, return the list of rows + total + current page
'''
# Try and use grid preference
grid_rows = session.get('grid_rows', None)
if rows=='-1': # Default value
rows = grid_rows if grid_rows is not None else 25
# Save grid preference
session['grid_rows'] = rows
session.save()
rows = int(rows)
try:
page = int(page)
rows = int(rows)
offset = (page-1) * int(rows)
except:
offset = 0
page = 1
rows = 25
apps = DBSession.query(Campaign).filter(Campaign.deleted==None)
total = 1 + apps.count() / rows
column = getattr(Campaign, sidx)
apps = apps.order_by(getattr(column,sord)()).offset(offset).limit(rows)
rows = [ { 'id' : a.cmp_id, 'cell': row(a) } for a in apps ]
return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:31,代码来源:cc_campaign.py
示例12: pwd_expired_change
def pwd_expired_change(self, **kw):
require_authenticated()
return_to = kw.get("return_to")
kw = F.password_change_form.to_python(kw, None)
ap = plugin.AuthenticationProvider.get(request)
try:
expired_username = session.get("expired-username")
expired_user = M.User.query.get(username=expired_username) if expired_username else None
ap.set_password(expired_user or c.user, kw["oldpw"], kw["pw"])
expired_user.set_tool_data("allura", pwd_reset_preserve_session=session.id)
expired_user.set_tool_data("AuthPasswordReset", hash="", hash_expiry="") # Clear password reset token
except wexc.HTTPUnauthorized:
flash("Incorrect password", "error")
redirect(tg.url("/auth/pwd_expired", dict(return_to=return_to)))
flash("Password changed")
session.pop("pwd-expired", None)
session["username"] = session.get("expired-username")
session.pop("expired-username", None)
session.save()
h.auditlog_user("Password reset (via expiration process)")
if return_to and return_to != request.url:
redirect(return_to)
else:
redirect("/")
开发者ID:joequant,项目名称:allura,代码行数:26,代码来源:auth.py
示例13: outcall_fetch
def outcall_fetch(self, page, rows, sidx, sord, cust_id, **kw):
''' Function called on AJAX request made by FlexGrid
Fetch data from DB, return the list of rows + total + current page
'''
# Try and use grid preference
grid_rows = session.get('grid_rows', None)
if rows=='-1': # Default value
rows = grid_rows if grid_rows is not None else 25
# Save grid preference
session['grid_rows'] = rows
session.save()
rows = int(rows)
try:
page = int(page)
rows = int(rows)
offset = (page-1) * int(rp)
except:
offset = 0
page = 1
rows = 25
data = DBSession.query(Outcall, CDR) \
.outerjoin(CDR, Outcall.uniqueid==CDR.uniqueid) \
.filter(Outcall.cust_id==cust_id)
total = 1 + data.count() / rows
column = getattr(Outcall, sidx)
data = data.order_by(getattr(column,sord)()).offset(offset).limit(rows)
rows = [
{ 'id' : a.Outcall.out_id, 'cell': outcall_row(a) } for a in data ]
return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:35,代码来源:cc_outcall.py
示例14: fetch
def fetch(self, page, rows, sidx, sord, **kw):
""" Function called on AJAX request made by FlexGrid
Fetch data from DB, return the list of rows + total + current page
"""
# Try and use grid preference
grid_rows = session.get("grid_rows", None)
if rows == "-1": # Default value
rows = grid_rows if grid_rows is not None else 25
# Save grid preference
session["grid_rows"] = rows
session.save()
rows = int(rows)
try:
page = int(page)
rows = int(rows)
offset = (page - 1) * int(rp)
except:
offset = 0
page = 1
rows = 25
apps = DBSession.query(Application)
total = apps.count()
column = getattr(Application, sidx)
apps = apps.order_by(getattr(column, sord)()).offset(offset).limit(rows)
rows = [{"id": a.app_id, "cell": row(a)} for a in apps]
return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:31,代码来源:application.py
示例15: diff
def diff(self, commit, fmt=None, **kw):
try:
path, filename = os.path.split(self._blob.path())
a_ci = c.app.repo.commit(commit)
a = a_ci.get_path(self._blob.path())
apath = a.path()
except:
a = []
apath = ''
b = self._blob
if not self._blob.has_html_view:
diff = "Cannot display: file marked as a binary type."
return dict(a=a, b=b, diff=diff)
la = list(a)
lb = list(b)
adesc = (u'a' + h.really_unicode(apath)).encode('utf-8')
bdesc = (u'b' + h.really_unicode(b.path())).encode('utf-8')
if not fmt:
fmt = web_session.get('diformat', '')
else:
web_session['diformat'] = fmt
web_session.save()
if fmt == 'sidebyside':
hd = HtmlSideBySideDiff()
diff = hd.make_table(la, lb, adesc, bdesc)
else:
diff = ''.join(difflib.unified_diff(la, lb, adesc, bdesc))
return dict(a=a, b=b, diff=diff)
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:31,代码来源:repository.py
示例16: fetch
def fetch(self, page, rows, sidx='user_name', sord='asc', _search='false',
searchOper=None, searchField=None, searchString=None, **kw):
''' Function called on AJAX request made by FlexGrid
Fetch data from DB, return the list of rows + total + current page
'''
# Try and use grid preference
grid_rows = session.get('grid_rows', None)
if rows=='-1': # Default value
rows = grid_rows if grid_rows is not None else 25
# Save grid preference
session['grid_rows'] = rows
session.save()
rows = int(rows)
try:
page = int(page)
rows = int(rows)
offset = (page-1) * rows
except:
offset = 0
page = 1
rows = 25
sounds = DBSession.query(Sound)
total = sounds.count()/rows + 1
column = getattr(Sound, sidx)
sounds = sounds.order_by(getattr(column,sord)()).offset(offset).limit(rows)
rows = [ { 'id' : s.sound_id, 'cell': row(s) } for s in sounds ]
return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:33,代码来源:moh.py
示例17: sites
def sites(self, *kw):
session['date'] = kw[0]
session.save()
c.reports = sites_report_grid
c.query_params = { 'Date' : session['date'] }
c.backlink = '/reports/reports'
return dict(page = 'squid')
开发者ID:diegows,项目名称:xreport,代码行数:7,代码来源:reports.py
示例18: report2
def report2(self,**kw):
reload(sys);
sys.setdefaultencoding("utf-8");
set_lang("th");
session['lang'] = "th";
session.save();
year = self.util.isValue(kw.get('year'));
log.info(year);
if year is None:
year = self.defaultyear;
listYear = self.util.getRangeYear(year);
section=[];
if(year):
startDate = str(int(year)-543 -1) + '-10-01';
stopDate = str(int(year)-543) + '-09-30';
log.info(startDate);
section = RiskManagement.listSectionReport(startDate,stopDate);
#log_view_report
self.saveLogView();
return dict(page='risk',util=self.util,year=year,listYear = listYear,section = section);
开发者ID:tongpa,项目名称:bantakCom,代码行数:25,代码来源:riskmanagecontroller.py
示例19: oid_session
def oid_session(self):
if 'openid_info' in session:
return session['openid_info']
else:
session['openid_info'] = result = {}
session.save()
return result
开发者ID:Bitergia,项目名称:allura,代码行数:7,代码来源:app_globals.py
示例20: login
def login(self, residence_dn, username, password):
if self.get_anon_bind() is None:
return False
user_base_dn = ldap_config.username_base_dn + residence_dn
actual_user = self.get_anon_bind().search_first(user_base_dn, "(uid=" + username + ")")
if actual_user is None:
return False
username_dn = actual_user.dn
bind = Ldap.connect(username_dn, password)
if bind is None:
return False
attributes = bind.search_first(username_dn, "(uid=" + username + ")")
user = User(bind, attributes, residence_dn)
AuthHandler.__users[username] = user
session[AuthHandler.__user_session_name] = username
session.save()
return True
开发者ID:Rbeuque74,项目名称:brie-aurore,代码行数:26,代码来源:auth.py
注:本文中的tg.session.save函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论