def get_creator_id(db): co = Factory.get('Constants')(db) entity_name = EntityName(db) entity_name.find_by_name(cereconf.INITIAL_ACCOUNTNAME, co.account_namespace) id = entity_name.entity_id return id
def get_name(e_id, e_type): namespace = ENTITY_TYPE_NAMESPACE.get(six.text_type(e_type)) if namespace is None: return None else: namespace = co.ValueDomain(namespace) entity = EntityName(self._db) try: entity.find(e_id) return entity.get_name(namespace) except Cerebrum.Errors.NotFoundError: return None
def __init__(self, *rest, **kw): self.__super.__init__(*rest, **kw) # VirtAccounts are owner by the system, rather than people/groups. We # need these ids later. Easier to fetch them right now and forget # about it. initial_group = Utils.Factory.get("Group")(self._db) initial_group.find_by_name(cereconf.INITIAL_GROUPNAME) self.initial_group = initial_group.entity_id initial_account = EntityName(self._db) initial_account.find_by_name(cereconf.INITIAL_ACCOUNTNAME, self.const.account_namespace) self.initial_account = initial_account.entity_id self.legal_chars = set(string.letters + string.digits + " .@")
def _build_entity2name_mapping(self, namespace): logger.info('Caching names in namespace=%r', namespace) for row in EntityName(self.db).list_names(namespace): self.e_id2name[int(row['entity_id'])] = row['entity_name'] self._names.add(namespace)