launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04962
lp:~allenap/launchpad/series-init-failure-explanations-bug-835024-db into lp:launchpad
Gavin Panella has proposed merging lp:~allenap/launchpad/series-init-failure-explanations-bug-835024-db into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #835024 in Launchpad itself: "Unclear why series initialization failed"
https://bugs.launchpad.net/launchpad/+bug/835024
For more details, see:
https://code.launchpad.net/~allenap/launchpad/series-init-failure-explanations-bug-835024-db/+merge/75183
This switches DistributionJob to using the new JSON property from Storm.
--
https://code.launchpad.net/~allenap/launchpad/series-init-failure-explanations-bug-835024-db/+merge/75183
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/series-init-failure-explanations-bug-835024-db into lp:launchpad.
=== modified file 'lib/lp/services/memcache/restful.py'
--- lib/lp/services/memcache/restful.py 2010-08-20 20:31:18 +0000
+++ lib/lp/services/memcache/restful.py 2011-09-13 13:46:24 +0000
@@ -4,11 +4,9 @@
"""Storm/memcached implementation of lazr.restful's representation cache."""
from lazr.restful.simple import BaseRepresentationCache
-from lazr.restful.utils import get_current_web_service_request
import storm
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
-from zope.traversing.browser import absoluteURL
from canonical.config import config
from lp.services.memcache.interfaces import IMemcacheClient
@@ -32,11 +30,11 @@
obj = removeSecurityProxy(obj)
try:
storm_info = storm.info.get_obj_info(obj)
- except storm.exceptions.ClassInfoError, e:
+ except storm.exceptions.ClassInfoError:
# There's no Storm data for this object. Don't cache it,
# since we don't know how to invalidate the cache.
return self.DO_NOT_CACHE
- table_name = storm_info.cls_info.table
+ table_name = storm_info.cls_info.table.name
primary_key = tuple(var.get() for var in storm_info.primary_vars)
identifier = table_name + repr(primary_key)
=== modified file 'lib/lp/soyuz/model/distributionjob.py'
--- lib/lp/soyuz/model/distributionjob.py 2011-09-09 19:23:39 +0000
+++ lib/lp/soyuz/model/distributionjob.py 2011-09-13 13:46:24 +0000
@@ -9,12 +9,11 @@
]
from lazr.delegates import delegates
-import simplejson
from storm.locals import (
And,
Int,
+ JSON,
Reference,
- Unicode,
)
from zope.interface import implements
@@ -52,7 +51,7 @@
job_type = EnumCol(enum=DistributionJobType, notNull=True)
- _json_data = Unicode('json_data')
+ metadata = JSON('json_data')
def __init__(self, distribution, distroseries, job_type, metadata):
super(DistributionJob, self).__init__()
@@ -60,16 +59,7 @@
self.distribution = distribution
self.distroseries = distroseries
self.job_type = job_type
- self._json_data = self.serializeMetadata(metadata)
-
- @classmethod
- def serializeMetadata(cls, metadata_dict):
- """Serialize a dict of metadata into a unicode string."""
- return simplejson.dumps(metadata_dict).decode('utf-8')
-
- @property
- def metadata(self):
- return simplejson.loads(self._json_data)
+ self.metadata = metadata
class DistributionJobDerived(BaseRunnableJob):
=== modified file 'lib/lp/soyuz/model/distroseriesdifferencejob.py'
--- lib/lp/soyuz/model/distroseriesdifferencejob.py 2011-08-31 14:05:59 +0000
+++ lib/lp/soyuz/model/distroseriesdifferencejob.py 2011-09-13 13:46:24 +0000
@@ -8,6 +8,7 @@
'DistroSeriesDifferenceJob',
]
+import simplejson
from zope.component import getUtility
from zope.interface import (
classProvides,
@@ -84,8 +85,8 @@
:return: A tuple of: derived distribution id, derived distroseries id,
job type, job id, JSON data map.
"""
- json = DistributionJob.serializeMetadata(make_metadata(
- sourcepackagename_id, parent_series.id))
+ json = simplejson.dumps(
+ make_metadata(sourcepackagename_id, parent_series.id))
return (
derived_series.distribution.id,
derived_series.id,
@@ -141,8 +142,7 @@
# the metadata string. It's fragile, but this is only an
# optimization. It's not actually disastrous to create
# redundant jobs occasionally.
- json_metadata = DistributionJob.serializeMetadata(
- make_metadata(sourcepackagename.id, parent_series.id))
+ json_metadata = make_metadata(sourcepackagename.id, parent_series.id)
# Use master store because we don't like outdated information
# here.
@@ -153,7 +153,7 @@
DistributionJob.job_type ==
DistributionJobType.DISTROSERIESDIFFERENCE,
DistributionJob.distroseries == derived_series,
- DistributionJob._json_data == json_metadata,
+ DistributionJob.metadata == json_metadata,
DistributionJob.job_id.is_in(Job.ready_jobs))
return [
=== modified file 'lib/lp/soyuz/model/initializedistroseriesjob.py'
--- lib/lp/soyuz/model/initializedistroseriesjob.py 2011-09-09 19:23:39 +0000
+++ lib/lp/soyuz/model/initializedistroseriesjob.py 2011-09-13 13:46:24 +0000
@@ -7,7 +7,6 @@
"InitializeDistroSeriesJob",
]
-import simplejson
from zope.interface import (
classProvides,
implements,
@@ -206,8 +205,7 @@
# This method is called when error is an instance of
# self.user_error_types.
super(InitializeDistroSeriesJob, self).notifyUserError(error)
- metadata = dict(self.metadata, error_description=unicode(error))
- self.context._json_data = simplejson.dumps(metadata).decode("utf-8")
+ self.metadata = dict(self.metadata, error_description=unicode(error))
def getOopsVars(self):
"""See `IRunnableJob`."""
=== modified file 'lib/lp/soyuz/model/packagecopyjob.py'
--- lib/lp/soyuz/model/packagecopyjob.py 2011-08-23 14:35:43 +0000
+++ lib/lp/soyuz/model/packagecopyjob.py 2011-09-13 13:46:24 +0000
@@ -15,6 +15,7 @@
from storm.locals import (
And,
Int,
+ JSON,
Reference,
Unicode,
)
@@ -103,7 +104,7 @@
job_type = EnumCol(enum=PackageCopyJobType, notNull=True)
- _json_data = Unicode('json_data')
+ metadata = JSON('json_data')
# Derived concrete classes. The entire class gets one dict for
# this; it's not meant to be on an instance.
@@ -145,16 +146,7 @@
self.target_distroseries = target_distroseries
self.package_name = unicode(package_name)
self.copy_policy = copy_policy
- self._json_data = self.serializeMetadata(metadata)
-
- @classmethod
- def serializeMetadata(cls, metadata_dict):
- """Serialize a dict of metadata into a unicode string."""
- return simplejson.dumps(metadata_dict).decode('utf-8')
-
- @property
- def metadata(self):
- return simplejson.loads(self._json_data)
+ self.metadata = metadata
@property
def package_version(self):
@@ -164,7 +156,7 @@
"""Add metadata_dict to the existing metadata."""
existing = self.metadata
existing.update(metadata_dict)
- self._json_data = self.serializeMetadata(existing)
+ self.metadata = existing
@property
def component_name(self):
@@ -294,7 +286,7 @@
data = (
cls.class_job_type, target_distroseries, copy_policy,
source_archive, target_archive, package_name, job_id,
- PackageCopyJob.serializeMetadata(metadata))
+ simplejson.dumps(metadata, ensure_ascii=False))
format_string = "(%s)" % ", ".join(["%s"] * len(data))
return format_string % sqlvalues(*data)
=== modified file 'versions.cfg'
--- versions.cfg 2011-09-12 23:52:19 +0000
+++ versions.cfg 2011-09-13 13:46:24 +0000
@@ -85,7 +85,7 @@
soupmatchers = 0.1r53
sourcecodegen = 0.6.9
# lp:~launchpad-committers/storm/with-without-datetime
-storm = 0.18.0.99-lpwithnodatetime-r396
+storm = 0.18.0.99-lpwithnodatetime-r398
testresources = 0.2.4-r58
testtools = 0.9.12-r228
timeline = 0.0.1