Ejemplo n.º 1
0
class Tag(Storm):
    """A tag represents a type of value.

    @param namespaceID: The L{Namespace.id} that contains this tag.
    @param name: The name of this tag.
    """

    __storm_table__ = 'tags'

    id = Int('id', primary=True, allow_none=False, default=AutoReload)
    objectID = UUID('object_id', allow_none=False)
    namespaceID = Int('namespace_id', allow_none=False)
    creatorID = Int('creator_id', allow_none=False)
    path = Unicode('path', allow_none=False)
    name = Unicode('name', allow_none=False)
    creationTime = DateTime('creation_time', default=AutoReload)

    namespace = Reference(namespaceID, 'Namespace.id')
    creator = Reference(creatorID, 'User.id')
    permission = Reference(id, 'TagPermission.tagID')

    def __init__(self, creator, namespace, path, name):
        self.objectID = uuid4()
        self.creator = creator
        self.path = path
        self.namespace = namespace
        self.name = name
Ejemplo n.º 2
0
class DBIssuesLog(object):
    """
    """
    #__storm_table__ = 'issues_log_bugzilla'
    id = Int(primary=True)
    #
    issue_id = Int()
    issue = Unicode()
    type = Unicode()
    summary = Unicode()
    description = Unicode()
    status = Unicode()
    resolution = Unicode()
    priority = Unicode()
    submitted_by = Int()
    date = DateTime()
    assigned_to = Int()
    tracker_id = Int()
    #

    tracker = Reference(tracker_id, DBTracker.id)
    submitted = Reference(submitted_by, DBPeople.id)
    assigned = Reference(assigned_to, DBPeople.id)

    def __init__(self, issue, tracker_id):
        self.issue = unicode(issue)
        self.tracker_id = tracker_id
Ejemplo n.º 3
0
class ArchiveAuthToken(Storm):
    """See `IArchiveAuthToken`."""
    implements(IArchiveAuthToken)
    __storm_table__ = 'ArchiveAuthToken'

    id = Int(primary=True)

    archive_id = Int(name='archive', allow_none=False)
    archive = Reference(archive_id, 'Archive.id')

    person_id = Int(name='person', allow_none=False)
    person = Reference(person_id, 'Person.id')

    date_created = DateTime(
        name='date_created', allow_none=False, tzinfo=pytz.UTC)

    date_deactivated = DateTime(
        name='date_deactivated', allow_none=True, tzinfo=pytz.UTC)

    token = Unicode(name='token', allow_none=False)

    def deactivate(self):
        """See `IArchiveAuthTokenSet`."""
        self.date_deactivated = UTC_NOW

    @property
    def archive_url(self):
        """Return a custom archive url for basic authentication."""
        normal_url = URI(self.archive.archive_url)
        auth_url = normal_url.replace(
            userinfo="%s:%s" %(self.person.name, self.token))
        return str(auth_url)
Ejemplo n.º 4
0
class DistributionJob(StormBase):
    """Base class for jobs related to Distributions."""

    implements(IDistributionJob)

    __storm_table__ = 'DistributionJob'

    id = Int(primary=True)

    job_id = Int(name='job')
    job = Reference(job_id, Job.id)

    distribution_id = Int(name='distribution')
    distribution = Reference(distribution_id, Distribution.id)

    distroseries_id = Int(name='distroseries')
    distroseries = Reference(distroseries_id, DistroSeries.id)

    job_type = EnumCol(enum=DistributionJobType, notNull=True)

    metadata = JSON('json_data')

    def __init__(self, distribution, distroseries, job_type, metadata):
        super(DistributionJob, self).__init__()
        self.job = Job()
        self.distribution = distribution
        self.distroseries = distroseries
        self.job_type = job_type
        self.metadata = metadata

    def makeDerived(self):
        return DistributionJobDerived.makeSubclass(self)
Ejemplo n.º 5
0
class DistroSeriesParent(Storm):
    """See `IDistroSeriesParent`."""
    __storm_table__ = 'DistroSeriesParent'

    id = Int(primary=True)

    parent_series_id = Int(name='parent_series', allow_none=False)
    parent_series = Reference(parent_series_id, 'DistroSeries.id')

    derived_series_id = Int(name='derived_series', allow_none=False)
    derived_series = Reference(derived_series_id, 'DistroSeries.id')

    initialized = Bool(allow_none=False)

    is_overlay = Bool(allow_none=False, default=False)
    inherit_overrides = Bool(allow_none=False, default=False)

    pocket = EnumCol(
        dbName='pocket', notNull=False,
        schema=PackagePublishingPocket)

    component_id = Int(name='component', allow_none=True)
    component = Reference(component_id, 'Component.id')

    ordering = Int(allow_none=False, default=1)
Ejemplo n.º 6
0
class DBIssuesLog(object):
    """
    Object shared by all the different issue log tables
    """
    __storm_table__ = 'issues_log'

    id = Int(primary=True)
    issue_id = Int()
    issue = Unicode()
    type = Unicode()
    summary = Unicode()
    description = Unicode()
    status = Unicode()
    resolution = Unicode()
    priority = Unicode()
    submitted_by = Int()
    date = DateTime()
    assigned_to = Int()
    tracker_id = Int()
    change_id = Int()

    tracker = Reference(tracker_id, DBTracker.id)
    submitted = Reference(submitted_by, DBPeople.id)
    assigned = Reference(assigned_to, DBPeople.id)

    def __init__(self, issue, tracker_id):
        self.issue = unicode(issue)
        self.tracker_id = tracker_id
class BinaryPackageReleaseDownloadCount(Storm):
    """See `IBinaryPackageReleaseDownloadCount`."""

    implements(IBinaryPackageReleaseDownloadCount)
    __storm_table__ = 'BinaryPackageReleaseDownloadCount'

    id = Int(primary=True)
    archive_id = Int(name='archive', allow_none=False)
    archive = Reference(archive_id, 'Archive.id')
    binary_package_release_id = Int(name='binary_package_release',
                                    allow_none=False)
    binary_package_release = Reference(binary_package_release_id,
                                       'BinaryPackageRelease.id')
    day = Date(allow_none=False)
    country_id = Int(name='country', allow_none=True)
    country = Reference(country_id, 'Country.id')
    count = Int(allow_none=False)

    def __init__(self, archive, binary_package_release, day, country, count):
        super(BinaryPackageReleaseDownloadCount, self).__init__()
        self.archive = archive
        self.binary_package_release = binary_package_release
        self.day = day
        self.country = country
        self.count = count

    @property
    def binary_package_name(self):
        """See `IBinaryPackageReleaseDownloadCount`."""
        return self.binary_package_release.name

    @property
    def binary_package_version(self):
        """See `IBinaryPackageReleaseDownloadCount`."""
        return self.binary_package_release.version
Ejemplo n.º 8
0
class RevisionCache(Storm):
    """A cached version of a recent revision."""

    __storm_table__ = 'RevisionCache'

    id = Int(primary=True)

    revision_id = Int(name='revision', allow_none=False)
    revision = Reference(revision_id, 'Revision.id')

    revision_author_id = Int(name='revision_author', allow_none=False)
    revision_author = Reference(revision_author_id, 'RevisionAuthor.id')

    revision_date = UtcDateTimeCol(notNull=True)

    product_id = Int(name='product', allow_none=True)
    product = Reference(product_id, 'Product.id')

    distroseries_id = Int(name='distroseries', allow_none=True)
    distroseries = Reference(distroseries_id, 'DistroSeries.id')

    sourcepackagename_id = Int(name='sourcepackagename', allow_none=True)
    sourcepackagename = Reference(sourcepackagename_id, 'SourcePackageName.id')

    private = Bool(allow_none=False, default=False)

    def __init__(self, revision):
        # Make the revision_author assignment first as traversing to the
        # revision_author of the revision does a query which causes a store
        # flush.  If an assignment has been done already, the RevisionCache
        # object would have been implicitly added to the store, and failes
        # with an integrity check.
        self.revision_author = revision.revision_author
        self.revision = revision
        self.revision_date = revision.revision_date
Ejemplo n.º 9
0
class ApportJob(StormBase):
    """Base class for jobs related to Apport BLOBs."""

    implements(IApportJob)

    __storm_table__ = 'ApportJob'

    id = Int(primary=True)

    job_id = Int(name='job')
    job = Reference(job_id, Job.id)

    blob_id = Int(name='blob')
    blob = Reference(blob_id, TemporaryBlobStorage.id)

    job_type = EnumCol(enum=ApportJobType, notNull=True)

    _json_data = Unicode('json_data')

    # The metadata property because it needs to be modifiable by
    # subclasses of ApportJobDerived. However, since ApportJobDerived
    # only delegates() to ApportJob we can't simply directly access the
    # _json_data property, so we use a getter and setter here instead.
    def _set_metadata(self, metadata):
        self._json_data = unicode(
            simplejson.dumps(metadata, 'utf-8'))

    def _get_metadata(self):
        return simplejson.loads(self._json_data)

    metadata = property(_get_metadata, _set_metadata)

    def __init__(self, blob, job_type, metadata):
        """Constructor.

        :param blob: The ITemporaryBlobStorage object this job relates to.
        :param job_type: The ApportJobType of this job.
        :param metadata: The type-specific variables, as a JSON-compatible
            dict.
        """
        super(ApportJob, self).__init__()
        json_data = simplejson.dumps(metadata)
        self.job = Job()
        self.blob = blob
        self.job_type = job_type
        # XXX AaronBentley 2009-01-29 bug=322819: This should be a
        # bytestring, but the DB representation is unicode.
        self._json_data = json_data.decode('utf-8')

    @classmethod
    def get(cls, key):
        """Return the instance of this class whose key is supplied."""
        instance = IStore(cls).get(cls, key)
        if instance is None:
            raise SQLObjectNotFound(
                'No occurrence of %s has key %s' % (cls.__name__, key))
        return instance

    def makeDerived(self):
        return ApportJobDerived.makeSubclass(self)
Ejemplo n.º 10
0
class BugSubscription(StormBase):
    """A relationship between a person and a bug."""

    __storm_table__ = 'BugSubscription'

    id = Int(primary=True)

    person_id = Int("person", allow_none=False, validator=validate_person)
    person = Reference(person_id, "Person.id")

    bug_id = Int("bug", allow_none=False)
    bug = Reference(bug_id, "Bug.id")

    bug_notification_level = DBEnum(enum=BugNotificationLevel,
                                    default=BugNotificationLevel.COMMENTS,
                                    allow_none=False)

    date_created = DateTime(allow_none=False, default=UTC_NOW, tzinfo=pytz.UTC)

    subscribed_by_id = Int("subscribed_by",
                           allow_none=False,
                           validator=validate_person)
    subscribed_by = Reference(subscribed_by_id, "Person.id")

    def __init__(self,
                 bug=None,
                 person=None,
                 subscribed_by=None,
                 bug_notification_level=BugNotificationLevel.COMMENTS):
        super(BugSubscription, self).__init__()
        self.bug = bug
        self.person = person
        self.subscribed_by = subscribed_by
        self.bug_notification_level = bug_notification_level

    @property
    def display_subscribed_by(self):
        """See `IBugSubscription`."""
        if self.person_id == self.subscribed_by_id:
            return u'Self-subscribed'
        else:
            return u'Subscribed by %s (%s)' % (self.subscribed_by.displayname,
                                               self.subscribed_by.name)

    @property
    def display_duplicate_subscribed_by(self):
        """See `IBugSubscription`."""
        if self.person == self.subscribed_by:
            return u'Self-subscribed to bug %s' % (self.bug_id)
        else:
            return u'Subscribed to bug %s by %s (%s)' % (
                self.bug_id, self.subscribed_by.displayname,
                self.subscribed_by.name)

    def canBeUnsubscribedByUser(self, user):
        """See `IBugSubscription`."""
        if user is None:
            return False
        return (user.inTeam(self.person) or user.inTeam(self.subscribed_by)
                or IPersonRoles(user).in_admin)
