launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02914
[Merge] lp:~wgrant/launchpad/unuse-spr-copyright into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/unuse-spr-copyright into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#732424 SourcePackageRelease.copyright shouldn't be loaded every time
https://bugs.launchpad.net/bugs/732424
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/unuse-spr-copyright/+merge/52808
SPR.copyright can get fairly large on production (up to 2MB), and nothing uses it. Grabbing it from the DB is significant overhead, so this branch prevents that. I turned it from a Storm column into a property that issues a separate query to get and set. archiveuploader and gina seem happy with this.
--
https://code.launchpad.net/~wgrant/launchpad/unuse-spr-copyright/+merge/52808
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/unuse-spr-copyright into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2011-03-10 03:50:50 +0000
+++ database/schema/security.cfg 2011-03-10 08:23:46 +0000
@@ -1277,7 +1277,7 @@
# Source and Binary packages and builds
public.sourcepackagename = SELECT, INSERT
-public.sourcepackagerelease = SELECT, INSERT
+public.sourcepackagerelease = SELECT, INSERT, UPDATE
public.binarypackagename = SELECT, INSERT
public.binarypackagerelease = SELECT, INSERT
public.sourcepackagereleasefile = SELECT, INSERT
=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
--- lib/lp/soyuz/model/sourcepackagerelease.py 2011-01-27 22:01:07 +0000
+++ lib/lp/soyuz/model/sourcepackagerelease.py 2011-03-10 08:23:46 +0000
@@ -137,7 +137,6 @@
dateuploaded = UtcDateTimeCol(dbName='dateuploaded', notNull=True,
default=UTC_NOW)
dsc = StringCol(dbName='dsc')
- copyright = StringCol(dbName='copyright', notNull=False, default=DEFAULT)
version = StringCol(dbName='version', notNull=True)
changelog = ForeignKey(foreignKey='LibraryFileAlias', dbName='changelog')
changelog_entry = StringCol(dbName='changelog_entry')
@@ -183,7 +182,30 @@
kwargs['_user_defined_fields'] = simplejson.dumps(
kwargs['user_defined_fields'])
del kwargs['user_defined_fields']
+ # copyright isn't on the Storm class, since we don't want it
+ # loaded every time. Set it separately.
+ if 'copyright' in kwargs:
+ copyright = kwargs.pop('copyright')
super(SourcePackageRelease, self).__init__(*args, **kwargs)
+ self.copyright = copyright
+
+ @property
+ def copyright(self):
+ """See `ISourcePackageRelease`."""
+ store = Store.of(self)
+ store.flush()
+ return store.execute(
+ "SELECT copyright FROM sourcepackagerelease WHERE id=%s",
+ (self.id,)).get_one()[0]
+
+ @copyright.setter
+ def copyright(self, content):
+ """See `ISourcePackageRelease`."""
+ store = Store.of(self)
+ store.flush()
+ store.execute(
+ "UPDATE sourcepackagerelease SET copyright=%s WHERE id=%s",
+ (content, self.id))
@property
def user_defined_fields(self):