当前位置: 首页>>代码示例>>Python>>正文


Python session.save函数代码示例

本文整理汇总了Python中pylons.session.save函数的典型用法代码示例。如果您正苦于以下问题:Python save函数的具体用法?Python save怎么用?Python save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了save函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: login_validate

    def login_validate(self):
        if (c.userid != "false"):
             redirect(url('/users/login?m=2'))
        session['logged_in'] = True
        session.save()    
            
        if request.method == 'POST':
            c.form = LoginForm(request.POST)
            if c.form.is_valid():

                userid = authenticate_user(c.form.cleaned_data['email'], \
                         c.form.cleaned_data['password'])
                print "hellooooo", c.form.cleaned_data['email'], c.form.cleaned_data['password']
                if (userid != "invalid" ):
                    session['userid'] = userid
                    session.save()
                    print session['userid']
                    redirect(url('/'))
                    c.login = "valid"
                else:
                 c.login = "invalid"

            else:
                 c.form = LoginForm(request.POST)

        return render("/users/login.mako")
开发者ID:icheckmate,项目名称:DARE-1,代码行数:26,代码来源:users.py

示例2: check_flash

def check_flash():
    """If the session data isn't of the particular format python has trouble.
    So we check that it is a dict."""
    if session.has_key('flash'):
        if type(session['flash']) != dict:
            del session['flash']
            session.save()
开发者ID:steven-ellis,项目名称:zookeepr,代码行数:7,代码来源:helpers.py

示例3: UserSetIconID

def UserSetIconID(UserID, IconID):

    # Convert to integer
    if not IconID.isdigit():
        return "Error: IconID is not an integer."
    else:
        IconID = int(IconID)

        # Bounds check the icon ID (should only range betwee [0, 18]
    if IconID < 0 or IconID > 19:
        return "Error: IconID is out of range."

        # Update this user's score in the database
    ExistingUsers = Session.query(UsersTable).filter(UsersTable.UserID == UserID).all()

    # Commit changes
    if len(ExistingUsers) == 1:
        ExistingUsers[0].IconID = IconID
        Session.commit()
    else:
        return "Error: No users found."

        # Post to session if we have a matching ID (otherwise, just return the user points)
    if session.get("UserID") and session["UserID"] == UserID:
        session["UserIconID"] = IconID
        session.save()

        # All done!
    return "Icon change saved!"
开发者ID:nint22,项目名称:CoreCodex,代码行数:29,代码来源:Users.py

示例4: submit

 def submit(self):
     c.post = h.post.get(int(request.params.get('post_id')))
     c.posts = None
     if h.forms.validate(h.forms.CommentForm()):         
         # save comment
         comment = h.comment.new()
         for k, v in c.form_result.items():
             setattr(comment, k, v)
         # some checks and defaults
         if len(comment.author) == 0:
             comment.author = 'anonymous'
         comment.posted = h.timehelpers.now()
         comment.body = h.html_escape(comment.body)
         comment.body = comment.body.replace('\n','<br>')
         comment.body = comment.body.replace('\t','&nbsp;')
         comment.body = comment.body.replace('  ','&nbsp; ')
         # save to db
         h.comment.save(comment)
         # flash message
         session['flash'] = 'Comment successfully saved.'
         session.save()
         # notify author
         h.mailer.send_mail('[email protected]', h.auth.get_user_mail(c.post.author), 'New comment for: '+c.post.subject, render('/messages/mail_new_comment.mako', extra_vars={'user':h.auth.get_user_name(id=c.post.author), 'post_subject':c.post.subject, 'site_name':h.config.get('site_title'), 'post_url':h.config.get('site_url')+url(controller='blog', action='view', id=c.post.id, subject=h.urlify(c.post.subject))}))
         # redirect to post
         redirect(url(controller='blog', action='view', id=request.params.get('post_id'), subject=h.urlify(c.post.subject)), code=303)
     else:
         session['flash'] = 'Erros in the submitted form, please correct and try again.'
         session.save()
         html = render('/blog/view.mako', extra_vars={'page_id':1, 'post_count':1})
         return htmlfill.render(html,defaults=c.form_result,errors=c.form_errors)
开发者ID:jaywink,项目名称:argonaut,代码行数:30,代码来源:comment.py

示例5: set_language

 def set_language(self):
     "Set the language"
     nextpage = request.params.get('next', None)
     if not nextpage:
         nextpage = request.headers.get('Referer', None)
     if not nextpage:
         nextpage = '/'
     if '://' in nextpage:
         from_url = urlparse(nextpage)
         nextpage = from_url[2]
     lang_code = request.params.get('language', None)
     if lang_code and check_language(lang_code):
         session['lang'] = lang_code
         session.save()
     params = []
     for param in request.params:
         if not param in ['language', 'amp']:
             value = request.params[param]
             if value:
                 if (param == 'came_from' and
                     '://' in urllib2.unquote(value)):
                     urlparts = urlparse(urllib2.unquote(value))
                     value = urlparts[2] or '/'
                 params.append('%s=%s' % (urllib2.quote(param),
                                         urllib2.quote(value)))
     if 'lc=1' not in params:
         params.append('lc=1')
     if params:
         nextpage = "%s?%s" % (nextpage, '&amp;'.join(params))
     redirect(nextpage)
