コード例 #1
0
ファイル: test_commands.py プロジェクト: LeResKP/tw2.core
    def setUp(self):
        import tw2.core.command
        o = StdOut(sys.stdout)
        e = StdOut(sys.stderr)
        self._stdout = sys.stdout
        self._stderr = sys.stderr
        sys.stdout = o
        sys.stderr = e
        d = distutils.dist.Distribution()
        self.c = tw2.core.command.archive_tw2_resources(d)

        try:
            shutil.rmtree(OUT_DIR)
        except Exception as e:
            pass

        self.c.initialize_options()
        self.c.finalize_options()
        self.c.output = OUT_DIR
        self.c.force = True
        self.c.distributions = ['tw2.forms']
        os.mkdir(OUT_DIR)

        # Set up fake middleware with which widgets can register their resources
        core.request_local = tw2.core.command.request_local_fake
        core.request_local()['middleware'] = middleware.make_middleware()
        try:
            core.request_local()['resources'] = []
        except Exception as e:
            pass
コード例 #2
0
ファイル: test_commands.py プロジェクト: mitin123/tw2.core
class TestArchive(TestCase):
    def setUp(self):
        import tw2.core.command
        o = StdOut(sys.stdout)
        e = StdOut(sys.stderr)
        self._stdout = sys.stdout
        self._stderr = sys.stderr
        sys.stdout = o
        sys.stderr = e
        d = distutils.dist.Distribution()
        self.c = tw2.core.command.archive_tw2_resources(d)

        try:
            shutil.rmtree(OUT_DIR)
        except Exception, e:
            pass

        self.c.initialize_options()
        self.c.finalize_options()
        self.c.output = OUT_DIR
        self.c.force = True
        self.c.distributions = ['tw2.forms']
        os.mkdir(OUT_DIR)

        # Set up fake middleware with which widgets can register their resources
        core.request_local = tw2.core.command.request_local_fake
        core.request_local()['middleware'] = middleware.make_middleware()
        try:
            core.request_local()['resources'] = []
        except Exception, e:
            pass
コード例 #3
0
ファイル: base.py プロジェクト: lmacken/tw2.core
 def _check_rendering_vs_expected(self, engine, attrs, params, expected):
     _request_id = None
     template.reset_engine_name_cache()
     mw = tmw.make_middleware(None, preferred_rendering_engines=[engine])
     self.request(1, mw)
     r = self.widget(_no_autoid=True, **attrs).display(**params)
     # reset the cache as not to affect other tests
     assert_eq_xml(r, expected, self.wrap)
コード例 #4
0
ファイル: base.py プロジェクト: beckastar/cleaner_markov
 def setup(self):
     global _request_id, _request_local
     _request_local = {}
     _request_id = None
     if hasattr(super(ValidatorTest, self), 'setup'):
         super(ValidatorTest, self).setup()
     self.mw = tmw.make_middleware(None)
     return self.request(1)
コード例 #5
0
ファイル: base.py プロジェクト: lmacken/tw2.core
 def setup(self):
     global _request_id, _request_local
     _request_local = {}
     _request_id = None
     if hasattr(super(WidgetTest, self), 'setup'):
         super(WidgetTest, self).setup()
     self.mw = tmw.make_middleware(None, default_engine=self.template_engine)
     if self.declarative:
         self.widget = TW2WidgetBuilder(self.widget, **self.attrs)
     return self.request(1)
コード例 #6
0
ファイル: base.py プロジェクト: carl-wallace/sprox
    def setup(self):
        if tmw and request_local:
            rl = request_local()
            rl.clear()
            rl['middleware'] = tmw.make_middleware(None)

        self.session = session
        self.engine = engine
        try:
            self.user = setup_records(session)
        except:
            self.session.rollback()
コード例 #7
0
ファイル: base.py プロジェクト: TurboGears/sprox
    def setup(self):
        if tmw and request_local:
            rl = request_local()
            rl.clear()
            rl['middleware'] = tmw.make_middleware(None)

        self.session = session
        self.engine = engine
        try:
            self.user = setup_records(session)
        except:
            self.session.rollback()
