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


Python config.update函数代码示例

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


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

示例1: setUp

 def setUp(self):
     self.defaultview = config.get('tg.defaultview', 'kid')
     config.update({
         'toscawidgets.on': True,
         'tg.defaultview': 'genshi'
     })
     super(ToscaWidgetsTest, self).setUp()
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:7,代码来源:test_toscawidgets.py

示例2: register_static_directory

def register_static_directory(modulename, directory):
    """
    Sets up a static directory for JavaScript and css files. You can refer
    to this static directory in templates as ${tg.widgets}/modulename
    """
    directory = os.path.abspath(directory)
    config.update({"/tg_widgets/%s" % modulename: {"static_filter.on": True, "static_filter.dir": directory}})
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:base.py

示例3: enable_csrf

def enable_csrf():
    '''A startup function to setup :ref:`CSRF-Protection`.

    This should be run at application startup.  Code like the following in the
    start-APP script or the method in :file:`commands.py` that starts it::

        from turbogears import startup
        from fedora.tg.util import enable_csrf
        startup.call_on_startup.append(enable_csrf)

    If we can get the :ref:`CSRF-Protection` into upstream :term:`TurboGears`,
    we might be able to remove this in the future.

    .. versionadded:: 0.3.10
       Added to enable :ref:`CSRF-Protection`
    '''
    # Override the turbogears.url function with our own
    # Note, this also changes turbogears.absolute_url since that calls
    # turbogears.url
    turbogears.url = url
    turbogears.controllers.url = url

    # Ignore the _csrf_token parameter
    ignore = config.get('tg.ignore_parameters', [])
    if '_csrf_token' not in ignore:
        ignore.append('_csrf_token')
        config.update({'tg.ignore_parameters': ignore})

    # Add a function to the template tg stdvars that looks up a template.
    turbogears.view.variable_providers.append(add_custom_stdvars)
开发者ID:fandikurnia,项目名称:python-fedora,代码行数:30,代码来源:utils.py

示例4: test_new_text_format

    def test_new_text_format(self):
        """Verify that our view is able to send new text format to Genshi."""

        # make sure we have asked for new format in the config
        new_syntax = config.get("genshi.new_text_syntax", False)
        config.update({"genshi.new_text_syntax": True})
        # we need to reload the engines for the config changes to take effect
        view.load_engines()

        # load our expected result in memory
        expected_result = 'Dear Florent Aide\nYour items:\n  * Apples\n  * Bananas\n  * Cherries\n\n'

        info = dict(
            name=u"Florent Aide",
            itemlist=[u'Apples', u'Bananas', u'Cherries']
        )
        template = "genshi-text:turbogears.tests.genshi_new_text_format"
        headers = {}
        val = view.render(info, template, headers=headers, format="text")
        config.update({"genshi.new_text_syntax": new_syntax})

        print "Got this:"
        print "*" * 35
        print "%r" % val
        print "*" * 35
        print "Expected that:"
        print "*" * 35
        print "%r" % expected_result
        print "*" * 35
        assert val == expected_result
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:30,代码来源:test_view.py

示例5: test_invalid_createrepo_command_fail

 def test_invalid_createrepo_command_fail(self):
     update({'beaker.createrepo_command': 'iamnotarealcommand'})
     rpm_file = pkg_resources.resource_filename('bkr.server.tests', \
         'tmp-distribution-beaker-task_test-2.0-5.noarch.rpm')
     copy(rpm_file, self.tasklibrary.rpmspath)
     with self.assertRaises(OSError):
         self.tasklibrary.update_repo()
开发者ID:sujithshankar,项目名称:beaker,代码行数:7,代码来源:test_model.py

示例6: test_content_types

 def test_content_types(self):
     info = dict(someval="someval")
     template = "turbogears.tests.simple"
     headers = {}
     view.render(info, template, headers=headers)
     assert headers.get('Content-Type') == 'text/html; charset=utf-8'
     headers = {}
     view.render(info, template, headers=headers, format='html')
     assert headers.get('Content-Type') == 'text/html; charset=utf-8'
     headers = {}
     view.render(info, template, headers=headers, format='html-strict')
     assert headers.get('Content-Type') == 'text/html; charset=utf-8'
     headers = {}
     view.render(info, template, headers=headers, format='xhtml')
     assert headers.get('Content-Type') == 'text/html; charset=utf-8'
     headers = {}
     view.render(info, template, headers=headers, format='xhtml-strict')
     assert headers.get('Content-Type') == 'text/html; charset=utf-8'
     headers = {}
     view.render(info, template, headers=headers, format='xml')
     assert headers.get('Content-Type') == 'text/xml; charset=utf-8'
     headers = {}
     view.render(info, template, headers=headers, format='json')
     assert headers.get('Content-Type') == 'application/json'
     config.update({'global':
         {'tg.format_mime_types': {'xhtml': 'application/xhtml+xml'}}})
     headers = {}
     view.render(info, template, headers=headers, format='xhtml')
     assert headers.get('Content-Type') == 'application/xhtml+xml; charset=utf-8'
     headers = {}
     view.render(info, template, headers=headers, format='xhtml-strict')
     assert headers.get('Content-Type') == 'application/xhtml+xml; charset=utf-8'
     config.update({'global': {'tg.format_mime_types': {}}})