开发者ID:TetraAsh,项目名称:baruwa2,代码行数:30,代码来源:accounts.py

示例6: changedir

    def changedir(self):
        # Grab params
        box = request.params.get('box').decode('latin1')
        dir = request.params.get('dir').decode('latin1')

        # Check a host exists
        if 'host' not in session[SESS_KEY][box]:
            return

        path = session[SESS_KEY][box]['path']
        account = int(session[SESS_KEY][box]['host'] or 0)

        # Clean input
        dir = dir[:-1] if dir[-1] == '/' else dir

        # Change full path
        if dir == '..Parent Directory':
            arr = session[SESS_KEY][box]['path'].split('/')
            path = '/'.join(arr[:-1])
            if not path:
                path = '/'
        elif dir == '..User Home Directory':
            path = '~'
        elif dir == '..Home Directory':
            path = None
        elif dir == '..Refresh Listing':
            pass
        else:
            path = path + '/' + dir

        # Update listing
        session[SESS_KEY][box]['path'] = path
        session.save()
        self._updatelisting(box, path)
开发者ID:sumukh210991,项目名称:Cyberweb,代码行数:34,代码来源:data.py

示例7: save

    def save(self, id=None):
        """
        """
        if id is None:
            abort(404)
        assay_q = Session.query(Assay)
        assay = assay_q.filter_by(id=id).first()
        if assay is None:
            abort(404)

        reload_sequences = False
        for k, v in self.form_result.items():
            if k in ("primer_fwd", "primer_rev", "chromosome", "probe_pos", "amplicon_width", "snp_rsid"):
                if getattr(assay, k) != v:
                    reload_sequences = True
            if k not in ("id"):
                setattr(assay, k, v)

        # blow away previous sequences; on view, this will update.
        if reload_sequences:
            cached_sequences = assay.cached_sequences
            for i in range(len(cached_sequences)):
                cs = cached_sequences[-1]
                snps = cs.snps
                for j in range(len(snps)):
                    snp = snps.pop()
                    Session.delete(snp)
                cached_sequences.pop()
                Session.delete(cs)

        self.__update_tms(assay)

        Session.commit()
        session.save()
        redirect(url(controller="assay", action="view", id=assay.id))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:35,代码来源:assay.py

示例8: check_flash

def check_flash():
    # If the session data isn't of the particular format python has trouble.
    # So we check that it is a dict.
    if session.has_key("flash"):
        if type(session["flash"]) != dict:
            del session["flash"]
            session.save()
开发者ID:cafuego,项目名称:zookeepr,代码行数:7,代码来源:helpers.py

示例9: authorize

	def authorize(self):
		context = self._get_context()

		try:
			tk.check_access('oauth2provider_token_create', context)
		except tk.NotAuthorized:
			return tk.abort(401)

		client_id = self._get_required_param('client_id')
		response_type = tk.request.params.get('redirect_uri', 'code')
		scopes = self._get_required_param('scope').split(' ')
		redirect_uri = tk.request.params.get('redirect_uri', '')
		state = tk.request.params.get('state', '')

		if state:
			session['oauth2provider_state'] = state
			session.save()

		client = Client.get(client_id=client_id)

		data = {
			'client_name': client.name,
			'client_id': client.client_id,
			'response_type': response_type,
			'redirect_uri': redirect_uri,
			'scopes': scopes,
		}

		vars = {'data': data, 'action': 'authorize'}
		return tk.render('ckanext/oauth2provider/authorize.html',
			extra_vars=vars)
开发者ID:dubvfan87,项目名称:ckanext-oauth2provider,代码行数:31,代码来源:token.py

示例10: update

    def update(self, id, format='html'):
        ignore = ['Submit',
                'username']

        params = [
            (p, request.params[p]) for p in request.params \
                if p not in ignore]
        data = {}
        for key, value in params:
            if key == 'cpu_speed' and not value:
                continue
            elif key == 'game' and not value:
                continue
            data[key] = value

        activity_engine = ActivityEngine(Session,
                session['active_user']['user_id'])
        status = activity_engine.update('node', id, data)

        if format =='html':
            session['flash'] = status
            session.save()
            return redirect(url(controller='nodes', action='show', id=id))
        elif format == 'json':
            request.content_type = 'application/json'
            return status
开发者ID:seryl,项目名称:Nodetraq,代码行数:26,代码来源:nodes.py

示例11: updatebyname

    def updatebyname(self, name, format='html'):
        id = Session.query(Node).filter(Node.hostname == name).first()
        if id:
            id = id.id
        else:
            return 'Host: %s is not in nodetraq' % name

        ignore = ['Submit',
                'username']

        params = [
            (p, request.params[p]) for p in request.params \
                if p not in ignore]
        data = {}
        for key, value in params:
            if value:
                if key == 'cpu_speed' and not value:
                    continue
                data[key] = value

        activity_engine = ActivityEngine(Session,
                session['active_user']['user_id'])
        status = activity_engine.update('node', id, data)

        if format =='html':
            session['flash'] = status
            session.save()
            return redirect(url(controller='nodes', action='show', id=id))
        elif format == 'json':
            request.content_type = 'application/json'
            return status