Ejemplo n.º 11
0
class TagValue(Storm):
    """A value for L{Tag}.

    @param creatorID: The L{User.id} of the person creating this value.
    @param tagID: The L{Tag.id} this value is for.
    @param objectID: The object this value is for.
    @param value: The value to store.
    """

    __storm_table__ = 'tag_values'

    id = Int('id', primary=True, allow_none=False)
    creatorID = Int('creator_id', allow_none=False)
    tagID = Int('tag_id', allow_none=False)
    objectID = UUID('object_id', allow_none=False)
    creationTime = DateTime('creation_time', default=AutoReload)
    value = BinaryJSON('value', validator=validateTagValue)

    tag = Reference(tagID, 'Tag.id')
    creator = Reference(creatorID, 'User.id')

    def __init__(self, creatorID, tagID, objectID, value):
        self.creatorID = creatorID
        self.tagID = tagID
        self.objectID = objectID
        self.value = value
Ejemplo n.º 12
0
class ArchiveFile(Storm):
    """See `IArchiveFile`."""

    __storm_table__ = 'ArchiveFile'

    id = Int(primary=True)

    archive_id = Int(name='archive', allow_none=False)
    archive = Reference(archive_id, 'Archive.id')

    container = Unicode(name='container', allow_none=False)

    path = Unicode(name='path', allow_none=False)

    library_file_id = Int(name='library_file', allow_none=False)
    library_file = Reference(library_file_id, 'LibraryFileAlias.id')

    scheduled_deletion_date = DateTime(name='scheduled_deletion_date',
                                       tzinfo=pytz.UTC,
                                       allow_none=True)

    def __init__(self, archive, container, path, library_file):
        """Construct an `ArchiveFile`."""
        super(ArchiveFile, self).__init__()
        self.archive = archive
        self.container = container
        self.path = path
        self.library_file = library_file
        self.scheduled_deletion_date = None
Ejemplo n.º 13
0
class ArchiveJob(StormBase):
    """Base class for jobs related to Archives."""

    __storm_table__ = 'ArchiveJob'

    id = Int(primary=True)

    job_id = Int(name='job')
    job = Reference(job_id, Job.id)

    archive_id = Int(name='archive')
    archive = Reference(archive_id, Archive.id)

    job_type = EnumCol(enum=ArchiveJobType, notNull=True)

    metadata = JSON('json_data')

    def __init__(self, archive, job_type, metadata):
        """Create an ArchiveJob.

        :param archive: the `IArchive` this job relates to.
        :param job_type: the `ArchiveJobType` of this job.
        :param metadata: the type-specific variables, as a json-compatible
            dict.
        """
        super(ArchiveJob, self).__init__()
        self.job = Job()
        self.archive = archive
        self.job_type = job_type
        self.metadata = metadata
Ejemplo n.º 14
0
class Namespace(Storm):
    """A namespace is a container for L{Tag}s and other namespaces.

    @param creator: The L{User} that owns the namespace.
    @param path: The full C{unicode} path for the namespace.
    @param name: The C{unicode} name of the namespace (should be the same as
        the last segment of C{path}).
    @param parent: Optionally, the C{Namespace} instance that represents the
        parent of this namespace.
    """

    __storm_table__ = 'namespaces'

    id = Int('id', primary=True, allow_none=False, default=AutoReload)
    objectID = UUID('object_id', allow_none=False)
    parentID = Int('parent_id')
    creatorID = Int('creator_id', allow_none=False)
    path = Unicode('path', allow_none=False)
    name = Unicode('name', allow_none=False)
    creationTime = DateTime('creation_time', default=AutoReload)

    creator = Reference(creatorID, 'User.id')
    parent = Reference(parentID, id)
    children = ReferenceSet(id, parentID)
    permission = Reference(id, 'NamespacePermission.namespaceID')

    def __init__(self, creator, path, name, parentID=None):
        self.objectID = uuid4()
        self.creator = creator
        self.path = path
        self.name = name
        self.parentID = parentID
