• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python security.authenticated_userid函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_new_post

def add_new_post(request):
	succ = False
	#if not authenticated_userid(request):
	#	request.session.flash({
	#			'class' : 'warning',
	#			'text'  : 'Войдите чтобы увидеть эту страницу'
	#			})
	#	return HTTPSeeOther(location=request.route_url('login'))
	if not request.POST:
		return HTTPSeeOther(location=request.route_url('home'))
	else:
		csrf = request.POST.get('csrf', '')
		message = request.POST.get('userpost', None)
		ppage = request.POST.get('ppage', None)
		aid = request.POST.get('aid', None)
		captcha = request.POST.get('g-recaptcha-response', None)
		if authenticated_userid(request):
			username = authenticated_userid(request)
			if message and csrf == request.session.get_csrf_token() and ppage:
				newpost = Post(date = datetime.datetime.now(), page=ppage, name=username, ip=request.remote_addr, post=message, articleid=aid )
				DBSession.add(newpost)
		

		else:
			username = request.POST.get('username', None)
			resp = urlopen("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}".format("6Lf5AP8SAAAAAHKklOunO0NxX3UOBiFNZPYJslId", captcha))
			
			captcharesp = json.loads(resp.read().decode("utf-8"))
			if captcharesp.get('success') is True:
				if message and csrf == request.session.get_csrf_token() and ppage:
					newpost = Post(date = datetime.datetime.now(), page=ppage, name=username, ip=request.remote_addr, post=message )
					DBSession.add(newpost)
					
		return HTTPSeeOther(location=request.referrer)
开发者ID:annndrey,项目名称:caas,代码行数:34,代码来源:views.py


示例2: my_view

def my_view(request):
    userid=authenticated_userid(request)
    if userid:
        email, nick = split_remembering(userid)
        return {'project': 'MyProject', 'login': authenticated_userid(request), 'name':nick, 'email':email}
    else:
        return HTTPFound(location = request.route_url('login'))
开发者ID:KhorAMus,项目名称:course-project,代码行数:7,代码来源:views.py


示例3: handle_submit

    def handle_submit(self, converted):
        context = self.context
        request = self.request
        workflow = self.workflow
        # *will be* modified event
        objectEventNotify(ObjectWillBeModifiedEvent(context))
        if 'security_state' in converted:
            if workflow is not None:
                workflow.transition_to_state(context, request,
                                             converted['security_state'])

        context.title = converted['title']
        context.text = converted['text']
        context.description = extract_description(converted['text'])

        # Tags and attachments
        set_tags(context, request, converted['tags'])
        creator = authenticated_userid(request)
        attachments_folder = context['attachments']
        upload_attachments(
            filter(lambda x: x is not None, converted['attachments']),
            attachments_folder,
            creator, request)

        # modified
        context.modified_by = authenticated_userid(request)
        objectEventNotify(ObjectModifiedEvent(context))

        location = resource_url(context, request)
        self.filestore.clear()
        return HTTPFound(location=location)
开发者ID:disko,项目名称:karl,代码行数:31,代码来源:blog.py


示例4: add_user

def add_user(request):
    message = ''
    if 'form.submitted' in request.params:
        login = request.params['login'].strip()
        password_0 = request.params['password_0'].strip()
        password_1 = request.params['password_1'].strip()
        if login == '':
            message = 'Login must have at least one character'
            return dict(login=login, message=message,
                        password_0=password_0, password_1=password_1,
                        logged_in=authenticated_userid(request))
        if DBSession.query(User).filter_by(name=login).first() is not None:
            message = 'That login has allready been taken'
            return dict(login=login, message=message,
                        password_0=password_0, password_1=password_1,
                        logged_in=authenticated_userid(request))
        if password_0 != password_1:
            message = 'Entered passwords are not identical'
            return dict(login=login, message=message,
                        password_0=password_0, password_1=password_1,
                        logged_in=authenticated_userid(request))
        if len(password_0) < 4:
            message = 'Password must be at least 4 characters long'
            return dict(login=login, message=message,
                        logged_in=authenticated_userid(request))
        user = User(name=login, password=password_0, permission='unapproved')
        DBSession.add(user)
        headers = remember(request, login)
        return HTTPFound(location = '/',
                         headers = headers)
    return dict(login='', message=message,
                logged_in=authenticated_userid(request))
开发者ID:Nyle,项目名称:old-scouting,代码行数:32,代码来源:security_views.py


示例5: swordfish

