def test_stacked_object_preserve_empty(): so = StackedObjectProxy() so._preserve_object() so._push_object({'hi': 'people'}) so._pop_object() so._preserve_object()
def test_stacked_object_preserve_empty(): so = StackedObjectProxy() so._preserve_object() so._push_object({'hi':'people'}) so._pop_object() so._preserve_object()
def test_stacked_object_stack(): so = StackedObjectProxy() assert (len(so._object_stack()) == 0) so._push_object({'hi': 'people'}) assert (len(so._object_stack()) == 1) so._pop_object() assert (len(so._object_stack()) == 0)
def test_stacked_object_stack(): so = StackedObjectProxy() assert(len(so._object_stack()) == 0) so._push_object({'hi':'people'}) assert(len(so._object_stack()) == 1) so._pop_object() assert(len(so._object_stack()) == 0)
def _lazy_ugettext(text: str): """ This function test if application context is available :param text: String to traduce :return: lazyfied string or string """ try: # Test if context is available, # cf. https://github.com/tracim/tracim/issues/173 context = StackedObjectProxy(name="context") context.translator return ugettext(text) except TypeError: return text
Saves a signed cookie of the pickled data. All other keyword arguments that ``WebOb.set_cookie`` accepts are usable and passed to the WebOb set_cookie method after creating the signed cookie value. """ secret = secret.encode('ascii') pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL) sig = hmac.new(secret, pickled, sha1).hexdigest().encode('ascii') cookie_value = sig + base64.encodestring(pickled) self.set_cookie(name, cookie_value, **kwargs) config = DispatchingConfig() context = StackedObjectProxy(name="context") class TurboGearsContextMember(TurboGearsObjectProxy): """Member of the TurboGears request context. Provides access to turbogears context members like request, response, template context and so on """ def __init__(self, name): self.__dict__['name'] = name def _current_obj(self): return getattr(context, self.name)
def test_stacked_object_preserved(): so = StackedObjectProxy() assert not so._is_preserved so._push_object({'hi':'people'}) assert not so._is_preserved so._pop_object() assert not so._is_preserved so._push_object({'hi':'people'}) so._preserve_object() assert so._is_preserved so._pop_object()
def test_stacked_object_preserved(): so = StackedObjectProxy() assert not so._is_preserved so._push_object({'hi': 'people'}) assert not so._is_preserved so._pop_object() assert not so._is_preserved so._push_object({'hi': 'people'}) so._preserve_object() assert so._is_preserved so._pop_object()
# (c) 2005 Ben Bangert # This module is part of the Python Paste Project and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php from nose.tools import raises from webtest import TestApp from tg.support.registry import RegistryManager, StackedObjectProxy, DispatchingConfig from tg.util import Bunch regobj = StackedObjectProxy() secondobj = StackedObjectProxy(default=dict(hi='people')) def simpleapp(environ, start_response): status = '200 OK' response_headers = [('Content-type', 'text/plain')] start_response(status, response_headers) return ['Hello world!\n'.encode('utf-8')] def simpleapp_withregistry(environ, start_response): status = '200 OK' response_headers = [('Content-type', 'text/plain')] start_response(status, response_headers) return [('Hello world!Value is %s\n' % regobj.keys()).encode('utf-8')] def simpleapp_withregistry_default(environ, start_response): status = '200 OK' response_headers = [('Content-type', 'text/plain')] start_response(status, response_headers)
# -*- coding: utf-8 -*- # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """The allura package""" from __future__ import unicode_literals from __future__ import absolute_import from tg.support.registry import StackedObjectProxy credentials = StackedObjectProxy(name='credentials')
def test_stacked_object_inspect(): if not hasattr(inspect, 'unwrap'): raise SkipTest("unwrap unavailable") so = StackedObjectProxy() assert inspect.unwrap(so) is so