Ejemplo n.º 15
0
class SnapBuildJob(StormBase):
    """See `ISnapBuildJob`."""

    __storm_table__ = 'SnapBuildJob'

    job_id = Int(name='job', primary=True, allow_none=False)
    job = Reference(job_id, 'Job.id')

    snapbuild_id = Int(name='snapbuild', allow_none=False)
    snapbuild = Reference(snapbuild_id, 'SnapBuild.id')

    job_type = EnumCol(enum=SnapBuildJobType, notNull=True)

    metadata = JSON('json_data', allow_none=False)

    def __init__(self, snapbuild, job_type, metadata, **job_args):
        """Constructor.

        Extra keyword arguments are used to construct the underlying Job
        object.

        :param snapbuild: The `ISnapBuild` this job relates to.
        :param job_type: The `SnapBuildJobType` of this job.
        :param metadata: The type-specific variables, as a JSON-compatible
            dict.
        """
        super(SnapBuildJob, self).__init__()
        self.job = Job(**job_args)
        self.snapbuild = snapbuild
        self.job_type = job_type
        self.metadata = metadata

    def makeDerived(self):
        return SnapBuildJobDerived.makeSubclass(self)
Ejemplo n.º 16
0
class DBChange(object):
    """
    Maps elements from X{changes} table.

    @param field: name field that was change
    @type field: C{str}
    @param old_value: old field value
    @type old_value: C{str}
    @param new_value: new field value
    @type new_value: C{str}
    @param changed_by: identifier of the user that made the change
    @type changed_by: C{int}
    @param changed_on: date when the change was made
    @type changed_on: L{datetime.datetime}
    @param issue_id: identifier of the issue
    @type issue_id: C{int}

    @ivar __storm_table__: Name of the database table.
    @type __storm_table__: C{str}

    @ivar id: Change identifier.
    @type id: L{storm.locals.Int}
    @ivar field: Field that was changed. 
    @type field: L{storm.locals.Unicode}
    @ivar old_value: Old field value. 
    @type old_value: L{storm.locals.Unicode}
    @ivar new_value: New field value. 
    @type new_value: L{storm.locals.Unicode}
    @ivar changed_by: Identifier of the user that made the change.
    @type changed_by: L{storm.locals.Int}
    @ivar changed_on: Date when the change was produced
    @type changed_on: L{storm.locals.DateTime}
    @ivar issue_id: Issue identifier.
    @type issue_id: L{storm.locals.Int}
    @ivar issue: Reference to L{DBIssue} object.
    @type issue: L{storm.locals.Reference}
    @ivar people: Reference to L{DBPeople} object.
    @type people: L{storm.locals.Reference}   
    """
    __storm_table__ = 'changes'

    id = Int(primary=True)
    field = Unicode()
    old_value = Unicode()
    new_value = Unicode()
    changed_by = Int()
    changed_on = DateTime()
    issue_id = Int()

    issue = Reference(issue_id, DBIssue.id)
    people = Reference(changed_by, DBPeople.id)

    def __init__(self, field, old_value, new_value, changed_by, changed_on,
                 issue_id):
        self.field = unicode(field)
        self.old_value = unicode(old_value)
        self.new_value = unicode(new_value)
        self.changed_by = changed_by
        self.changed_on = changed_on
        self.issue_id = issue_id
Ejemplo n.º 17
0
class ProductJob(StormBase):
    """Base class for product jobs."""

    __storm_table__ = 'ProductJob'

    id = Int(primary=True)

    job_id = Int(name='job')
    job = Reference(job_id, Job.id)

    product_id = Int(name='product')
    product = Reference(product_id, Product.id)

    job_type = EnumCol(enum=ProductJobType, notNull=True)

    _json_data = Unicode('json_data')

    @property
    def metadata(self):
        return simplejson.loads(self._json_data)

    def __init__(self, product, job_type, metadata):
        """Constructor.

        :param product: The product the job is for.
        :param job_type: The type job the product needs run.
        :param metadata: A dict of JSON-compatible data to pass to the job.
        """
        super(ProductJob, self).__init__()
        self.job = Job()
        self.product = product
        self.job_type = job_type
        json_data = simplejson.dumps(metadata)
        self._json_data = json_data.decode('utf-8')