def swordfish(context,request):
    logged_in = authenticated_userid(request)
    t_path = "../templates/register.pt"
    main = get_renderer(t_path).implementation()

    if not 'god' in context:
        context["god"] = User("god",
                              hashlib.sha1("eden".encode('UTF-8')).digest(), 
                              777777, 
                              firstName = "Jesus", 
                              lastName = "Christ", 
                              email = "[email protected]", 
                              phone = "777-777-7707", 
                              gradYear = 2013, 
                              inductionYear = 0, 
                              isofficer=True, 
                              isadvisor=True)

        context["god"].__parent__ = context
        
        return {'red':'',
                'main':get_renderer(t_path).implementation(),
                'content':'And on the eighth day, Man created God',
                'logged_in':authenticated_userid(request),
                'name':'Apotheosis Sucessful (:',
		'TutText': getTutText(context, view='')}
        
    return {'red':'',
            'main':get_renderer(t_path).implementation(),
            'content':'You already have a God',
            'logged_in':authenticated_userid(request),
            'name':'Apotheosis Failed D:',
	    'TutText': getTutText(context, view='')}
开发者ID:C453,项目名称:yhs_nhs,代码行数:33,代码来源:userviews.py


示例6: public_room

def public_room(request):
    if authenticated_userid(request):
        login_flag = 1
        user_id = authenticated_userid(request)
        _id = ObjectId(user_id)
        user_data = user.find_one({"_id":_id})
        user_data['_id'] = str(user_data['_id'])
    else:
        ##login_flag = 0
        ##user_data = {}
        ##headers = remember(request, 10)
        return HTTPFound(location='/login')

    if request.POST.get('e_nickname'):
        user_id = request.POST.get('e_user_id')
        _id = ObjectId(user_id)
        nickname = request.POST.get('e_nickname')
        textcolor = request.POST.get('e_textcolor')
        user.update({"_id":_id},{"$set":{"nickname":nickname,"textcolor":textcolor}})

        user_data = user.find_one({"_id":_id})
        user_data['_id'] = str(user_data['_id'])

    return {'login_flag': login_flag,
            'user_data': user_data}
开发者ID:WickyYao,项目名称:chat,代码行数:25,代码来源:views.py


示例7: user

def user(request):
  userid = authenticated_userid(request)
  if not userid:
    request.session.flash('Please login')
    return HTTPFound(location=request.route_url('login'))
  username = request.matchdict.get('username', userid)
  profile = (username == userid)
  if not profile and not has_permission('approve_run', request.context, request):
    request.session.flash('You cannot inspect users')
    return HTTPFound(location=request.route_url('tests'))
  user = request.userdb.get_user(username)
  if 'user' in request.POST:
    if profile:
      if len(request.params.get('password')) > 0:
        if request.params.get('password') != request.params.get('password2', ''):
          request.session.flash('Matching verify password required')
          return {'user': user, 'profile': profile}
        user['password'] = request.params.get('password')
      if len(request.params.get('email')) > 0:
        user['email'] = request.params.get('email')
    else:
      user['blocked'] = ('blocked' in request.POST)
      request.actiondb.block_user(authenticated_userid(request), {'user': username, 'blocked': user['blocked']})
      request.session.flash(('Blocked' if user['blocked'] else 'Unblocked') + ' user ' + username)
    request.userdb.save_user(user)
    return HTTPFound(location=request.route_url('tests'))
  userc = request.userdb.user_cache.find_one({'username': username})
  hours = int(userc['cpu_hours']) if userc is not None else 0
  return {'user': user, 'limit': request.userdb.get_machine_limit(username), 'hours': hours, 'profile': profile}
开发者ID:glinscott,项目名称:fishtest,代码行数:29,代码来源:views.py


示例8: view_page

def view_page(request):
    all_posts = []
    pagename = request.matchdict['pagename']
    page = DBSession.query(Page).filter_by(name=pagename).first()
    if page is None:
        return HTTPNotFound('No such page')
    editor = has_permission('edit',RootFactory,request)    
    def check(match):
        word = match.group(1)
        exists = DBSession.query(Page).filter_by(name=word).all()
        if exists:
            view_url = request.route_url('view_page', pagename=word)
            return '<a href="%s">%s</a>' % (view_url, word)
        else:
            add_url = request.route_url('add_page', pagename=word)
            return '<a href="%s">%s</a>' % (add_url, word)

    content = publish_parts(page.data, writer_name='html')['html_body']
    content = wikiwords.sub(check, content)
    edit_url = request.route_url('edit_page', pagename=pagename)
    delete_post_url = request.route_url('delete_post', pagename=pagename)
    if 'form.submitted' in request.params:
        DBSession.add(Posts(authenticated_userid(request), pagename, request.params['message'], datetime.now()))
    for post in DBSession.query(Posts).filter_by(page_name=pagename):
        all_posts.append(post)
    
    return dict(page=page,  content=content, all_posts=all_posts, edit_url=edit_url, delete_post_url=delete_post_url, editor = editor,
                logged_in=authenticated_userid(request))
开发者ID:heng4fun,项目名称:SQLAlchemy---URL-Dispatch-Wiki-Tutorial,代码行数:28,代码来源:views.py


示例9: group_post

    def group_post(self):
        group = Category.objects.with_id(ObjectId(self.request.matchdict['id']))
        me = User.by_username(authenticated_userid(self.request))
        if not (group and (group.public or group.owner == me or me in group.members)):
            raise NotFound

        if self.request.method == 'POST':
            content = self.request.POST['tx_content'].replace("'", "&#39;").replace("\r\n", "")
            post = Post(title=self.request.POST['title'],
                        content=content,
                        category=group,
                        modified=datetime.now(),
                        author=User.by_username(authenticated_userid(self.request)))
            
            for attach in self.request.POST.getall('tx_attach_image'):
                post.images.append(attach)
            for attach in self.request.POST.getall('tx_attach_file'):
                post.files.append(attach)
            
            post.save(safe=True)

            # 내가 새글을 추가한 경우, 나를 제외한 블로그 그룹의 모든 사람에게 알람을 전송한다.
            msg = AlarmMessage(me=me, command=AlarmMessage.CMD_BLOG_ADD, post=post)
            thread_alarmer.send(msg)
            
            return HTTPFound(location=self.request.route_path('blog_view', id=str(post.id)))
        else:
            return dict(post=None,
                        group=group,
                        save_url=self.request.route_path('group_post', id=self.request.matchdict['id']),
                        )
开发者ID:theun,项目名称:in.nuribom.com,代码行数:31,代码来源:blog.py


示例10: edit_robot

def edit_robot(request):
    message = ""
    original_number = request.params["original_number"]
    robot = DBSession.query(Robot).filter_by(number=original_number).first()
    if "form.submitted" in request.params:
        robot.wheels = request.params["wheels"]
        robot.gearbox = request.params["gearbox"]
        robot.drive_motors = request.params["drive_motors"]
        robot.description = request.params["description"]
        robot.shooter = "shooter" in request.params
        robot.climb_10 = "climb_10" in request.params
        robot.climb = "climb" in request.params
        robot.human_loading = "human_loading" in request.params
        robot.ground_loading = "ground_loading" in request.params
        robot.is_scouted = "is_scouted" in request.params
        robot.scout = request.params["scout"]
        if (
            request.params["number"] != original_number
            and DBSession.query(Robot).filter_by(number=request.params["number"]).first() is not None
        ):
            message = "Robot number {0} allready exists".format(request.params["number"])
            return dict(
                robot=robot, original_number=original_number, logged_in=authenticated_userid(request), message=message
            )
        else:
            robot.number = request.params["number"]

        DBSession.add(robot)

        return HTTPFound(location=request.route_url("view_robot", number=robot.number))
    robot.is_scouted = True
    return dict(robot=robot, original_number=original_number, logged_in=authenticated_userid(request), message=message)
开发者ID:Nyle,项目名称:old-scouting,代码行数:32,代码来源:robot_views.py


示例11: license_add_ws

def license_add_ws(request):

    viewer_username = authenticated_userid(request)
    request.session.flash(authenticated_userid(request))
    if viewer_username == None:
        viewer_username = "not logged in"

    #form = Form(request, LicenseSchema)
    form = Form(request)

    if 'form.submitted' in request.POST:
        # request.session.flash("Here comes request.str_POST")
        # request.session.flash(request.str_POST)
        # request.session.flash("And this is request.POST")
        # request.session.flash(request.POST)

        my_results_dict = request.str_POST
        request.session.flash(my_results_dict.keys())

        request.session.flash(my_results_dict['cc_js_want_cc_license'])
        request.session.flash(my_results_dict['cc_js_result_uri'])
        request.session.flash(my_results_dict['cc_js_result_img'])
        request.session.flash(my_results_dict[u'cc_js_result_name'])

        # so here is what we need to store:
        #the_license = License(
        #    cc_license = my_results_dict['cc_js_want_cc_license'])

        #request.session.flash(
        #             "license? :" + form.data['cc_js_want_cc_license'])
        # request.session.flash("sharing? :" + form.data['cc_js_share'])
        # request.session.flash("remixing? :" + form.data['cc_js_remix'])
        # request.session.flash("locale :" + form.data['cc_js_jurisdiction'])
        # request.session.flash("URI :" + request.POST.cc_js_result_uri)
        # request.session.flash("img :" + form.data['cc_js_result_img'])
        # request.session.flash("name :" + form.data['cc_js_result_name'])

    # if 'form.submitted' in request.POST and not form.validate():
    #     # form didn't validate
    #     request.session.flash('form does not validate!')
    #     request.session.flash(form.data['license_name'])
    #     request.session.flash(form.data['license_url'])

    # if 'form.submitted' in request.POST and form.validate():
    #     request.session.flash('form validated!')
    #     license_name = form.data['license_name']

    #     license = License(
    #         license_name = form.data['license_name'],
    #         license_album = form.data['license_album'],
    #         license_url = form.data['license_url'],
    #         )
    #     dbsession.add(license)
    #     request.session.flash(u'writing to database ...')
    #     # ToDo: https://redmine.local/issues/5

    return {
        'viewer_username': viewer_username,
        'form': FormRenderer(form)
        }
开发者ID:AnneGilles,项目名称:c3sar,代码行数:60,代码来源:license.py


示例12: view_index

def view_index(request):
    """
    View associated with the home page of the app.
    """
    if authenticated_userid(request) == None or 'user' not in request.session.keys():
        return HTTPFound(location='/')
    if 'current_test' in request.session.keys(): 
        request.session.pop('current_test') #remove current_test from session
    userinfo = request.session['user']
    messages = []
    messages.append("Welcome " + userinfo['name'] + " to pyquiz.")
    dbsession = DBSession()
    if authenticated_userid(request) == 'teacher':
        messages.append('You are currently teaching the following classes:')
    if authenticated_userid(request) == 'student':
        messages.append('You are currently enrolled in the following classes:')
    courses = []
    for c in userinfo['courses']:
        course = dbsession.query(Course).filter(
                                       Course.course_id == c[0]).first()
        if course != None:
             courses.append(course)
    messages.append('')
    if len(courses) == 0:
        messages[2] == 'You have no classes'
    for course in courses:
        course.url = 'course?id='+str(course.id)
    return {'messages': messages, 'courses': courses}
开发者ID:ellimistd,项目名称:pyquiz,代码行数:28,代码来源:views.py


示例13: pub_remove

def pub_remove(request):
	loc = get_localizer(request)
	if not authenticated_userid(request):
		request.session.flash({
				'class' : 'warning',
				'text'  : request.translate(_('Войдите чтобы увидеть эту страницу'))
				})
		return HTTPSeeOther(location=request.route_url('login'))
	else:
		pubtype = request.matchdict['pub']
		pubid = request.matchdict['id']
		if pubtype == 'post':
			post = DBSession.query(Post).filter(Post.id==pubid).first()
			if post.page == 'discuss':
				if post.name == authenticated_userid(request):
					DBSession.delete(post)
					transaction.commit()
					return HTTPSeeOther(location=request.referrer)
			else:
				DBSession.delete(post)
				transaction.commit()
				return HTTPSeeOther(location=request.referrer)
		elif pubtype == 'article':
			article = DBSession.query(Article).filter(Article.id==pubid).first()
			#if article.user == authenticated_userid(request):
			DBSession.delete(article)
			transaction.commit()
				#session.flash article deleted
			return HTTPSeeOther(location=request.route_url('main'))

	return HTTPSeeOther(location=request.referrer)
开发者ID:annndrey,项目名称:simplesite,代码行数:31,代码来源:views.py


示例14: add_article

def add_article(request):
	if not authenticated_userid(request):
		# add error message processing in the template
		request.session.flash({
				'class' : 'warning',
				'text'  : 'Войдите чтобы увидеть эту страницу'
				})
		return HTTPSeeOther(location=request.route_url('login'))
	if not request.POST:
		tpldef = {}
		article_series = set([s.series for s in DBSession.query(Article).all()])
		tpldef.update({'authuser':authenticated_userid(request), 'auth':True, 'article_status':article_status, 'article_series':article_series, 'pagename':'Новая статья'})
		return tpldef
	else:
		csrf = request.POST.get('csrf', '')
		if csrf == request.session.get_csrf_token():
			art_name = request.POST.get('inputMainname', None)
			art_uppername = art_name
			art_kwords = request.POST.get('inputKeywords', None)
			art_descr = request.POST.get('inputDescr', None)
			art_text = request.POST.get('inputArticle', None)
			art_url = request.POST.get('inputURL', None)

			art_leftbr = request.POST.get('inputLeftBracket', None)
			art_rightbr = request.POST.get('inputRightBracket', None)
			art_sep = request.POST.get('inputSep', None)
			art_prevtext = request.POST.get('inputPrevText', None)
			art_prevpict = request.POST.get('inputPrevPict', None)

			newarticle = Article(art_name, art_uppername, art_kwords, art_url, art_text, art_descr, datetime.datetime.now(), authenticated_userid(request), art_sep, art_rightbr, art_leftbr, art_prevtext, art_prevpict)
			DBSession.add(newarticle)
			# new article added here
		return HTTPSeeOther(location=request.route_url('main'))
开发者ID:annndrey,项目名称:caas,代码行数:33,代码来源:views.py


示例15: add_new_post

def add_new_post(request):
	succ = False
	sess = DBSession()
	cfg = request.registry.settings
	recaptcha_secret = cfg.get('recaptcha.secret', False)
	
	if not request.POST:
		return HTTPSeeOther(location=request.route_url('home'))
	else:
		csrf = request.POST.get('csrf', '')
		message = request.POST.get('userpost', None)
		ppage = request.POST.get('ppage', None)
		aid = request.POST.get('aid', None)
		captcha = request.POST.get('g-recaptcha-response', None)
		if authenticated_userid(request):
			username = authenticated_userid(request)
			if message and csrf == request.session.get_csrf_token() and ppage:
				newpost = Post(date = datetime.datetime.now(), page=ppage, name=username, ip=request.remote_addr, post=message, articleid=aid )
				DBSession.add(newpost)
				transaction.commit()
		

		else:
			username = request.POST.get('username', None)
			resp = urlopen("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}".format(recaptcha_secret, captcha))
			
			captcharesp = json.loads(resp.read().decode("utf-8"))
			if captcharesp.get('success') is True:
				if message and csrf == request.session.get_csrf_token() and ppage:
					newpost = Post(date = datetime.datetime.now(), page=ppage, name=username, ip=request.remote_addr, post=message, articleid=aid )
					DBSession.add(newpost)
					transaction.commit()
					
		return HTTPSeeOther(location=request.referrer)
开发者ID:annndrey,项目名称:simplesite,代码行数:34,代码来源:views.py


示例16: edit_admin

def edit_admin(request):
    changed = False
    all_group_names = []
    user_name = authenticated_userid(request)
    logged_in = authenticated_userid(request)

    home_url = request.route_url('home')
    login_url = request.route_url('login')
    view_url = request.route_url('view')
    alert_url = request.route_url('alert')
    admin_url = request.route_url('admin')
    add_admin_url = request.route_url('add_admin')
    edit_admin_url = request.route_url('edit_admin')
    add_streetlight_url = request.route_url('add_streetlight')
    logout_url = request.route_url('logout')
    delete_admin_url = request.route_url('delete_admin')

    alert = DBSession.query(StreetLight).filter(
        "voltage > 220.0 or current > 30.0").all()

    for group_name in DBSession.query(Group).all():
        all_group_names.append(group_name)

    if 'form.submitted' in request.params:
        password = request.params['password']
        user_group = request.params['user_group']
        admin = DBSession.query(Admin).filter_by(user_name=user_name).one()
        admin.password = password
        admin.user_group = user_group
        DBSession.flush()
        headers = forget(request)
        return HTTPFound(location=request.route_url('login'),
                         headers=headers)

    return dict(locals())
开发者ID:heng4fun,项目名称:streetlight,代码行数:35,代码来源:views.py