开发者ID:seryl,项目名称:Nodetraq,代码行数:31,代码来源:nodes.py

示例12: change_password

	def change_password(self):
		c.controller = 'account'
		c.action = 'index'
		m = hashlib.md5()
		m.update(request.params['password'])
		if m.hexdigest() != session['passhash']:
			c.message = _("Incorrect current password!")
			return render('/info.mako')
		new = request.params['new_password']
		new2 = request.params['new_password2']
		if new != new2:
			c.message = _("Passwords do not match!")
			return render('/info.mako')
		bad_password = h.check_password(session['user'], new)
		if bad_password is not None:
			c.message = bad_password
			return render('/info.mako')
		m = hashlib.md5()
		m.update(new)
		new = m.hexdigest()
		app_globals.rpcservice.user_change_password(session['user'], session['passhash'], new)
		session['passhash'] = new
		session.save()
		c.message = _("Password set succesfully")
		return render('/info.mako')
开发者ID:cyclefusion,项目名称:szarp,代码行数:25,代码来源:account.py

示例13: authenticate_admin

def authenticate_admin(username, password):
    
    auth_user = AdminUser.query.filter(AdminUser.username==username).first()

    if not auth_user:
        log.debug("No user named: '%s'", username)
        return False        
    elif not auth_user.password:
        log.error("Bad username/pass:'%s'")
        return False
    elif password != auth_user.password:
        log.debug("Database password for user '%s'", username)
        return False
    else:
        request.environ["REMOTE_USER"] = auth_user.username
        request.environ["HTTP_REMOTE_USER"] = auth_user.username

    session["perms"]= auth_user.permissions
    session["user"] = auth_user
    session["name"] = auth_user.name
    session['user_id'] = auth_user.id

    auth_user.register_login(username, session, request)  
    db.commit()
    db.flush()
    session.save()
    return True
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:27,代码来源:auth.py

示例14: logged_in

    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()

        # we need to set the language explicitly here or the flash
        # messages will not be translated.
        ckan.lib.i18n.set_lang(lang)

        if c.user:
            context = {'model': model,
                       'user': c.user}

            data_dict = {'id': c.user}

            user_dict = get_action('user_show')(context, data_dict)

            h.flash_success(_("%s is now logged in") %
                            user_dict['display_name'])
            return self.me(locale=lang)
        else:
            err = _('Login failed. Bad username or password.')
            if g.openid_enabled:
                err += _(' (Or if using OpenID, it hasn\'t been associated '
                         'with a user account.)')
            h.flash_error(err)
            h.redirect_to(locale=lang, controller='user', action='login')
开发者ID:abulte,项目名称:ckan,代码行数:27,代码来源:user.py

示例15: logged_in

    def logged_in(self):
        # we need to set the language via a redirect
        lang = session.pop('lang', None)
        session.save()

        # we need to set the language explicitly here or the flash
        # messages will not be translated.
        i18n.set_lang(lang)

        if c.user:
            is_new = False
            is_sysadmin = new_authz.is_sysadmin(c.user)

            # Retrieve information about the current user
            context = {'model': model, 'session': model.Session,
                   'user': c.user or c.author,
                   'schema': schema.user_new_form_schema()}
            data_dict = {'id': c.user}

            user_dict = get_action('user_show')(context, data_dict)

            # This check is not needed (or correct) for sys admins
            if not is_sysadmin:

                # Get all organizations and all groups the user belongs to
                orgs_q = model.Session.query(model.Group) \
                    .filter(model.Group.is_organization == True) \
                    .filter(model.Group.state == 'active')
                q = model.Session.query(model.Member) \
                    .filter(model.Member.table_name == 'user') \
                    .filter(model.Member.table_id == user_dict['id'])

                group_ids = []
                for row in q.all():
                    group_ids.append(row.group_id)

                if not group_ids:
                    is_new = True
                else:
                    orgs_q = orgs_q.filter(model.Group.id.in_(group_ids))

                    orgs_list = model_dictize.group_list_dictize(orgs_q.all(), context)

                    if len(orgs_list) == 0:
                        is_new = True

            h.flash_success(_("<p><strong>Note</strong></p>"
                "<p>%s is now logged in</p>") %
                user_dict['display_name'], allow_html=True)

            if is_new:
                return h.redirect_to(controller='ckanext.canada.controller:CanadaController',
                                         action='view_new_user', locale=lang)
            else:
                return h.redirect_to(controller='package',
                    action='search', locale=lang)
        else:
            h.flash_error(_('Login failed. Bad username or password.'))
            return h.redirect_to(controller='user',
                action='login', locale=lang)
开发者ID:mathew-thomas,项目名称:ckanext-canada,代码行数:60,代码来源:controller.py


注:本文中的pylons.session.save函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。