Ejemplo n.º 18
0
class IncrementalDiff(Storm):
    """See `IIncrementalDiff."""

    implements(IIncrementalDiff)

    delegates(IDiff, context='diff')

    __storm_table__ = 'IncrementalDiff'

    id = Int(primary=True, allow_none=False)

    diff_id = Int(name='diff', allow_none=False)

    diff = Reference(diff_id, 'Diff.id')

    branch_merge_proposal_id = Int(name='branch_merge_proposal',
                                   allow_none=False)

    branch_merge_proposal = Reference(branch_merge_proposal_id,
                                      "BranchMergeProposal.id")

    old_revision_id = Int(name='old_revision', allow_none=False)

    old_revision = Reference(old_revision_id, 'Revision.id')

    new_revision_id = Int(name='new_revision', allow_none=False)

    new_revision = Reference(new_revision_id, 'Revision.id')
Ejemplo n.º 19
0
class SnappyDistroSeries(Storm):
    """Link table between `SnappySeries` and `DistroSeries`."""

    __storm_table__ = 'SnappyDistroSeries'

    id = Int(primary=True)

    snappy_series_id = Int(name='snappy_series', allow_none=False)
    snappy_series = Reference(snappy_series_id, 'SnappySeries.id')

    distro_series_id = Int(name='distro_series', allow_none=True)
    distro_series = Reference(distro_series_id, 'DistroSeries.id')

    preferred = Bool(name='preferred', allow_none=False)

    def __init__(self, snappy_series, distro_series, preferred=False):
        super(SnappyDistroSeries, self).__init__()
        self.snappy_series = snappy_series
        self.distro_series = distro_series
        self.preferred = preferred

    @property
    def title(self):
        if self.distro_series is not None:
            return "%s, for %s" % (self.distro_series.fullseriesname,
                                   self.snappy_series.title)
        else:
            return self.snappy_series.title
Ejemplo n.º 20
0
class _SourcePackageRecipeDataInstruction(Storm):
    """A single line from a recipe."""

    __storm_table__ = "SourcePackageRecipeDataInstruction"

    def __init__(self, name, type, comment, line_number, branch, revspec,
                 directory, recipe_data, parent_instruction,
                 source_directory):
        super(_SourcePackageRecipeDataInstruction, self).__init__()
        self.name = unicode(name)
        self.type = type
        self.comment = comment
        self.line_number = line_number
        self.branch = branch
        if revspec is not None:
            revspec = unicode(revspec)
        self.revspec = revspec
        if directory is not None:
            directory = unicode(directory)
        self.directory = directory
        self.source_directory = source_directory
        self.recipe_data = recipe_data
        self.parent_instruction = parent_instruction

    id = Int(primary=True)

    name = Unicode(allow_none=False)
    type = EnumCol(notNull=True, schema=InstructionType)
    comment = Unicode(allow_none=True)
    line_number = Int(allow_none=False)

    branch_id = Int(name='branch', allow_none=False)
    branch = Reference(branch_id, 'Branch.id')

    revspec = Unicode(allow_none=True)
    directory = Unicode(allow_none=True)
    source_directory = Unicode(allow_none=True)

    recipe_data_id = Int(name='recipe_data', allow_none=False)
    recipe_data = Reference(recipe_data_id, 'SourcePackageRecipeData.id')

    parent_instruction_id = Int(name='parent_instruction', allow_none=True)
    parent_instruction = Reference(
        parent_instruction_id, '_SourcePackageRecipeDataInstruction.id')

    def appendToRecipe(self, recipe_branch):
        """Append a bzr-builder instruction to the recipe_branch object."""
        branch = RecipeBranch(
            self.name, self.branch.bzr_identity, self.revspec)
        if self.type == InstructionType.MERGE:
            recipe_branch.merge_branch(branch)
        elif self.type == InstructionType.NEST:
            recipe_branch.nest_branch(self.directory, branch)
        elif self.type == InstructionType.NEST_PART:
            recipe_branch.nest_part_branch(
                branch, self.source_directory, self.directory)
        else:
            raise AssertionError("Unknown type %r" % self.type)
        return branch