示例17: success

    def success(self, appstruct):
        super(Done, self).success(appstruct)
        if appstruct.get('is_favorite', False):
            self.favorite.set(
                name=appstruct.get('favorite_name'),
                state=self.wizard_state.dump())
            self.favorite.save()

        source_type = self.wizard_state.get('wizard_source')['source']
        if source_type == 'wizard_upload':
            inputs = appstruct_to_inputs(self.request, self.wizard_state.get('wizard_literal_inputs', {}))
            resource = self.wizard_state.get('wizard_complex_inputs')['identifier']
            for url in self.wizard_state.get('wizard_storage')['url']:
                inputs.append( (resource, url) )
            logger.debug('storage inputs=%s', inputs)
            result = execute_process.delay(
                userid=authenticated_userid(self.request),
                url=self.wps.url,
                identifier=self.wizard_state.get('wizard_process')['identifier'],
                inputs=inputs, outputs=[])
            self.request.registry.notify(JobStarted(self.request, result.id))
        else:
            result = execute_workflow.delay(
                userid=authenticated_userid(self.request),
                url=self.request.wps.url,
                workflow=self.workflow_description())
            self.request.registry.notify(JobStarted(self.request, result.id))
开发者ID:rmoorman,项目名称:pyramid-phoenix,代码行数:27,代码来源:done.py


示例18: invitation_claim

def invitation_claim(request):
    """ Action that awards a person a badge after scanning a qrcode. """

    settings = request.registry.settings

    if request.context.expires_on < datetime.now():
        return HTTPGone("That invitation is expired.")

    if not authenticated_userid(request):
        request.session['came_from'] = request.resource_url(
                request.context, 'claim')
        return HTTPFound(location=request.route_url('login'))

    person = request.db.get_person(person_email=authenticated_userid(request))

    # Check to see if the user already has the badge.
    if request.context.badge in [a.badge for a in person.assertions]:
        # TODO: Flash a message explaining that they already have the badge
        return HTTPFound(location=request.route_url('home'))

    result = request.db.add_assertion(request.context.badge_id,
                                      person.email,
                                      datetime.now())

    # TODO -- return them to a page that auto-exports their badges.
    # TODO -- flash and tell them they got the badge
    return HTTPFound(location=request.route_url('home'))
开发者ID:ArcticSphinx,项目名称:tahrir,代码行数:27,代码来源:views.py


示例19: view_index

def view_index(request):
    """
    View associated with the home page of the app.
    """
    main = get_renderer('templates/master.pt').implementation()
    if authenticated_userid(request) == None or 'user' not in request.session.keys():
        return HTTPFound(location='/')
    if 'current_test' in request.session.keys():
        request.session.pop('current_test') #remove current_test from session
    userinfo = request.session['user']
    messages = []
    messages.append("Welcome " + userinfo['name'] + " to pyquiz.")
    dbsession = DBSession()
    if authenticated_userid(request) == 'teacher':
        messages.append('You are currently teaching the following classes:')
    if authenticated_userid(request) == 'student':
        messages.append('You are currently enrolled in the following classes:')
    sections = []
    for c in userinfo['courses']:
        section = dbsession.query(Section).filter(
                                 Section.course_id == c).first()
        if section != None:
             sections.append(section)
    messages.append('')
#    if len(courses) == 0:
#        messages[2] == 'You have no classes' ##Depreceated due to SchoolTool integration? 
    for section in sections:
        section.url = 'course?id='+str(section.id)
    return {'messages': messages, 'sections': sections, 'main': main}
开发者ID:jboisture,项目名称:pyquiz,代码行数:29,代码来源:views.py


示例20: add_robot

def add_robot(request):
    message = ""
    if "form.submitted" in request.params:
        number = request.params["number"]
        wheels = request.params["wheels"]
        gearbox = request.params["gearbox"]
        drive_motors = request.params["drive_motors"]
        description = request.params["description"]
        shooter = "shooter" in request.params
        climb = "climb" in request.params
        human_loading = "human_loading" in request.params
        ground_loading = "ground_loading" in request.params
        scout = request.params["scout"]
        robot = Robot(
            number=number,
            wheels=wheels,
            gearbox=gearbox,
            description=description,
            shooter=shooter,
            climb=climb,
            human_loading=human_loading,
            scout=scout,
            ground_loading=ground_loading,
            is_scouted=True,
        )
        message = "A robot with that number allready exists"
        if DBSession.query(Robot).filter_by(number=number).first() is not None:
            return dict(robot=robot, message=message)
        DBSession.add(robot)
        robot = Robot()
        message = "Robot number {0} has been added".format(number)
        return dict(robot=robot, message=message, logged_in=authenticated_userid(request))
    robot = Robot()
    return dict(robot=robot, message=message, logged_in=authenticated_userid(request))
开发者ID:Nyle,项目名称:old-scouting,代码行数:34,代码来源:robot_views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python security.effective_principals函数代码示例发布时间:2022-05-27
下一篇:
Python common.parse_vars函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap