=== modified file 'lib/canonical/launchpad/database/distrorelease.py' --- lib/canonical/launchpad/database/distrorelease.py +++ lib/canonical/launchpad/database/distrorelease.py @@ -648,14 +648,13 @@ len(changesfilecontent), StringIO(changesfilecontent), 'text/plain') return DistroReleaseQueue(distrorelease=self.id, - status=DistroReleaseQueueStatus.NEW, pocket=pocket, changesfile=changes_file.id) def getQueueItems(self, status=DistroReleaseQueueStatus.ACCEPTED): """See IDistroRelease.""" return DistroReleaseQueue.selectBy(distroreleaseID=self.id, - status=status) + private_status=status) def getFancyQueueItems(self, status=DistroReleaseQueueStatus.ACCEPTED, name=None, version=None, exact_match=False): === modified file 'lib/canonical/launchpad/database/queue.py' --- lib/canonical/launchpad/database/queue.py +++ lib/canonical/launchpad/database/queue.py @@ -29,7 +29,7 @@ from canonical.launchpad.interfaces import ( IDistroReleaseQueue, IDistroReleaseQueueBuild, IDistroReleaseQueueSource, - IDistroReleaseQueueCustom, NotFoundError, QueueStateWriteProtectedError, + IDistroReleaseQueueCustom, NotFoundError, QueueInconsistentStateError, QueueSourceAcceptError, QueueBuildAcceptError, IDistroReleaseQueueSet) @@ -67,9 +67,10 @@ _defaultOrder = ['id'] - status = EnumCol(dbName='status', unique=False, notNull=True, - default=DistroReleaseQueueStatus.NEW, - schema=DistroReleaseQueueStatus) + # private attribute not provided by IDistroReleaseQueue + private_status = EnumCol(dbName='status', unique=False, + default=DistroReleaseQueueStatus.NEW, + schema=DistroReleaseQueueStatus) distrorelease = ForeignKey(dbName="distrorelease", foreignKey='DistroRelease') @@ -96,31 +97,18 @@ joinColumn='distroreleasequeue', orderBy='distroreleasequeuecustom.id') - def _set_status(self, value): - """Directly write on 'status' is forbidden. - - Force user to use the provided machine-state methods. - Raises QueueStateWriteProtectedError. - """ - # XXX: bug #29663: this is a bit evil, but does the job. Andrew - # has suggested using immutable=True in the column definition. - # -- kiko, 2006-01-25 - # allow 'status' write only in creation process. - if self._SO_creating: - self._SO_set_status(value) - return - # been facist - raise QueueStateWriteProtectedError( - 'Directly write on queue status is forbidden use the ' - 'provided methods to set it.') + @property + def status(self): + """See IDistroReleaseQueue.""" + return self.private_status def set_new(self): """See IDistroReleaseQueue.""" - self._SO_set_status(DistroReleaseQueueStatus.NEW) + self.private_status = DistroReleaseQueueStatus.NEW def set_unapproved(self): """See IDistroReleaseQueue.""" - self._SO_set_status(DistroReleaseQueueStatus.UNAPPROVED) + self.private_status = DistroReleaseQueueStatus.UNAPPROVED def set_accepted(self): """See IDistroReleaseQueue.""" @@ -141,15 +129,16 @@ raise QueueInconsistentStateError(info) # if the previous checks applied and pass we do set the value - self._SO_set_status(DistroReleaseQueueStatus.ACCEPTED) + self.private_status = DistroReleaseQueueStatus.ACCEPTED def set_done(self): """See IDistroReleaseQueue.""" - self._SO_set_status(DistroReleaseQueueStatus.DONE) + self.private_status = DistroReleaseQueueStatus.DONE + def set_rejected(self): """See IDistroReleaseQueue.""" - self._SO_set_status(DistroReleaseQueueStatus.REJECTED) + self.private_status = DistroReleaseQueueStatus.REJECTED @cachedproperty def changesfilename(self): === modified file 'lib/canonical/launchpad/interfaces/queue.py' --- lib/canonical/launchpad/interfaces/queue.py +++ lib/canonical/launchpad/interfaces/queue.py @@ -5,7 +5,6 @@ __metaclass__ = type __all__ = [ - 'QueueStateWriteProtectedError', 'QueueInconsistentStateError', 'QueueSourceAcceptError', 'QueueBuildAcceptError', @@ -23,14 +22,6 @@ _ = MessageIDFactory('launchpad') -class QueueStateWriteProtectedError(Exception): - """This exception prevent directly set operation in queue state. - - The queue state machine is controlled by its specific provided methods, - like: set_new, set_accepted and so on. - """ - - class QueueInconsistentStateError(Exception): """Queue state machine error. @@ -59,10 +50,6 @@ title=_("ID"), required=True, readonly=True, ) - status = Int( - title=_("Read-only Queue status"), required=False, readonly=True, - ) - distrorelease = Int( title=_("Distribution release"), required=True, readonly=False, ) @@ -71,6 +58,7 @@ title=_("The pocket"), required=True, readonly=False, ) + status = Attribute("Read-only status property") changesfile = Attribute("The librarian alias for the changes file " "associated with this upload") changesfilename = Attribute("The filename of the changes file.")