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


Python Config.get_all方法代码示例

本文整理汇总了Python中framework.config.Config.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get_all方法的具体用法?Python Config.get_all怎么用?Python Config.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在framework.config.Config的用法示例。


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

示例1: emailProjectEndorsement

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailProjectEndorsement(email, title, leaderName):
    """
    Email project admins about endorsements.  Using template: project_endorsement
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    subject = "%s liked your project!" % leaderName
    template_values = {
        'title': title,
        'leader_name': leaderName,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/project_endorsement', template_values, suffix = 'txt')
         
    # Send email.
    try:
        return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])
    except Exception, e:
        log.info("*** couldn't send endorsement email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:35,代码来源:messaging.py

示例2: emailAccountDeactivation

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailAccountDeactivation(email):
    """
    Email deleted users.  Using template: account_deactivation
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    subject = "Your account has been deactivated"
    link = "%stou" % Config.get('default_host')
    template_values = {
        'link': link,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/account_deactivation', template_values, suffix = 'txt')

    # Send email.
    try:
        return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])
    except Exception, e:
        log.info("*** couldn't send account deactivation email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:35,代码来源:messaging.py

示例3: emailUnauthenticatedUser

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailUnauthenticatedUser(email, authGuid):
    """
    Send unauthenticated user a link to authenticate.  Using 
    template: auth_user
        
    @type   email: string
    @param  email: Email address to send to
    
    @rtype: *
    @returns: Emailer send response.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    subject = "Please authenticate your account"
    link = "%sjoin/auth/%s" % (Config.get('default_host'), authGuid)
    template_values = {
        'link': link,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/auth_user', template_values, suffix = 'txt')
            
    # Send email.            
    try:
        return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])  
    except Exception, e:
        log.info("*** couldn't send authenticate user email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:35,代码来源:messaging.py

示例4: emailTempPassword

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailTempPassword(email, password):
    """
    Email temporary password.  Using template: forgot_password
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    subject = "Your password has been reset"
    link = "%slogin" % Config.get('default_host')
    link = "%stou" % Config.get('default_host')
    template_values = {
        'password': password,
        'link': link,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/forgot_password', template_values, suffix = 'txt')

    # Send email.
    try:
        return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])
    except Exception, e:
        log.info("*** couldn't send forgot password email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:37,代码来源:messaging.py

示例5: emailResourceApproval

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailResourceApproval(email, title):
    """
    Email resource owner on approval.  Using template: resource_approval
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    subject = "Your resource has been approved"
    template_values = {
        'link': Config.get('default_host'),
        'title': title,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/resource_approval', template_values, suffix = 'txt')

    # Send email.
    try:
        return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])  
    except Exception, e:
        log.info("*** couldn't send resource approval email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:35,代码来源:messaging.py

示例6: test_get_all

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
 def test_get_all(self):
     """
     Test `get_all` method
     
     """
     data = Config.get_all()
     self.assertIsNotNone(data)
     self.assertIsInstance(data, dict)
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:10,代码来源:config-tests.py

示例7: test_manualSetConfig

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
 def test_manualSetConfig(self):
     """
     Test manually setting a value.
     
     """
     # Assert that value is not there
     self.assertNotIn('testing', Config.data)
     
     # Set new value and assert it is there
     Config.data['testing'] = True
     data = Config.get_all()
     self.assertTrue(data['testing'])
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:14,代码来源:config-tests.py

示例8: directMessageUser

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def directMessageUser(db, toUserId, toName, toEmail, fromUserId, fromName, message):
    """
    Email user about direct message.  Using template: direct_message
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    #email = "%s <%s>" % (toName, toEmail)
    email = toEmail
    subject = "Change By Us message from %s" % fromName
    link = "%suseraccount/%s" % (Config.get('default_host'), fromUserId)
    template_values = {
        'name': fromName,
        'message': message,
        'link': link,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/direct_message', template_values, suffix = 'txt')

    # Send email.
    try:
        isSent = Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])
                                                       
        if (isSent):
            db.insert('direct_message', message = message, to_user_id = toUserId, from_user_id = fromUserId)
            return True
        else:
            log.info("*** couldn't log direct message")
            # Not sure if best to return False
            return False

    except Exception, e:
        log.info("*** couldn't send direct message email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:48,代码来源:messaging.py

示例9: emailResourceNotification

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailResourceNotification(email, projectId, title, description, resourceName):
    """
    Email resource contacts on resource add.  Using template: resource_notification
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    subject = "A project on Changeby.us has added %s as a resource" % resourceName
    link = "%sproject/%s" % (Config.get('default_host'), str(projectId))
    template_values = {
        'title': title,
        'description': description,
        'resource_name': resourceName,
        'link': link,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/resource_notification', template_values, suffix = 'txt')
    
    # If dev, don't email resources
    if (Config.get('dev')):
        log.info("*** body = %s" % body)
        return True

    # Send email.
    try:
        return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])
    except Exception, e:
        log.info("*** couldn't send resource notification email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:43,代码来源:messaging.py

示例10: emailProjectJoin

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailProjectJoin(email, projectId, title, userId, userName):
    """
    Email project admins when new user joins.  Using template: project_join
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    defaultUrl = Config.get('default_host')
    subject = "A new member %s has joined your project %s" % (userName, title)
    userLink = "%suseraccount/%s" % (defaultUrl, str(userId))
    memberLink = "%sproject/%s#show,members" % (defaultUrl, str(projectId))
    template_values = {
        'title': title,
        'user_name': userName,
        'user_link': userLink,
        'member_link': memberLink,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/project_join', template_values, suffix = 'txt')
         
    # Send email.
    try:
        return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])
    except Exception, e:
        log.info("*** couldn't send join email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:40,代码来源:messaging.py

示例11: emailIdeaConfirmation

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailIdeaConfirmation(email, responseEmail, locationId):
    """
    Email upon idea submission.  Using template: idea_confirmation
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    host = Config.get('default_host')
    subject = "Thanks for submitting an idea to Change by Us!"
    searchLink = "%ssearch?location_id=%s" % (host, locationId)
    createLink = "%screate" % host
    template_values = {
        'search_link': searchLink,
        'create_link': createLink,
        'response_email': emailAccount['from_email'],
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/idea_confirmation', template_values, suffix = 'txt')

    # Send email.
    try:
        return Emailer.send(email, subject, body, from_name = emailAccount['from_name'],
            from_address = emailAccount['from_email'])
    except Exception, e:
        log.info("*** couldn't send authenticate user email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:39,代码来源:messaging.py

示例12: emailInvite

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
def emailInvite(email, inviterName, projectId, title, description, message = None):
    """
    Send invitation email.  Using template: project_invite
        
    @type   email: string
    @param  email: Email address to send to
    ...
    
    @rtype: Boolean
    @returns: Whether emailer was successful or not.
    
    """
    
    # Create values for template.
    emailAccount = Config.get('email')
    subject = "You've been invited by %s to join a project" % inviterName
    link = "%sproject/%s" % (Config.get('default_host'), str(projectId))
    template_values = {
        'inviter': inviterName,
        'title':title,
        'description':description,
        'link': link,
        'message': message,
        'config': Config.get_all()
    }
    
    # Render email body.
    body = Emailer.render('email/project_invite', template_values, suffix = 'txt')     
    
    # Send email.
    try:
        return Emailer.send(email, subject,  body, from_name = emailAccount['from_name'], 
            from_address = emailAccount['from_email'])  
    except Exception, e:
        log.info("*** couldn't send invite email")
        log.error(e)
        return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:39,代码来源:messaging.py

示例13: render

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get_all [as 别名]
    def render(self, template_name, template_values=None, suffix="html", content_type = "text/html", status="200 OK"):
        """
        Custom renderer for Change by Us templates.

        @type   template_name: string
        @param  template_name: Name of template (without extension)
        @type   template_values: dict
        @param  template_values: Values to include in the template.
        @type   suffix: string
        @param  suffix: Extension of template file.
        @type   content_type: string
        @param  content_type: HTTP header content type to output.

        @rtype: ?
        @returns: ?

        """
        if template_values is None:
            template_values = {}

        # Set the user object in case it's been created since we initialized.
        self.setUserObject()

        # Hand all config values to the template.  This method is deprecated
        # but around until all templates have been updated.
        config = Config.get_all()

        config['base_url'] = Config.base_url()
        for key in config:
            if type(config[key]) is dict:
                for param in config[key]:
                    template_values["%s_%s" % (key, param)] = config[key][param]
            else:
                template_values[key] = config[key]

        # Give all config values as a dict in a config space.
        template_values['config'] = config

        # Send user data to template
        if self.user:
            template_values['user'] = self.user
            template_values['sqla_user'] = self.sqla_user

        # Add template data object
        if self.template_data:
            template_values['template_data'] = self.template_data

        # Create full URL from web.py values
        template_values['full_url'] = web.ctx.home + web.ctx.fullpath

        # Check for "flash"?
        if hasattr(self.session, 'flash') and self.session.flash is not None:
            template_values['flash'] = self.session.flash
            log.info('showing flash message: "' + self.session.flash + '"')
            self.session.flash = None
            self.session.invalidate()

        template_values['session_id'] = self.session.session_id

        # Put session values into template ??
        keys = self.session.keys()
        for key in keys:
            template_values[key] = self.session[key]

        # Set up template and Jinja
        template_values['template_name'] = template_name
        renderer = render_jinja(os.path.dirname(__file__) + '/../templates/',
            extensions=['jinja2.ext.i18n',
                        'jinja2.ext.with_',])
        renderer._lookup.filters.update(custom_filters.filters)

        # Install the translation
        translation = self.get_gettext_translation(self.get_language())
        renderer._lookup.install_gettext_translations(translation)

        # Insert HTML for the language chooser
        curr_lang = self.get_language()
        all_langs = self.get_supported_languages()

        template_values['language'] = {"current": curr_lang, "list":
                all_langs.iteritems()}

        template_values['language_selector'] = self.choice_list(
            all_langs, curr_lang)

        # Set HTTP header
        web.header("Content-Type", content_type)

        # Debug data.
        log.info("%s: %s (%s)" % (status, content_type, template_name))
        log.info("*** session  = %s" % self.session)

        # Set status
        web.ctx.status = status

        # Return template and data.
        return (renderer[template_name + "." + suffix](dict(d=template_values))).encode('utf-8')
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:99,代码来源:controller.py


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