Ejemplo n.º 21
0
class DBAttachment(object):
    """
    Maps elements from X{attachments} table.

    @param name: name of the attachment
    @param description: description of the attachment
    @param url: URL of the attachement
    @param submitted_by: identifier of the user that uploaded the attachment
    @type submitted_by: C{int}
    @param submitted_on: date when the attachment was uploaded
    @type submitted_on: L{datetime.datetime}
    @param issue_id: identifier of the issue
    @type issue_id: C{int}

    @ivar __storm_table__: Name of the database table.
    @type __storm_table__: C{str}

    @ivar id: Attachment identifier.
    @type id: L{storm.locals.Int}
    @ivar name: Name of the attachment. 
    @type name: L{storm.locals.Unicode}
    @ivar description: Description of the attachment. 
    @type description: L{storm.locals.Unicode}
    @ivar url: URL of the attachment. 
    @type url: L{storm.locals.Unicode}
    @ivar submitted_by: Identifier of the submitter.
    @type submitted_by: L{storm.locals.Int}
    @ivar submitted_on: Date when the attachment was uploaded
    @type submitted_on: L{storm.locals.DateTime}
    @ivar issue_id: Issue identifier.
    @type issue_id: L{storm.locals.Int}
    @ivar issue: Reference to L{DBIssue} object.
    @type issue: L{storm.locals.Reference}
    @ivar submitted: Reference to L{DBPeople} object.
    @type submitted: L{storm.locals.Reference}   
    """
    __storm_table__ = 'attachments'

    id = Int(primary=True)
    name = Unicode()
    description = Unicode()
    url = Unicode()
    submitted_by = Int()
    submitted_on = DateTime()
    issue_id = Int()

    issue = Reference(issue_id, DBIssue.id)
    submitted = Reference(submitted_by, DBPeople.id)

    def __init__(self, name, description, url, submitted_by, submitted_on,
                 issue_id):
        self.name = unicode(name)
        self.description = unicode(description)
        self.url = unicode(url)
        self.submitted_by = submitted_by
        self.submitted_on = submitted_on
        self.issue_id = issue_id
Ejemplo n.º 22
0
class User2RoleEntity(Storm):
    __storm_table__ = 'USERS2ROLES'
    __storm_primary__ = 'user_id', 'role_id'

    user_id = Unicode(name='user_id')
    role_id = Unicode(name='role_id')

    user = Reference(user_id, UserEntity.id)
    role = Reference(role_id, RoleEntity.id)
Ejemplo n.º 23
0
class Role2PermissionEntity(Storm):
    __storm_table__ = 'ROLES2PERMISSIONS'
    __storm_primary__ = 'role_id', 'permission_id'

    role_id = Unicode(name='role_id')
    permission_id = Unicode(name='permission_id')

    role = Reference(role_id, RoleEntity.id)
    permission = Reference(permission_id, PermissionEntity.id)
Ejemplo n.º 24
0
class CodeReviewInlineCommentDraft(StormBase):
    __storm_table__ = 'CodeReviewInlineCommentDraft'
    __storm_primary__ = ('previewdiff_id', 'person_id')

    previewdiff_id = Int(name='previewdiff')
    previewdiff = Reference(previewdiff_id, 'PreviewDiff.id')
    person_id = Int(name='person')
    person = Reference(person_id, 'Person.id')
    comments = JSON()
Ejemplo n.º 25
0
class BranchMergeQueue(Storm):
    """See `IBranchMergeQueue`."""

    __storm_table__ = 'BranchMergeQueue'
    implements(IBranchMergeQueue)
    classProvides(IBranchMergeQueueSource)

    id = Int(primary=True)

    registrant_id = Int(name='registrant', allow_none=True)
    registrant = Reference(registrant_id, 'Person.id')

    owner_id = Int(name='owner', allow_none=True)
    owner = Reference(owner_id, 'Person.id')

    name = Unicode(allow_none=False)
    description = Unicode(allow_none=False)
    configuration = Unicode(allow_none=False)

    date_created = UtcDateTimeCol(notNull=True)

    @property
    def branches(self):
        """See `IBranchMergeQueue`."""
        return Store.of(self).find(
            Branch,
            Branch.merge_queue_id == self.id)

    def setMergeQueueConfig(self, config):
        """See `IBranchMergeQueue`."""
        try:
            simplejson.loads(config)
            self.configuration = config
        except ValueError: # The config string is not valid JSON
            raise InvalidMergeQueueConfig

    @classmethod
    def new(cls, name, owner, registrant, description=None,
            configuration=None, branches=None):
        """See `IBranchMergeQueueSource`."""
        store = IMasterStore(BranchMergeQueue)

        if configuration is None:
            configuration = unicode(simplejson.dumps({}))

        queue = cls()
        queue.name = name
        queue.owner = owner
        queue.registrant = registrant
        queue.description = description
        queue.configuration = configuration
        if branches is not None:
            for branch in branches:
                branch.addToQueue(queue)

        store.add(queue)
        return queue
