def _set_object_permission(self, obj): """ :param obj: :return: """ portal_type = api.get_portal_type(obj) # Don't do anything, if it is just a dependency if portal_type in self.unwanted_content_types: return if portal_type in self.read_only_types: obj.manage_permission('Modify portal content', roles=[])
def to_super_model(obj): # avoid circular imports from senaite.core.supermodel import SuperModel # Object is already a SuperModel, return immediately if isinstance(obj, SuperModel): return obj # Only portal objects are supported if not api.is_object(obj): raise TypeError("Expected a portal object, got '{}'".format( type(obj))) # Wrap the object into a specific Publication Object Adapter uid = api.get_uid(obj) portal_type = api.get_portal_type(obj) adapter = queryAdapter(uid, ISuperModel, name=portal_type) if adapter is None: return SuperModel(uid) return adapter
def get_portal_type(brain_or_object): """Proxy to senaite.api.get_portal_type """ return api.get_portal_type(brain_or_object)