コード例 #8
0
ファイル: base.py プロジェクト: beckastar/cleaner_markov
    def setup(self):
        global _request_id, _request_local
        _request_local = {}
        _request_id = None
        if hasattr(super(WidgetTest, self), 'setup'):
            super(WidgetTest, self).setup()
        self.mw = tmw.make_middleware(
            None,
            default_engine=self.template_engine
        )
        if self.declarative:
            self.widget = TW2WidgetBuilder(self.widget, **self.attrs)

        return self.request(1)
コード例 #9
0
ファイル: base.py プロジェクト: beckastar/cleaner_markov
 def _check_rendering_vs_expected(self, engine, attrs, params, expected):
     if self.engines and engine not in self.engines:
         raise SkipTest("%r not in engines %r" % (engine, self.engines))
     _request_id = None
     templating.engine_name_cache = {}
     mw = tmw.make_middleware(None, preferred_rendering_engines=[engine])
     self.request(1, mw)
     try:
         r = self.widget(_no_autoid=True, **attrs).display(**params)
     except ValueError, e:
         if str(e).startswith("Could not find engine name"):
             raise SkipTest("No template for engine %r" % engine)
         else:
             raise
コード例 #10
0
ファイル: base.py プロジェクト: carl-wallace/sprox
    def setup(self):
        if tmw and request_local:
            rl = request_local()
            rl.clear()
            rl['middleware'] = tmw.make_middleware(None)

        self.session = session
        self.engine = engine
        try:
            self.user = setup_records(session)
        except Exception as ex:
            try:
                self.session.close()
            except: pass
            raise ex
コード例 #11
0
    def setUp(self):
        global _request_id, _request_local
        _request_local = {}
        _request_id = None

        # Clean up the cache
        templating.engine_name_cache = {}

        super(WidgetTest, self).setUp()

        self.mw = tmw.make_middleware(None,
                                      default_engine=self.template_engine)
        if self.declarative:
            self.widget = TW2WidgetBuilder(self.widget, **self.attrs)

        return self.request(1)
コード例 #12
0
ファイル: base.py プロジェクト: garrettmc/TGWikiTutorial
    def setUp(self):
        global _request_id, _request_local
        _request_local = {}
        _request_id = None

        # Clean up the cache
        templating.engine_name_cache = {}

        super(WidgetTest, self).setUp()

        self.mw = tmw.make_middleware(
            None,
            default_engine=self.template_engine
        )
        if self.declarative:
            self.widget = TW2WidgetBuilder(self.widget, **self.attrs)

        return self.request(1)
コード例 #13
0
ファイル: command.py プロジェクト: lmacken/tw2.core
    def _copy_resources(self):

        # Set up fake middleware with which widgets can register their resources
        core.request_local = request_local_fake
        core.request_local()['middleware'] = middleware.make_middleware()

        # Load widgets and have them prepare their resources
        map(self._load_widget_entry_points, self.distributions)

        rl_resources = core.request_local().setdefault('resources', [])

        for resource in rl_resources:
            try:
                modname = resource.modname
                fbase = resource.filename.split('/')[0]
                self.execute(self._copy_resource_tree, (modname, fbase),
                             "Copying %s recursively into %s" %
                             (modname, self.writer.base))
            except AttributeError, e:
                pass
コード例 #14
0
ファイル: command.py プロジェクト: mitin123/tw2.core
    def _copy_resources(self):

        # Set up fake middleware with which widgets can register their
        # resources
        core.request_local = request_local_fake
        core.request_local()['middleware'] = middleware.make_middleware()

        # Load widgets and have them prepare their resources
        map(self._load_widget_entry_points, self.distributions)

        rl_resources = core.request_local().setdefault('resources', [])

        for resource in rl_resources:
            try:
                modname = resource.modname
                fbase = resource.filename.split('/')[0]
                self.execute(self._copy_resource_tree, (modname, fbase),
                             "Copying %s recursively into %s" %
                             (modname, self.writer.base))
            except AttributeError, e:
                pass
コード例 #15
0
    def _check_rendering_vs_expected(self, engine, attrs, params, expected):
        if self.engines and engine not in self.engines:
            raise SkipTest("%r not in engines %r" % (engine, self.engines))

        if engine == 'genshi':
            # Since version 0.7.x genshi doesn't add empty attributes like in
            # the other templating systems we remove the empty value
            expected = expected.replace(' value=""', '')

        _request_id = None
        templating.engine_name_cache = {}
        mw = tmw.make_middleware(None, preferred_rendering_engines=[engine])
        self.request(1, mw)
        try:
            r = self.widget(_no_autoid=True, **attrs).display(**params)
        except ValueError as e:
            if str(e).startswith("Could not find engine name"):
                raise SkipTest("No template for engine %r" % engine)
            else:
                raise

        # reset the cache as not to affect other tests
        assert_eq_xml(r, expected, self.wrap)