Ejemplo n.º 26
0
class SourcePackageRecipeBuildJob(BuildFarmJobOld, Storm):
    classProvides(ISourcePackageRecipeBuildJobSource)
    implements(ISourcePackageRecipeBuildJob)

    __storm_table__ = 'sourcepackagerecipebuildjob'

    id = Int(primary=True)

    job_id = Int(name='job', allow_none=False)
    job = Reference(job_id, 'Job.id')

    build_id = Int(name='sourcepackage_recipe_build', allow_none=False)
    build = Reference(build_id, 'SourcePackageRecipeBuild.id')

    @property
    def processor(self):
        return self.build.distroseries.nominatedarchindep.processor

    @property
    def virtualized(self):
        """See `IBuildFarmJob`."""
        return self.build.is_virtualized

    def __init__(self, build, job):
        self.build = build
        self.job = job
        super(SourcePackageRecipeBuildJob, self).__init__()

    @staticmethod
    def preloadBuildFarmJobs(jobs):
        from lp.code.model.sourcepackagerecipebuild import (
            SourcePackageRecipeBuild, )
        return list(
            IStore(SourcePackageRecipeBuildJob).find(
                SourcePackageRecipeBuild, [
                    SourcePackageRecipeBuildJob.job_id.is_in(
                        [j.id
                         for j in jobs]), SourcePackageRecipeBuildJob.build_id
                    == SourcePackageRecipeBuild.id
                ]))

    @classmethod
    def preloadJobsData(cls, jobs):
        load_related(Job, jobs, ['job_id'])
        builds = load_related(SourcePackageRecipeBuild, jobs, ['build_id'])
        SourcePackageRecipeBuild.preloadBuildsData(builds)

    @classmethod
    def new(cls, build, job):
        """See `ISourcePackageRecipeBuildJobSource`."""
        specific_job = cls(build, job)
        store = IMasterStore(cls)
        store.add(specific_job)
        return specific_job

    def score(self):
        return 2505 + self.build.archive.relative_build_score
Ejemplo n.º 27
0
class StormTestResult(TestResult):
    __storm_table__ = "test_result"

    id = Int(primary=True)
    build_id = Int(name="build")
    build = Reference(build_id, StormBuild)

    test_id = Int(name="test")
    test = Reference(test_id, StormTest)
Ejemplo n.º 28
0
class CodeReviewInlineComment(StormBase):
    __storm_table__ = 'CodeReviewInlineComment'

    previewdiff_id = Int(name='previewdiff')
    previewdiff = Reference(previewdiff_id, 'PreviewDiff.id')
    person_id = Int(name='person')
    person = Reference(person_id, 'Person.id')
    comment_id = Int(name='comment', primary=True)
    comment = Reference(comment_id, 'CodeReviewComment.id')
    comments = JSON()
Ejemplo n.º 29
0
class ArchiveArch(Storm):
    """See `IArchiveArch`."""
    implements(IArchiveArch)
    __storm_table__ = 'ArchiveArch'
    id = Int(primary=True)

    archive_id = Int(name='archive', allow_none=False)
    archive = Reference(archive_id, 'Archive.id')
    processor_id = Int(name='processor', allow_none=False)
    processor = Reference(processor_id, Processor.id)
class _SourcePackageRecipeDistroSeries(Storm):
    """Link table for many-to-many relationship."""

    __storm_table__ = "SourcePackageRecipeDistroSeries"
    id = Int(primary=True)
    sourcepackagerecipe_id = Int(name='sourcepackagerecipe', allow_none=False)
    sourcepackage_recipe = Reference(sourcepackagerecipe_id,
                                     'SourcePackageRecipe.id')
    distroseries_id = Int(name='distroseries', allow_none=False)
    distroseries = Reference(distroseries_id, 'DistroSeries.id')