當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。