Ejemplo n.º 1
0
 def get_provider(self):
     """
     Get the provider for this type of persistent identifier
     """
     if self._provider is None:
         self._provider = PidProvider.create(self.type, self.pid)
     return self._provider
Ejemplo n.º 2
0
 def get_provider(self):
     """
     Get the provider for this type of persistent identifier
     """
     if self._provider is None:
         self._provider = PidProvider.create(self.type, self.pid)
     return self._provider
Ejemplo n.º 3
0
    def create(cls, pid_type, pid, provider=None):
        """
        Internally reserve a new persistent identifier in Invenio.

        A provider for the given persistent identifier type must exists. By
        default the system will choose a provider according to the pid
        type. If desired, the default system provider can be overridden via
        the provider keyword argument.

        Returns PID object if successful otherwise None.
        """
        # Ensure provider exists
        if provider is None:
            provider = PidProvider.create(pid_type, pid)
            if not provider:
                raise Exception("No provider found for %s:%s" %
                                (pid_type, pid))

        try:
            obj = cls(type=provider.pid_type, pid=pid, status=CFG_STATUS_NEW)
            obj._provider = provider
            db.session.add(obj)
            db.session.commit()
            obj.log("CREATE", "Created")
            return obj
        except SQLAlchemyError:
            db.session.rollback()
            obj.log("CREATE", "Failed to created. Already exists.")
            return None
Ejemplo n.º 4
0
    def create(cls, pid_type, pid, provider=None):
        """
        Internally reserve a new persistent identifier in Invenio.

        A provider for the given persistent identifier type must exists. By
        default the system will choose a provider according to the pid
        type. If desired, the default system provider can be overridden via
        the provider keyword argument.

        Returns PID object if successful otherwise None.
        """
        # Ensure provider exists
        if provider is None:
            provider = PidProvider.create(pid_type, pid)
            if not provider:
                raise Exception(
                    "No provider found for %s:%s" % (pid_type, pid)
                )

        try:
            obj = cls(type=provider.pid_type, pid=pid, status=CFG_STATUS_NEW)
            obj._provider = provider
            db.session.add(obj)
            db.session.commit()
            obj.log("CREATE", "Created")
            return obj
        except SQLAlchemyError:
            db.session.rollback()
            obj.log("CREATE", "Failed to created. Already exists.")
            return None