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


Python security.authenticated_userid函数代码示例

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


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


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