~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Gavin Panella
  • Date: 2011-09-12 16:16:28 UTC
  • mto: This revision was merged to the branch mainline in revision 13954.
  • Revision ID: gavin.panella@canonical.com-20110912161628-ytrku6yu0ilgxybq
Borrow the JSON property from lp:~allenap/storm/json-variable-unicode-bug-846867.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    )
55
55
from lp.services.job.model.job import Job
56
56
from lp.services.job.runner import BaseRunnableJob
 
57
from lp.services.jsoncol import JSON
57
58
from lp.soyuz.adapters.overrides import (
58
59
    FromExistingOverridePolicy,
59
60
    SourceOverride,
103
104
 
104
105
    job_type = EnumCol(enum=PackageCopyJobType, notNull=True)
105
106
 
106
 
    _json_data = Unicode('json_data')
 
107
    metadata = JSON('json_data')
107
108
 
108
109
    # Derived concrete classes.  The entire class gets one dict for
109
110
    # this; it's not meant to be on an instance.
145
146
        self.target_distroseries = target_distroseries
146
147
        self.package_name = unicode(package_name)
147
148
        self.copy_policy = copy_policy
148
 
        self._json_data = self.serializeMetadata(metadata)
149
 
 
150
 
    @classmethod
151
 
    def serializeMetadata(cls, metadata_dict):
152
 
        """Serialize a dict of metadata into a unicode string."""
153
 
        return simplejson.dumps(metadata_dict).decode('utf-8')
154
 
 
155
 
    @property
156
 
    def metadata(self):
157
 
        return simplejson.loads(self._json_data)
 
149
        self.metadata = metadata
158
150
 
159
151
    @property
160
152
    def package_version(self):
164
156
        """Add metadata_dict to the existing metadata."""
165
157
        existing = self.metadata
166
158
        existing.update(metadata_dict)
167
 
        self._json_data = self.serializeMetadata(existing)
 
159
        self.metadata = existing
168
160
 
169
161
    @property
170
162
    def component_name(self):
294
286
        data = (
295
287
            cls.class_job_type, target_distroseries, copy_policy,
296
288
            source_archive, target_archive, package_name, job_id,
297
 
            PackageCopyJob.serializeMetadata(metadata))
 
289
            simplejson.dumps(metadata, ensure_ascii=False))
298
290
        format_string = "(%s)" % ", ".join(["%s"] * len(data))
299
291
        return format_string % sqlvalues(*data)
300
292