开发者ID:OnShift,项目名称:turbogears,代码行数:33,代码来源:test_view.py

示例7: test_default_output_encoding

 def test_default_output_encoding(self):
     info = dict(someval="someval")
     # default encoding is utf-8
     val = view.render(info, template="turbogears.tests.simple")
     assert 'utf-8' in view.cherrypy.response.headers["Content-Type"]
     config.update({'tg.defaultview':'kid', 'kid.encoding':'iso-8859-1'})
     val = view.render(info, template="turbogears.tests.simple")
     assert 'iso-8859-1' in view.cherrypy.response.headers["Content-Type"]
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_view.py

示例8: test_authenticate_header

 def test_authenticate_header(self):
     """Test that identity returns correct WWW-Authenticate header."""
     response = self.app.get('/logged_in_only', status=403)
     assert 'WWW-Authenticate' not in response.headers
     config.update({'identity.http_basic_auth': True,
                    'identity.http_auth_realm': 'test realm'})
     response = self.app.get('/logged_in_only', status=401)
     assert response.headers['WWW-Authenticate'] == 'Basic realm="test realm"'
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:8,代码来源:test_identity.py

示例9: test_redirect

 def test_redirect(self):
     config.update({"server.webpath": "/coolsite/root"})
     response = self.app.get("/redirect")
     assert response.location == 'http://localhost:80/coolsite/root/foo'
     self.app.get("/raise_redirect")
     assert response.location == 'http://localhost:80/coolsite/root/foo'
     self.app.get("/relative_redirect")
     assert response.location == 'http://localhost:80/coolsite/root/foo'
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:8,代码来源:test_controllers.py

示例10: test_redirect

 def test_redirect(self):
     config.update({"server.webpath": "/coolsite/root"})
     startup.startTurboGears()
     testutil.create_request("/coolsite/root/subthing/")
     try:
         redirect("/foo")
         assert False, "redirect exception should have been raised"
     except cherrypy.HTTPRedirect, e:
         assert "http://localhost/coolsite/root/subthing/foo" in e.urls
开发者ID:dikoufu,项目名称:turbogears,代码行数:9,代码来源:test_controllers.py

示例11: start_server

def start_server():
    """Start the server if it's not already started."""
    if not config.get("cp_started"):
        cherrypy.server.start(server_class=None, init_only=True)
        config.update({"cp_started" : True})

    if not config.get("server_started"):
        startup.startTurboGears()
        config.update({"server_started" : True})
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:9,代码来源:testutil.py

示例12: test_throw_out_random

 def test_throw_out_random(self):
     """Can append random value to the URL to avoid caching problems."""
     response = self.app.get("/test?tg_random=1")
     assert "Paging all niggles" in response
     config.update({"tg.strict_parameters": True})
     response = self.app.get("/test?tg_random=1", status=200)
     assert "Paging all niggles" in response
     response = self.app.get("/test?tg_not_random=1", status=500)
     assert "unexpected keyword argument" in response
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:9,代码来源:test_controllers.py

示例13: setUp

 def setUp(self):
     self._visit_on = config.get('visit.on', False)
     self._visit_source = config.get('visit.source', 'cookie')
     config.update({'visit.on': True})
     self._visit_timeout = config.get('visit.timeout', 20)
     config.update({'visit.timeout': 50})
     self.cookie_name = config.get("visit.cookie.name", 'tg-visit')
     self._visit_key_param = config.get("visit.form.name", 'tg_visit')
     cherrypy.root = VisitRoot()
开发者ID:OnShift,项目名称:turbogears,代码行数:9,代码来源:test_visit.py

示例14: test_suppress_mochikit

def test_suppress_mochikit():
    """MochiKit inclusion can be suppressed"""
    config.update({"global":{"tg.mochikit_suppress" : True}})
    suppressed = app.get("/usemochi")
    # repair the fixture
    config.update({"global":{"tg.mochikit_suppress" : False}})

    included = app.get("/usemochi")
    assert "MochiKit.js" not in suppressed.body
    assert "MochiKit.js" in included.body
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:10,代码来源:test_form_controllers.py

示例15: setUp

 def setUp(self):
     self._identity_on = config.get('identity.on', False)
     config.update({'identity.on': False})
     try:
         self._provider = cherrypy.request.identityProvider
     except AttributeError:
         self._provider= None
     cherrypy.request.identityProvider = None
     startup.startTurboGears()
     testutil.DBTest.setUp(self)
开发者ID:thraxil,项目名称:gtreed,代码行数:10,代码来源:test_identity.py


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