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


Python config.Config类代码示例

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


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

示例1: showHome

    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,代码行数:35,代码来源:home.py

示例2: emailAccountDeactivation

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,代码行数:33,代码来源:messaging.py

示例3: emailUnauthenticatedUser

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,代码行数:33,代码来源:messaging.py

示例4: emailResourceApproval

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,代码行数:33,代码来源:messaging.py

示例5: showHome

    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,代码行数:33,代码来源:home.py

示例6: emailProjectEndorsement

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,代码行数:33,代码来源:messaging.py

示例7: setUp

 def setUp(self):
     # HACK: We kept getting db.printing inexplicably set to True, so patch
     # it to be False here.
     _real_db_execute = web.db.DB._db_execute
     def _db_execute(self, cur, sql_query):
         self.printing = False
         return _real_db_execute(self, cur, sql_query)
     web.db.DB._db_execute = _db_execute
         
     # Set the dev flag in Config to False.
     Config.load()
     Config.data['dev'] = False
     
     # Set the debug flag to true, despite what is in the config file
     web.config.debug = False
     web.config.session_parameters['cookie_name'] = 'gam'
     
     # TODO: Clean up this initialization
     web.ctx.method = ''
     web.ctx.path = ''
     import StringIO
     web.ctx.env = {'wsgi.input': StringIO.StringIO(),
                    'REQUEST_METHOD': ''}
     
     # Set up the routes
     app = web.application(main.ROUTES, globals())
     
     # Grab a database connection
     self.db = main.sessionDB()
     
     # Initialize the session holder (I don't know what that is yet)
     #main.SessionHolder.set(web.session.Session(app, web.session.DBStore(db, 'web_session')))
     
     # Finally, create a test app
     self.app = TestApp(app.wsgifunc())
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:35,代码来源:project_tests.py

示例8: emailTempPassword

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,代码行数:35,代码来源:messaging.py

示例9: send

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,代码行数:28,代码来源:sms.py

示例10: test_load

 def test_load(self):
     """
     Test `load` method and that a config has been loaded.
     
     """
     Config.load()
     self.assertIsNotNone(Config.data)
     self.assertIsInstance(Config.data, dict)
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:8,代码来源:config-tests.py

示例11: getHomepageQuestion

 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,代码行数:14,代码来源:home.py

示例12: newProject

    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,代码行数:30,代码来源:createProject.py

示例13: getS3Path

 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,代码行数:7,代码来源:file_server.py

示例14: GET

 def GET(self, action = None):
     """
     Get for Blitz.io route
     
     """
     response = Config.get('blitz_io').get('response')
     return response
开发者ID:AltisCorp,项目名称:Change-By-Us,代码行数:7,代码来源:blitz.py

示例15: directMessageUser

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,代码行数:46,代码来源:messaging.py


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