~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/model/archive.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-21 22:17:38 UTC
  • mfrom: (13228.4.8 set-ppa-private)
  • Revision ID: launchpad@pqm.canonical.com-20110621221738-l68s7zrnalblik8l
[r=jcsackett][bug=724740] Provides facility to set a PPA private via
        the API

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    )
60
60
from canonical.launchpad.components.tokens import (
61
61
    create_unique_token_for_table,
 
62
    create_token,
62
63
    )
63
64
from canonical.launchpad.database.librarian import (
64
65
    LibraryFileAlias,
271
272
 
272
273
    publish = BoolCol(dbName='publish', notNull=True, default=True)
273
274
 
274
 
    private = BoolCol(dbName='private', notNull=True, default=False,
 
275
    _private = BoolCol(dbName='private', notNull=True, default=False,
275
276
                      storm_validator=_validate_archive_privacy)
276
277
 
277
278
    require_virtualized = BoolCol(
336
337
        else:
337
338
            alsoProvides(self, IDistributionArchive)
338
339
 
 
340
    # Note: You may safely ignore lint when it complains about this
 
341
    # declaration.  As of Python 2.6, this is a perfectly valid way
 
342
    # of adding a setter
 
343
    @property
 
344
    def private(self):
 
345
        return self._private
 
346
 
 
347
    @private.setter
 
348
    def private(self, private):
 
349
        self._private = private
 
350
        if private:
 
351
            if not self.buildd_secret:
 
352
                self.buildd_secret = create_token(20)
 
353
        else:
 
354
            self.buildd_secret = None
 
355
 
339
356
    @property
340
357
    def title(self):
341
358
        """See `IArchive`."""
2205
2222
        store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
2206
2223
        return store.find(
2207
2224
            Archive,
2208
 
            Archive.private == True,
 
2225
            Archive._private == True,
2209
2226
            Archive.purpose == ArchivePurpose.PPA)
2210
2227
 
2211
2228
    def getCommercialPPAs(self):
2233
2250
        if name is not None:
2234
2251
            extra_exprs.append(Archive.name == name)
2235
2252
 
2236
 
        public_archive = And(Archive.private == False,
 
2253
        public_archive = And(Archive._private == False,
2237
2254
                             Archive._enabled == True)
2238
2255
 
2239
2256
        if user is not None: