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


Python Config.get方法代码示例

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


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

示例1: send

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
def send(phone, message):
    
    log.info("Sending sms...")    
    
    message = clean(message)
    
    settings = Config.get('twilio')
    account = twilio.Account(settings['sid'], settings['token'])
    callback = Config.base_url()
    if not callback:
        callback = Config.get('default_host')
    
    data = {    'From': settings['phone'],
                'To': phone,
                'Body': message,
                'StatusCallback': "%stwilio/status" % callback
                }
    log.debug(data)
    try:
        response = account.request('/%s/Accounts/%s/SMS/Messages.json' % (settings['api'], settings['sid']), 'POST', data)
        log.info("--> %s" % response)        
        response = json.loads(response)        
        smsid = response['TwilioResponse']['SMSMessage']['Sid']
        status = "passed"
    except Exception, e:
        log.error(e)
        smsid = None
        status = "blocked"        
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:30,代码来源:sms.py

示例2: showHome

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
    def showHome(self):
        """
        Sets up template data and renders homepage template.

        """
        homepage = Config.get("homepage")
        features = Config.get("features")

        locationData = mLocation.getSimpleLocationDictionary(self.db)
        allIdeasData = mIdea.getMostRecentIdeas(self.db, homepage["num_recent_ideas"])

        locations = dict(data=locationData, json=json.dumps(locationData))
        allIdeas = dict(data=allIdeasData, json=json.dumps(allIdeasData))

        news = self.getNewsItems()

        if bool(features.get("is_display_leaderboard")):
            leaderboardProjects = mProject.getLeaderboardProjects(self.db, 6)
            self.template_data["leaderboard"] = leaderboardProjects

        if bool(features.get("is_display_featured_projects")):
            featuredProjects = mProject.getFeaturedProjects(self.db, 6)
            self.template_data["featured_projects"] = featuredProjects

        if bool(features.get("is_community_leaders_displayed")):
            community_leaders = self.orm.query(models.CommunityLeader).order_by("`order`").all()
            self.template_data["community_leaders"] = community_leaders

        self.template_data["locations"] = locations
        self.template_data["all_ideas"] = allIdeas
        self.template_data["news"] = news

        return self.render("home", {"locations": locations, "all_ideas": allIdeas})
开发者ID:rblom,项目名称:Change-By-Us,代码行数:35,代码来源:home.py

示例3: emailAccountDeactivation

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [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

示例4: emailUnauthenticatedUser

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [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

示例5: emailTempPassword

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [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

示例6: emailResourceApproval

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [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

示例7: showHome

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
    def showHome(self):
        """
        Sets up template data and renders homepage template.

        """
        homepage = Config.get('homepage')
        features = Config.get('features')

        locationData = mLocation.getSimpleLocationDictionary(self.db)
        allIdeasData = mIdea.getMostRecentIdeas(self.db, homepage['num_recent_ideas']);

        locations = dict(data = locationData, json = json.dumps(locationData))
        allIdeas = dict(data = allIdeasData, json = json.dumps(allIdeasData))

        news = self.getNewsItems()

        if (bool(features.get('is_display_leaderboard'))):
            leaderboardProjects = mProject.getLeaderboardProjects(self.db, 6)
            self.template_data['leaderboard'] = leaderboardProjects

        if (bool(features.get('is_display_featured_projects'))):
            featuredProjects = mProject.getFeaturedProjects(self.db, 6)
            self.template_data['featured_projects'] = featuredProjects

        if (bool(features.get('is_community_leaders_displayed'))):
            community_leaders = self.orm.query(models.CommunityLeader) \
                .order_by('`order`') \
                .all()
            self.template_data['community_leaders'] = community_leaders

        self.template_data['locations'] = locations
        self.template_data['all_ideas'] = allIdeas
        self.template_data['news'] = news

        return self.render('home', {'locations':locations, 'all_ideas':allIdeas})
开发者ID:yuletide,项目名称:Change-By-Us,代码行数:37,代码来源:home.py

示例8: getHomepageQuestion

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
 def getHomepageQuestion(self):
     q = None
 
     if (Config.get('homepage').get('is_question_from_cms')):
         sql = "select question from homepage_question where is_active = 1 and is_featured = 1"
         data = list(self.db.query(sql))
         
         if (len(data) == 1):
             q = data[0].question
             
     if (not q):
         q = Config.get('homepage').get('question')
         
     return q
开发者ID:HugoButel,项目名称:Change-By-Us,代码行数:16,代码来源:home.py

示例9: emailProjectEndorsement

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [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

示例10: getS3Path

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
 def getS3Path(self, fileid):
     """
     Get the path to the file given by the fileid on the S3 server.
     
     """
     return "%(file_path)s/%(file_id)s" % {'file_path': Config.get('media').get('file_path'),
                                          'file_id': fileid}
开发者ID:HugoButel,项目名称:Change-By-Us,代码行数:9,代码来源:file_server.py

示例11: GET

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
 def GET(self, action = None):
     """
     Get for Blitz.io route
     
     """
     response = Config.get('blitz_io').get('response')
     return response
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:9,代码来源:blitz.py

示例12: newProject

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
    def newProject(self):
        if (self.request('main_text')): return False

        supported_features = Config.get('features')

        if (self.user):
            owner_user_id = self.user.id
            title = self.request('title')
            description = self.request('text')
            organization = self.request('organization')
            locationId = util.try_f(int, self.request('location_id'), -1)
            imageId = self.request('image')
            keywords = [word.strip() for word in self.request('keywords').split(',')] if not util.strNullOrEmpty(self.request('keywords')) else []
            resourceIds = self.request('resources').split(',')
            isOfficial = self.user.isAdmin and supported_features.get('is_official_supported')

            projectId = mProject.createProject(self.db, owner_user_id, title, description, ' '.join(keywords), locationId, imageId, isOfficial, organization)

            for resourceId in resourceIds:
                log.info("*** insert resource id %s" % resourceId)
                mProject.addResourceToProject(self.db, projectId, resourceId)

            if (projectId):
                return projectId
            else:
                log.error("*** couldn't create project")
                return False
        else:
            log.error("*** only logged in users can create projects")
            return False
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:32,代码来源:createProject.py

示例13: directMessageUser

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [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

示例14: getLocalPath

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
 def getLocalPath(self, fileid):
     """
     Get the path to the file given by the fileid on the local file system.
     This is used only to temporarily save the file before uploading it to
     the S3 server.
     
     """
     return "%(file_path)s/%(file_id)s" % {'file_path': Config.get('media').get('file_path'),
                                          'file_id': fileid}
开发者ID:HugoButel,项目名称:Change-By-Us,代码行数:11,代码来源:file_server.py

示例15: validate

# 需要导入模块: from framework.config import Config [as 别名]
# 或者: from framework.config.Config import get [as 别名]
def validate(request):    
    # this is just a cheap validate that depends on the attacker not knowing our AccountSid, it's not secure        
        
    settings = Config.get('twilio')        
    if request('AccountSid') != settings['sid']:
        log.error("Request from Twilio does not have correct sid! Possibly an attack! Blocking message.")
        log.error("--> was theirs [%s] vs ours [%s]" % (request('AccountSid'), settings['sid']))
        return False
    return True
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:11,代码来源:sms.py


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