Beispiel #1
0
def test_visitmods_reloading():
    m2_make_wsgi()
    rulenum = len(list(ag.route_map.iter_rules()))
    # if all the tests are run, and reload doesn't work, then this this will
    # fail b/c other tests have already loaded minimal2/views.py
    assert rulenum >= 9, ag.route_map

    from minimal2.views import page1
    firstid = id(page1)

    # reloading should only work once per application, so running it again
    # for the same app should not cause any further side effects
    visitmods('views')
    rulenum2 = len(list(ag.route_map.iter_rules()))
    assert rulenum == rulenum2, ag.route_map

    m2_make_wsgi()
    rulenum = len(list(ag.route_map.iter_rules()))
    # if only this tests is run, and reload doesn't work, then this this will
    # fail b/c the previous m2_make_wsgi() loaded minimal2/views.py
    assert rulenum >= 9, ag.route_map

    from minimal2.views import page1
    secondid = id(page1)

    # we want to make sure that @asview is not creating a new class object
    # each time, but using the cache object that already exists if possible
    eq_(firstid, secondid)
Beispiel #2
0
def test_visitmods_reloading():
    m2_make_wsgi()
    rulenum = len(list(ag.route_map.iter_rules()))
    # if all the tests are run, and reload doesn't work, then this this will
    # fail b/c other tests have already loaded minimal2/views.py
    assert rulenum >= 9, ag.route_map

    from minimal2.views import page1
    firstid = id(page1)

    # reloading should only work once per application, so running it again
    # for the same app should not cause any further side effects
    visitmods('views')
    rulenum2 = len(list(ag.route_map.iter_rules()))
    assert rulenum == rulenum2, ag.route_map

    m2_make_wsgi()
    rulenum = len(list(ag.route_map.iter_rules()))
    # if only this tests is run, and reload doesn't work, then this this will
    # fail b/c the previous m2_make_wsgi() loaded minimal2/views.py
    assert rulenum >= 9, ag.route_map

    from minimal2.views import page1
    secondid = id(page1)

    # we want to make sure that @asview is not creating a new class object
    # each time, but using the cache object that already exists if possible
    eq_(firstid, secondid)
Beispiel #3
0
def make_wsgi(profile='Dev'):
    app = WSGIApp(settingsmod, profile)

    app = SQLAlchemyApp(app)

    # has to happen after the db global gets setup and is needed b/c of our
    # use of @asview
    visitmods('views')

    return full_wsgi_stack(app)
Beispiel #4
0
    def init_routing(self):
        # setup the Map object with the appropriate settings
        self.ag.route_map = Map(**self.settings.routing.map.todict())

        # load view modules so routes from @asview() get setup correctly
        if self.settings.auto_load_views:
            visitmods('views')

        # application routes first since they should take precedence
        self.add_routing_rules(self.settings.routing.routes)

        # now the routes from component settings
        for pname in self.settings.components.keys():
            psettings = self.settings.components[pname]
            try:
                self.add_routing_rules(psettings.routes)
            except AttributeError as e:
                if "no attribute 'routes'" not in str(e):
                    raise  # pragma: no cover
Beispiel #5
0
    def test_visitmods(self):
        bset = set(sys.modules.keys())
        visitmods('tovisit')
        aset = set(sys.modules.keys())
        eq_(
            aset.difference(bset),
            set([
                'nlsupporting.tovisit', 'nlsupporting.components.news.tovisit',
                'newlayout.components.badimport.tovisit', 'newscomp3.tovisit',
                'newlayout.components.news.tovisit', 'newlayout.tovisit'
            ]))

        # test that we don't catch another import error
        try:
            visitmods('views')
            assert False
        except ImportError as e:
            if str(e).replace("'", '') != 'No module named foo':
                raise
Beispiel #6
0
    def init_routing(self):
        # setup the Map object with the appropriate settings
        self.ag.route_map = Map(**self.settings.routing.map.todict())

        # load view modules so routes from @asview() get setup correctly
        if self.settings.auto_load_views:
            visitmods('views')

        # application routes first since they should take precedence
        self.add_routing_rules(self.settings.routing.routes)

        # now the routes from component settings
        for pname in self.settings.components.keys():
            psettings = self.settings.components[pname]
            try:
                self.add_routing_rules(psettings.routes)
            except AttributeError as e:
                if "no attribute 'routes'" not in str(e):
                    raise  # pragma: no cover
Beispiel #7
0
    def __init__(self, application, visit_mods=True):
        self.application = application
        self.container = SQLAlchemyContainer(self.db_settings)
        self.sop_obj._push_object(self.container)

        # if using multiple DB connections, only the one highest in the wsgi
        # stack should visit the mods.
        if visit_mods:
            visitmods('model.orm')
            visitmods('model.entities')
            visitmods('model.metadata')
            visitmods('model.schema')
Beispiel #8
0
    def test_visitmods(self):
        bset = set(sys.modules.keys())
        visitmods('tovisit')
        aset = set(sys.modules.keys())
        eq_(
            aset.difference(bset),
            set([
                'nlsupporting.tovisit',
                'nlsupporting.components.news.tovisit',
                'newlayout.components.badimport.tovisit',
                'newscomp3.tovisit',
                'newlayout.components.news.tovisit',
                'newlayout.tovisit'
            ])
        )

        # test that we don't catch another import error
        try:
            visitmods('views')
            assert False
        except ImportError as e:
            if str(e).replace("'", '') != 'No module named foo':
                raise
Beispiel #9
0
 def init_events(self):
     visitmods('events')
     signal('blazeweb.events.initialized').send(self.init_events)
Beispiel #10
0
 def init_events(self):
     visitmods('events')
     signal('blazeweb.events.initialized').send(self.init_events)
Beispiel #11
0
 def init_events(self):
     global called
     visitmods('events')
     called = signal('blazeweb.events.initialized').send(self.init_events)