Exemplo n.º 1
0
    def new(self, receiver_dict):
        """
        @receiver_dict: here is supposed to be already sanitized
        @return: the receiver_gus or raise an exception

        Behold! this method convert a soulless dict in Tha Man, The Choosen
        One that want review the whistles blowed documents. It's a sort of
        transparency baptism: here you get your GlobaLeaks Unique String, sir!
        """

        store = self.getStore('receiver new')

        baptized_receiver = Receiver()

        try:
            baptized_receiver._import_dict(receiver_dict)
        except KeyError:
            store.close()
            raise InvalidInputFormat("Error near the Storm")

        baptized_receiver.receiver_gus = idops.random_receiver_gus()
        baptized_receiver.contexts = []

        baptized_receiver.creation_date = gltime.utcDateNow()
        baptized_receiver.update_date = gltime.utcDateNow()
        # last_access is not initialized

        store.add(baptized_receiver)
        store.commit()
        store.close()

        return baptized_receiver.receiver_gus
Exemplo n.º 2
0
        Behold! this method convert a soulless dict in Tha Man, The Choosen
        One that want review the whistles blowed documents. It's a sort of
        transparency baptism: here you get your GlobaLeaks Unique String, sir!
        """

        store = self.getStore()

        try:
            self._import_dict(receiver_dict)
        except KeyError, e:
            raise InvalidInputFormat("initialization failed (missing %s)" % e)
        except TypeError, e:
            raise InvalidInputFormat("initialization failed (wrong %s)" % e)

        self.receiver_gus = idops.random_receiver_gus()

        self.creation_date = gltime.utcTimeNow()
        self.update_date = gltime.utcTimeNow()

        store.add(self)

        return self._description_dict()


    @transact
    def update(self, receiver_gus, receiver_dict):
        """
        This is the method called by the admin for change receiver preferences.
        may edit more elements than the next method (self_update)
        the dict need to be already validated