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')
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)
def _add_modul(config, actions, dbsession): """Method to add the modul entries for the extension in the database. This includes a entry in the modules table and the configured actions. :config: Extension configuration as a dictionary :actions: List of ActionItems :dbsession: Database session """ # Set defaults name = config.get("name") clazzpath = config.get("clazzpath") str_repr = config.get("str_repr") or "%s|id" display = config.get("display") or "hidden" label = config.get("label") or name label_plural = config.get("label_plural") or label # Add modul modul = ModulItem(name=name) modul.clazzpath = clazzpath modul.label = label modul.str_repr = str_repr modul.label_plural = label_plural modul.display = display # Configure actions modul = _configure_actions(modul, config, actions, dbsession) dbsession.add(modul) dbsession.flush() transaction.commit() log.debug("Adding new modul '%s'" % name) return modul
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))
def _load_item(self): from ringo.model.modul import ModulItem factory = ModulItem.get_item_factory() return factory.load(1)