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

Python i18n._函数代码示例

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

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



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

示例1: get

	def get(self, urlsafeCartKey):
		try:
			cart = ndb.Key(urlsafe=urlsafeCartKey).get()
			if cart:
				if cart.d: self.forkCart_form.description.data = cart.d
				if cart.cat: self.forkCart_form.category.data = cart.cat

				params = {
					"forkCartForm" : self.forkCart_form, \
					"cartDetailsForm" : self.cartDetails_form, \
					"urlsafeCartKey": urlsafeCartKey, \
					"cart": cart, \
					}
				self.bournee_template('forkCartForm.html', **params)
			else:
				logging.error("Could not find cart in function GET of class MakeCartPublicFormHandler")
				message = _('There was an Error fetching the cart data. We can not complete request at this time. Please try again later')
				self.add_message(message, 'error')
				try:
					self.redirect(self.request.referer)
				except:
					self.redirect_to('home')
		except Exception as e:
			logging.error("Error occurred running function GET of class MakeCartPublicFormHandler: -- %s" % str(e))
			message = _('There was an Error on the servers. We can not complete request at this time. Please try again later')
			self.add_message(message, 'error')
			try:
				self.redirect(self.request.referer)
			except:
				self.redirect_to('home')
开发者ID:JElbourne,项目名称:PubCart,代码行数:30,代码来源:cartHandlers.py


示例2: get

    def get(self, provider_name):
        provider_display_name = models.SocialUser.PROVIDERS_INFO[provider_name]['label']
        if not config.enable_federated_login:
            message = _('Federated login is disabled.')
            self.add_message(message, 'warning')
            return self.redirect_to('login')

        #OAuth Shizzle    
        callback_url = "%s/social_login/%s/complete" % (self.request.host_url, provider_name)
        
        # twitter madness (seriously, what's the deal with them?)
        if provider_name == "twitter":
            twitter_helper = twitter.TwitterAuth(self, redirect_uri=callback_url)
            self.redirect( twitter_helper.auth_url() )

        # github stores the callback URL in the app settings on their site, so we don't pass it here
        # you can register a new app at https://github.com/settings/applications/
        elif provider_name == "github":
            scope = 'gist'
            github_helper = github.GithubAuth(scope)
            self.redirect( github_helper.get_authorize_url() )

        else:
            message = _('%s authentication is not yet implemented.' % provider_display_name)
            self.add_message(message, 'warning')
            self.redirect_to('edit-profile')
开发者ID:StackGeek,项目名称:stackgeek-gaeb,代码行数:26,代码来源:userhandlers.py


示例3: _set_fields

 def _set_fields(self, form):
     setattr(form, 'email',TextField(_(u'E-mail Address'), [validators.Email(message=_(u'Invalid email address.'))]))
     if self.get_provider_services():
         setattr(form, 'service', SelectField(_(u'Service'), choices=self.get_provider_services()))
     setattr(form, 'comments', TextAreaField(_(u'Comments for your appointment')))
     setattr(form, 'booking_date', HiddenField('booking_date'))
     setattr(form, 'booking_time', HiddenField('booking_time'))
开发者ID:deltron,项目名称:veosan,代码行数:7,代码来源:booking.py


示例4: get

    def get(self, token_id):
        # Session request handler
        current_session = Session(self)
        JINJA_ENVIRONMENT.globals['session'] = current_session
        # Language request handler
        Language.language(self)
        # Load jinja template
        template = JINJA_ENVIRONMENT.get_template('static/templates/activation.html')

        # Check if token is expired
        token = database.TokenManager.select_token_by_id(int(token_id))
        if token and (datetime.datetime.now() - datetime.timedelta(days=1) < token.date) and (not token.used):
            # Activate user
            user = token.user.get()
            # Check if user is already activated
            if user.role_level > 0:
                errorMessage = _("AccountAlreadyActivated")
            else:
                errorMessage = None
            database.UserManager.modify_user(user.key, role_level=1)
            # Set token as used
            database.TokenManager.set_used_token(token.key)
        else:
            errorMessage = _("ExpiredTokenOrNotExist")
        # Prompt activation result
        self.response.write(template.render(error=errorMessage))
开发者ID:jipvazoj,项目名称:ProyectosMasterAritz,代码行数:26,代码来源:kaixomundua.py


示例5: post

    def post(self):
        """ Get fields from POST dict """

        checked_genres = self.request.POST.getall('genres')

        pseudonyms = self.request.POST.get('pseudonyms').replace('  ', ' ').replace(' ,', ',').split(',')
        pseudonyms = [i.lstrip().rstrip() for i in pseudonyms]

        # k = models.User.get_by_id(long(self.user_id)).key
        print checked_genres
        print pseudonyms

        author_profile = bmodels.AuthorProfile.get_by_userkey(self.user_key)
        if not author_profile:
            author_profile = bmodels.AuthorProfile()
            author_profile.user = self.user_key

        try:
            message = ''
            author_profile.title = self.request.POST.get('title')
            author_profile.overview = self.request.POST.get('overview').replace('\r\r\n', '\r\n')
            author_profile.freelance = (self.request.POST.get('freelance') == "True")
            author_profile.ghostwrites = (self.request.POST.get('ghostwrites') == "True")
            author_profile.genres = checked_genres
            author_profile.pseudonyms = pseudonyms
            author_profile.put()
            message += " " + _('Your author profile has been updated.')
            self.add_message(message, 'success')
            self.redirect('/settings/profile')

        except (AttributeError, KeyError, ValueError), e:
            logging.error('Error creating/updating author profile: ' + e)
            message = _('Unable to create/update author profile. Please try again later.')
            self.add_message(message, 'error')
            return self.get()
开发者ID:rchaber,项目名称:publishbay,代码行数:35,代码来源:handlers.py


示例6: get

    def get(self):
        params = {}
        target_user_id = int(self.request.get('user_id', '0'))
        if not target_user_id:
            message = _('User id unavailable. Please try again later.')
            self.add_message(message, 'error')
            return self.redirect_to('show-listings')
        if int(self.user_id) == target_user_id:
            # Viewing logged-in user's profile. Go to profile edit page instead.
            return self.redirect_to('edit-profile')
        u = self.user_model.get_by_id(target_user_id)
        if not u:
            message = _('Could not find user. Please try again later.')
            self.add_message(message, 'error')
            return self.redirect_to('show-listings')
        params['target_user'] = u

        # Check our profile for completeness.
        me = self.user_model.get_by_id(long(self.user_id))
        if ((me.get_full_name == '[Anonymous user]') or
            not me.city or not me.state):
            warning_msg = 'Please <a href="/settings/profile">complete your profile</a>, so that others can see where you\'re coming from, and what you need/have for the event.'
            self.add_message(warning_msg, 'error')
            return self.redirect_to('edit-profile')
        return self.render_template('share_detail.html', **params)
开发者ID:srijib,项目名称:surrender-rides,代码行数:25,代码来源:handlers.py


示例7: post

    def post(self):
        """ Get fields from POST dict """

        if not self.form.validate():
            return self.get()
        username = self.form.username.data.lower()
        name = self.form.name.data.strip()
        last_name = self.form.last_name.data.strip()
        country = self.form.country.data
        tz = self.form.tz.data

        try:
            user_info = self.user_model.get_by_id(long(self.user_id))

            try:
                message = ''
                # update username if it has changed and it isn't already taken
                if username != user_info.username:
                    user_info.unique_properties = ['username', 'email']
                    uniques = [
                        'User.username:%s' % username,
                        'User.auth_id:own:%s' % username,
                    ]
                    # Create the unique username and auth_id.
                    success, existing = Unique.create_multi(uniques)
                    if success:
                        # free old uniques
                        Unique.delete_multi(
                            ['User.username:%s' % user_info.username, 'User.auth_id:own:%s' % user_info.username])
                        # The unique values were created, so we can save the user.
                        user_info.username = username
                        user_info.auth_ids[0] = 'own:%s' % username
                        message += _('Your new username is <strong>{}</strong>').format(username)

                    else:
                        message += _(
                            'The username <strong>{}</strong> is already taken. Please choose another.').format(
                            username)
                        # At least one of the values is not unique.
                        self.add_message(message, 'error')
                        return self.get()
                user_info.name = name
                user_info.last_name = last_name
                user_info.country = country
                user_info.tz = tz
                user_info.put()
                message += " " + _('Thanks, your settings have been saved.')
                self.add_message(message, 'success')
                return self.get()

            except (AttributeError, KeyError, ValueError), e:
                logging.error('Error updating profile: ' + e)
                message = _('Unable to update profile. Please try again later.')
                self.add_message(message, 'error')
                return self.get()

        except (AttributeError, TypeError), e:
            login_error_message = _('Your session has expired.')
            self.add_message(login_error_message, 'error')
            self.redirect_to('login')
开发者ID:jcarrasko,项目名称:alf4gae,代码行数:60,代码来源:handlers.py


示例8: get

    def get(self):
        render_notice = lambda values: self.render("noticepage", values)

        successful = self.request.get("successful", None)
        if successful == "1":
            values = {
                    "message": _("You successfully signed in, welcome back!"),
                    "redirect": self.request.get("referer"),
                    }
            return render_notice(values)
        elif successful == "0":
            values = {
                    "message": _("Login failed, invalid password or user doesn't exist, you could try again."),
                    "redirect": self.uri_for("login"),
                    }
            return render_notice(values)
        elif successful == "-1":
            values = {
                    "message": _("The user is valid but not verified,\
                            check your email to find the confirmation link\
                            we sent to you when you registered."),
                    "redirect": None,
                    }
            return render_notice(values)
        else:
            if self.get_current_user() != None:
                values = {
                        "message": _("You've logged in, why do you want to do this again?"),
                        "redirect": self.uri_for("home"),
                        }
                return render_notice(values)
            else:
                values = { "referer": self.request.headers.get("Referer", self.uri_for("home")) }
                self.render("loginpage", values)
开发者ID:phaikawl,项目名称:Guss,代码行数:34,代码来源:user_auth.py


示例9: get

    def get(self, provider_name):
        provider_display_name = models.SocialUser.PROVIDERS_INFO[provider_name]['label']
        if not config.enable_federated_login:
            message = _('Federated login is disabled.')
            self.add_message(message,'warning')
            return self.redirect_to('login')
        callback_url = "%s/social_login/%s/complete" % (self.request.host_url, provider_name)
        if provider_name == "twitter":
            twitter_helper = twitter.TwitterAuth(self, redirect_uri=callback_url)
            self.redirect(twitter_helper.auth_url())
        if provider_name == "facebook":
			fb = facebook.Facebook(config._FbApiKey, config._FbSecret)
			#~ print "HTTP/1.1\n"
			#~ print fb.get_authorize_url('http://localhost:9090')
			#~ return 
			print fb.get_ext_perm_url('')
			print fb.login('')
			return
			fb.auth.createToken()
			fb.login(popup=True)
			#~ print fb.get_add_url('http://localhost') 
        else:
            message = _('%s authentication is not implemented yet.') % provider_display_name
            self.add_message(message,'warning')
            self.redirect_to('edit-profile')
开发者ID:sabirmostofa,项目名称:app-engine-facebook,代码行数:25,代码来源:handlers.py


示例10: post

    def post(self):
        """ Get fields from POST dict """

        manuscript_id = self.request.POST.get('manuscript_id')
        manuscript = bmodels.Manuscript.get_by_id(long(manuscript_id))
        upload_full_manuscript = self.get_uploads()

        if upload_full_manuscript:
            try:
                blobstore.delete(manuscript.full_manuscript_key)
            except:
                pass
            full_manuscript_key = upload_full_manuscript[0].key()
            full_manuscript_filename = upload_full_manuscript[0].filename
            full_manuscript_uploaded_on = datetime.now()
        else:
            full_manuscript_key = None

        pprint(upload_full_manuscript[0].__dict__)
        print upload_full_manuscript[0].filename
        print full_manuscript_key

        try:
            message = ''
            manuscript.full_manuscript_key = full_manuscript_key
            manuscript.full_manuscript_filename = full_manuscript_filename
            manuscript.full_manuscript_uploaded_on = full_manuscript_uploaded_on
            manuscript.put()
            message += " " + _('Full manuscript successfully uploaded.')
            self.add_message(message, 'success')

        except (AttributeError, KeyError, ValueError), e:
            logging.error('Error creating/updating manuscript: ' + e)
            message = _('Unable to create/update manuscript. Please try again later.')
            self.add_message(message, 'error')
开发者ID:rchaber,项目名称:publishbay,代码行数:35,代码来源:author_handlers.py


示例11: _set_fields

 def _set_fields(self, form):        
     setattr(form, 'email', TextField(_(u'Email'),
                             validators=[validators.Email(message=_(u'Invalid email address.'))],
                             filters=[custom_filters.to_lowercase]           
                         ))
     setattr(form, 'password', PasswordField(_(u'Password')))
     setattr(form, 'remember_me', CustomBooleanField(_(u'Remember Me')))
开发者ID:deltron,项目名称:veosan,代码行数:7,代码来源:user.py


示例12: _post

 def _post(self):
     username = self.request.get("username")
     email = self.request.get("email")
     model = UserModel(verified=False)
     model.assign(self)
     if model.validate():
         if config.get_config("user_email_confirm") == "yes":
             model.put()
             user_confirm.send_confirmation_mail(username, email)
             values = {
                     "message": _(u"""An email that contains the link to activate the account \
                         has been sent to the email"""),
                     "redirect": None,
                     }
             return self.render("noticepage", values)
         else:
             model.verified = True
             user_key = model.put()
             rbac.add_role(user_key, rbac.default_role("registered"))
             values = {
                     "message": _(u"""Successfully registered."""),
                     "redirect": None,
                     }
             return self.render("noticepage", values)
     else:
         values = {
                 "model": model
                 }
         return self.render("admin_user_add", values)
开发者ID:phaikawl,项目名称:Guss,代码行数:29,代码来源:admin_user.py


示例13: get_all_note_types

def get_all_note_types():
    return [('call', _(u'Call')),
            ('email', _(u'Email')),
            ('meeting', _(u'Meeting')),
            ('info', _(u'Info')),
            ('admin', _(u'Admin')),
            ]
开发者ID:deltron,项目名称:veosan,代码行数:7,代码来源:util.py


示例14: post

    def post(self):
        """
              validate contact form
        """
        if not self.form.validate():
            return self.get()
        remoteip  = self.request.remote_addr
        user_agent  = self.request.user_agent
        name = self.form.name.data.strip()
        email = self.form.email.data.lower()
        message = self.form.message.data.strip()

        try:
            subject = _("Contact")
            body = """
            IP Address : %s
            Web Browser  : %s

            Sender : %s <%s>
            %s
            """ % (remoteip, user_agent, name, email, message)

            utils.send_email(config.contact_recipient, subject, body)

            message = _('Message sent successfully.')
            self.add_message(message, 'success')
            return self.redirect_to('contact')

        except (AttributeError, KeyError), e:
            message = _('Error sending the message. Please try again later.')
            self.add_message(message, 'error')
            return self.redirect_to('contact')
开发者ID:grisaitis,项目名称:gae-puns,代码行数:32,代码来源:handlers.py


示例15: email_booking_to_patient

def email_booking_to_patient(handler, booking, activation_url=None):
    ''' send booking info to patient, provider and us '''
    patient = booking.patient.get()
    provider = booking.provider.get()
    to_address = patient.email
    # check email valid
    if not mail.is_email_valid(to_address):
        logging.warn('Email is not valid: %s -- trying anyway...' % to_address)
        
    # create message
    message = mail.EmailMessage()
    message.sender = "Veosan" + ' <' + VEOSAN_SUPPORT_ADDRESS + '>'
    message.to = to_address
    category_label = dict(util.get_all_categories_all_domains())[provider.category]
    message.subject = '%s - %s' % (_(u'Veosan Appointment'), _(category_label).capitalize())
    
    kw = {'booking': booking, 'activation_url': activation_url}
    logging.debug('activation url for email: %s' % activation_url)
    message.body = render_booking_email_body(handler.jinja2, 'email/patient_booking.txt', **kw)
    
    try:
        logging.info('Sending booking email to provider %s' % patient.email)
        message.send()
        
        booking.email_sent_to_patient = True
        booking.put()
    except Exception as e:
        logging.error('Email to patient not sent. %s' % e)
开发者ID:deltron,项目名称:veosan,代码行数:28,代码来源:mail.py


示例16: get

    def get(self, user_id, token):
        try:
            if not self.user_model.validate_auth_token(user_id, token):
                message = _('The link is invalid.')
                self.add_message(message, 'danger')
                return self.redirect_to('home')

            user = self.user_model.get_by_id(long(user_id))
            # activate the user's account
            user.activated = True
            user.put()

            # Update all invites that this user's email have been invited to
            UpdateUserOnAttendeesCommand(user).execute()


            # Login User
            self.auth.get_user_by_token(int(user_id), token)

            # Delete token
            self.user_model.delete_auth_token(user_id, token)

            message = _('Congratulations, Your account <strong>{}</strong> has been successfully activated.').format(
                user.username)
            self.add_message(message, 'success')
            self.redirect_to('edit-profile')

        except (AttributeError, KeyError, InvalidAuthIdError, NameError), e:
            logging.error("Error activating an account: %s" % e)
            message = _('Sorry, Some error occurred.')
            self.add_message(message, 'danger')
            return self.redirect_to('home')
开发者ID:xplot,项目名称:imeet,代码行数:32,代码来源:profile.py


示例17: get_all_titles

def get_all_titles():
    return [
            ("mr", _('Mr.')),
            ("mrs", _('Mrs.')),
            ("ms", _('Ms.')),
            ("dr", _('Dr.')),
            ]
开发者ID:deltron,项目名称:veosan,代码行数:7,代码来源:util.py


示例18: send_forgot_email

def send_forgot_email(the_req, the_email, the_url):

    set_locale_for_user(the_req)

    if not mail.is_email_valid(the_email):
        logging.error("send_forgot_email invalid email: {0}".format(the_email))
        return False
        
    message = mail.EmailMessage()
    message.sender = SENDER_EMAIL
    message.to = the_email
    message.subject = _('Gig-o-Matic Password Reset')
#     message.body = u"""
# Hello! To reset your Gig-o-Matic password, click the link below.
# 
# {0}
# 
# Thanks,
# The Gig-o-Matic Team
# 
#     """.format(the_url)

    message.body = _('forgot_password_email').format(the_url)

    try:
        message.send()
    except:
        logging.error('failed to send email!')
        
    return True
开发者ID:ChaoticNoise,项目名称:GO2,代码行数:30,代码来源:goemail.py


示例19: send_registration_email

def send_registration_email(the_req, the_email, the_url, the_locale_override=None):

    set_locale_for_user(the_req, the_locale_override)

    if not mail.is_email_valid(the_email):
        return False
        
    message = mail.EmailMessage()
    message.sender = SENDER_EMAIL
    message.to = the_email
    message.subject = _('Welcome to Gig-o-Matic')
#     message.body = u"""
# Hello! You have registered to join Gig-o-Matic - click the link below to log in and you're good to go. (The link
# is good for 48 hours - after that you can just register again to get a new one if you need it.)
# 
# {0}
# 
# Thanks,
# The Gig-o-Matic Team
# 
#     """.format(the_url)
    message.body=_('welcome_msg_email').format(the_url)
    
    try:
        message.send()
    except:
        logging.error('failed to send email!')
        
    return True
开发者ID:ChaoticNoise,项目名称:GO2,代码行数:29,代码来源:goemail.py


示例20: send_band_accepted_email

def send_band_accepted_email(the_req, the_email, the_band):

    set_locale_for_user(the_req)

    if not mail.is_email_valid(the_email):
        return False
        
    message = mail.EmailMessage()
    message.sender = SENDER_EMAIL
    message.to = the_email
    message.subject = _('Gig-o-Matic: Confirmed!')
#     message.body = u"""
# Hello! You have been confirmed as a member of {0} and can now start using Gig-o-Matic to manage your band life.
# 
# http://gig-o-matic.appspot.com/band_info.html?bk={1}
# 
# Thanks,
# The Gig-o-Matic Team
# 
#     """.format(the_band.name, the_band.key.urlsafe())
    message.body = _('member_confirmed_email').format(the_band.name, the_band.key.urlsafe())

    try:
        message.send()
    except:
        logging.error('failed to send email!')
        
    return True
开发者ID:ChaoticNoise,项目名称:GO2,代码行数:28,代码来源:goemail.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python i18n.get_i18n函数代码示例发布时间:2022-05-26
下一篇:
Python auth.get_user_by_session函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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