コード例 #16
0
ファイル: base.py プロジェクト: garrettmc/TGWikiTutorial
    def _check_rendering_vs_expected(self, engine, attrs, params, expected):
        if self.engines and engine not in self.engines:
            raise SkipTest("%r not in engines %r" % (engine, self.engines))

        if engine == 'genshi':
            # Since version 0.7.x genshi doesn't add empty attributes like in
            # the other templating systems we remove the empty value
            expected = expected.replace(' value=""', '')

        _request_id = None
        templating.engine_name_cache = {}
        mw = tmw.make_middleware(None, preferred_rendering_engines=[engine])
        self.request(1, mw)
        try:
            r = self.widget(_no_autoid=True, **attrs).display(**params)
        except ValueError as e:
            if str(e).startswith("Could not find engine name"):
                raise SkipTest("No template for engine %r" % engine)
            else:
                raise

        # reset the cache as not to affect other tests
        assert_eq_xml(r, expected, self.wrap)
コード例 #17
0
ファイル: test_validation.py プロジェクト: nphilipp/tw2.core
 def setUp(self):
     self.mw = make_middleware(None, {})
コード例 #18
0
ファイル: base.py プロジェクト: carl-wallace/sprox
except ImportError:
    from ming import datastore as DS
    def create_ming_datastore():
        return DS.DataStore(master=os.environ.get('MONGOURL', 'mongodb://127.0.0.1:27017/'), database='test_db')

try:
    from tw import framework
    framework.default_view = 'mako'
except ImportError:
    pass

try:
    import tw2.core.core
    import tw2.core.middleware as tmw

    _request_local = {'middleware':tmw.make_middleware(None)}
    def request_local_tst():
        return _request_local

    tw2.core.core.request_local = request_local_tst
    from tw2.core.core import request_local
except ImportError:
    tmw = None
    request_local = None

#try:
import xml.etree.ElementTree as etree
#except ImportError:
#    import cElementTree as etree

session = None
コード例 #19
0
    def create_ming_datastore():
        return DS.DataStore(master=os.environ.get("MONGOURL", "mongodb://127.0.0.1:27017/"), database="test_db")


try:
    from tw import framework

    framework.default_view = "mako"
except ImportError:
    pass

try:
    import tw2.core.core
    import tw2.core.middleware as tmw

    _request_local = {"middleware": tmw.make_middleware(None)}

    def request_local_tst():
        return _request_local

    tw2.core.core.request_local = request_local_tst
    from tw2.core.core import request_local
except ImportError:
    tmw = None
    request_local = None

# try:
import xml.etree.ElementTree as etree

# except ImportError:
#    import cElementTree as etree
コード例 #20
0
 def testMakeMiddelware(self):
     from tw2.core.middleware import make_middleware
     make_middleware(None)
コード例 #21
0
ファイル: app.py プロジェクト: ralphbean/irlp-viz
import math
import uuid

import geojson
import flask
import tw2.polymaps
import yaml
import fastkml
import shapely.geometry

from tw2.polymaps.geojsonify import geojsonify
from tw2.core.middleware import make_middleware


app = flask.Flask(__name__)
app.wsgi_app = make_middleware(app.wsgi_app)

template = """
<html>
<head>
<style type="text/css">
svg {
        width: 100%;
        height: 100%;
}

.midnight-commander-extras {
        width: 100%;
        height: 100%;
}
コード例 #22
0
def setup():
    core.request_local = request_local_tst
    core.request_local().setdefault('middleware',
                                    middleware.make_middleware())
コード例 #23
0
ファイル: test_widgets.py プロジェクト: LeResKP/tw2.forms
 def setUp(self):
     self.widget = TW2WidgetBuilder(self.widget, **self.attrs)
     self.mw = make_middleware(None, {})
コード例 #24
0
 def setUp(self):
     self.mw = make_middleware(None, {})
コード例 #25
0
    def testMakeMiddelware(self):
        from tw2.core.middleware import make_middleware

        make_middleware(None)