Example #1
0
def _get_item_modul(request, item):
    if not request:
        # FIXME: Ideally there is no need to call the methods without a
        # request and to get the request from the app globals. If this
        # code path is executed this is a sign the the caller is not
        # implemented in a clean way. Well, this is a known issue for
        # years and it currently doesn't seem to cause problems in the
        # real world. (ti) <2016-01-12 08:55>
        request = get_current_request()
    if not request or not request.cache_item_modul.get(item._modul_id):
        from ringo.model.modul import ModulItem
        factory = ModulItem.get_item_factory()
        if item._modul_id is None:
            # FIXME: Special case when loading fixtures for extensions.
            # As the id of an extension is set dynamically on
            # application startup the id is not yet present at time of
            # fixture loading. (ti) <2015-02-17 23:00>
            modul = factory.load(item.__tablename__, field="name")
        else:
            modul = factory.load(item._modul_id)
        if request:
            if not request.cache_item_modul.get(item._modul_id):
                request.cache_item_modul.set(item._modul_id, modul)
        else:
            return modul
    return request.cache_item_modul.get(item._modul_id)
Example #2
0
 def test_get_form_config(self):
     from ringo.model.modul import ModulItem
     from ringo.lib.form import get_form_config
     factory = ModulItem.get_item_factory()
     item = factory.load(1)
     result = get_form_config(item, 'create')
     self.assertEqual(result.id, 'create')
Example #3
0
 def test_get_form_config(self):
     from ringo.model.modul import ModulItem
     from ringo.lib.form import get_form_config
     factory = ModulItem.get_item_factory()
     item = factory.load(1)
     result = get_form_config(item, 'create')
     self.assertEqual(result.id, 'create')
Example #4
0
def _get_item_modul(request, item):
    if not request:
        # FIXME: Ideally there is no need to call the methods without a
        # request and to get the request from the app globals. If this
        # code path is executed this is a sign the the caller is not
        # implemented in a clean way. Well, this is a known issue for
        # years and it currently doesn't seem to cause problems in the
        # real world. (ti) <2016-01-12 08:55>
        request = get_current_request()
    if not request or not request.cache_item_modul.get(item._modul_id):
        from ringo.model.modul import ModulItem
        factory = ModulItem.get_item_factory()
        if item._modul_id is None:
            # FIXME: Special case when loading fixtures for extensions.
            # As the id of an extension is set dynamically on
            # application startup the id is not yet present at time of
            # fixture loading. (ti) <2015-02-17 23:00>
            modul = factory.load(item.__tablename__, field="name")
        else:
            modul = factory.load(item._modul_id)
        if request:
            if not request.cache_item_modul.get(item._modul_id):
                request.cache_item_modul.set(item._modul_id, modul)
        else:
            return modul
    return request.cache_item_modul.get(item._modul_id)
Example #5
0
 def test_get_item_factory(self):
     from ringo.model.modul import ModulItem
     from ringo.model.base import BaseFactory
     result = ModulItem.get_item_factory()
     self.assertEqual(result._clazz, ModulItem)
     self.assertTrue(isinstance(result, BaseFactory))
Example #6
0
 def _load_item(self):
     from ringo.model.modul import ModulItem
     factory = ModulItem.get_item_factory()
     return factory.load(1)
Example #7
0
 def test_get_item_factory(self):
     from ringo.model.modul import ModulItem
     from ringo.model.base import BaseFactory
     result = ModulItem.get_item_factory()
     self.assertEqual(result._clazz, ModulItem)
     self.assertTrue(isinstance(result, BaseFactory))
Example #8
0
 def _load_item(self):
     from ringo.model.modul import ModulItem
     factory = ModulItem.get_item_factory()
     return factory.load(1)