[Pkg-debile-commits] [debile-master] 27/28: Documentation for ORM. Added maintainer field.
Léo Cavaillé
leo.cavaille-guest at alioth.debian.org
Wed Aug 21 13:36:53 UTC 2013
This is an automated email from the git hooks/post-receive script.
leo.cavaille-guest pushed a commit to branch master
in repository debile-master.
commit 7f4406318c08298fbe71936fc432d94cba626872
Author: Léo Cavaillé <leo at cavaille.net>
Date: Wed Aug 21 10:44:31 2013 +0200
Documentation for ORM. Added maintainer field.
---
lucy/incoming.py | 1 +
lucy/orm.py | 197 ++++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 171 insertions(+), 27 deletions(-)
diff --git a/lucy/incoming.py b/lucy/incoming.py
index 41747d9..bd8f33b 100644
--- a/lucy/incoming.py
+++ b/lucy/incoming.py
@@ -97,6 +97,7 @@ def accept_source(changes, user):
s = Source( name=changes['source'],
version=changes['version'],
user=owner,
+ maintainer=changes['maintainer'],
group=group,
dsc=dsc,
run=run_nb)
diff --git a/lucy/orm.py b/lucy/orm.py
index 4106bbf..8cb836f 100644
--- a/lucy/orm.py
+++ b/lucy/orm.py
@@ -1,14 +1,22 @@
-from sqlalchemy.ext.declarative import declarative_base
+# This ORM is the declaration of all the entities we are using in debile-master
+# as well as the relations between these entities.
+
+from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
from sqlalchemy.orm import relationship, backref
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean
from sqlalchemy.dialects.postgresql import UUID
+from sqlalchemy import types as sqltypes
import datetime as dt
def row2dict(row):
+ """
+ Method used to convert a SQLAlchemy entity to a python dictonnary for
+ serialization purposes.
+ """
d = {}
for column in row.__table__.columns:
if column.name == 'uuid':
@@ -17,14 +25,33 @@ def row2dict(row):
d[column.name] = getattr(row, column.name)
return d
+
class User(Base):
+ """
+ A User is a registered member of debile, that means he signed up therefore
+ getting some rights to upload packages for instance or login.
+ """
+ # ORM internal
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
+
+ # A unique login for each User
+ # TODO: look at possible bindings/proxy with an official Debian member
+ # directory (LDAP)
login = Column(String(100))
+ # A password for the User to login on debile-web or via the XML-RPC
+ # interface
+ # FIXME: implement hashing and strength verification
password = Column(String(100))
+ # The real name that will be displayed on debile-web for this User
name = Column(String(100))
+ # A valid email for registration and to send notifications
email = Column(String(100))
+ # The User fingerprint, the key is in the debile-master keyring, the string
+ # does not contain whitespaces
+ # e.g. B11A9FEC01B2B1F6C1C31DD4896AE222CC16515C
gpg_fingerprint = Column(String(100))
+ # Simple boolean for access control, see @admin_method decorator
admin = Column(Boolean)
def serialize(self):
@@ -32,75 +59,169 @@ class User(Base):
class Machine(Base):
+ """
+ A Machine is a corresponding debile-slave instance.
+ """
+ # ORM internal
__tablename__ = 'machines'
id = Column(Integer, primary_key=True)
+
+ # The name of the builder which is also used by the machine to login via the
+ # XML-RPC interface
name = Column(String(100), unique=True)
+ # A password for the Machine used to login via XML-RPC
+ # FIXME: implement hashing and strength verification
+ password = Column(String)
+ # A simple datetime attribute, updated to now() each time the machine says
+ # something on the XML-RPC interface
last_ping = Column(DateTime)
+ # The Machine fingerprint, the key is in the debile-master keyring, the
+ # string does not contain whitespaces
+ # e.g. B11A9FEC01B2B1F6C1C31DD4896AE222CC16515C
gpg_fingerprint = Column(String(100))
- password = Column(String)
def serialize(self):
return row2dict(self)
+
class Group(Base):
+ """
+ A Group is an entity to group packages, enabling users to do group rebuilds,
+ or make stats on several packages linked together.
+ """
+ # ORM internal
__tablename__ = 'groups'
id = Column(Integer, primary_key=True)
+
+ # The name used to register the group
name = Column(String(100))
-# Just so we can put either a Source package or a Binary package in a job
+
class Package(Base):
+ """
+ A Package is a polymorphic entity that can represent either a Source package
+ or a Binary package.
+ This enables searching through both of packages type via the common
+ attributes of the entities (name, version, ...)
+ """
__tablename__ = 'packages'
package_id = Column(Integer, primary_key=True)
+
+ # Declaration of the polymorphic entity using the type attribute.
type = Column(String(30), nullable=False)
__mapper_args__ = {'polymorphic_on': type}
+
+# Register to the ORM that we are using posgresql-debversion extension.
+# This declares a special field of DEBVERSION type, which ships a built-in
+# comparator for Debian versions on top of a text field.
+class DebVersion(sqltypes.UserDefinedType):
+ def get_col_spec(self):
+ return "DEBVERSION"
+
+ def bind_processor(self, dialect):
+ return None
+
+ def result_processor(self, dialect, coltype):
+ return None
+from sqlalchemy.databases import postgres
+postgres.ischema_names['debversion'] = DebVersion
+
+
class Source(Package):
+ """
+ See the polymorphic type Package.
+ A Source represents an entry of a Debian source package in the debile system
+ usually meaning a .dsc, .orig.tar.gz, .debian.tar.gz.
+ A Source is uploaded by a User into the system. The debile system adds
+ special build jobs to turn the Source into Binaries with Machines.
+ """
+ # ORM internal & polymorphism
__tablename__ = 'sources'
__mapper_args__ = {'polymorphic_identity': 'source'}
- # If package is source, we add a special job for each available arch
- # to build the binaries that will be uploaded to lucy by ethel instances
- suite = 'unstable'
- arch = 'all'
source_id = Column(Integer, ForeignKey('packages.package_id'), primary_key=True)
+
+ # Creation time of the Source, meaning when it was processed via incoming/
created_at = Column(DateTime)
- updated_at = Column(DateTime)
- name = Column(String(100))
- version = Column(String(100))
+ # Relation with the User entity, representing the uploader of the package
user_id = Column(Integer, ForeignKey('users.id'))
user = relationship("User", backref=backref('sources', order_by=name))
+
+ ### FROM the .changes file
+ # The package name
+ name = Column(String(100))
+ # The package version, using the special DEBVERSION type
+ version = Column(DebVersion)
+ # The maintainer name/email
+ maintainer = Column(String(100))
+ # The name of the dsc file
dsc = Column(String(100))
+ # Relation with the entity Group
group_id = Column(Integer, ForeignKey('groups.id'))
group = relationship("Group", backref=backref('sources', order_by=name))
+ # The suite this package comes from
+ suite = Column(String(50), nullable=False)
+ # The architectures of the source package
+ arch = Column(String(50), nullable=False)
+
+ # The run number, a number incremented each time the user uploads the same
+ # package again
run = Column(Integer)
+
def serialize(self):
source_dict = row2dict(self)
source_dict['type'] = 'source'
return source_dict
-#class BinaryFiles(Base):
-# __tablename__ = 'binaryfiles'
-# id = Column(Integer, primary_key=True)
-# name = Column(String(100))
-# binary_id = Column(Integer, ForeignKey('binaries.binary_id'), nullable=False)
-# binary = relationship("Binary", backref=backref('files', order_by=name))
class Binary(Package):
+ """
+ See the polymorphic type Package.
+ A binary represents an entry of a Debian binary package in the debile system
+ meaning a .deb.
+ A Binary is uploaded by a Machine into the system, originating from a Source
+ uploaded by a User and a build type Job.
+ """
+ # ORM Internal & polymorphism
__tablename__ = 'binaries'
__mapper_args__ = {'polymorphic_identity': 'binary'}
- binary_id = Column(Integer, ForeignKey('packages.package_id'), primary_key=True)
- name = Column(String(100))
- version = Column(String(100))
- source_id = Column(Integer, ForeignKey('sources.source_id'))
- source = relationship("Source", backref=backref('binaries', order_by=name), foreign_keys=[source_id])
+ binary_id = Column(Integer,
+ ForeignKey('packages.package_id'),
+ primary_key=True)
+
+
+ # Creation time of the Binary, meaning when it was processed via incoming/
+ # and not when it was output by the builder
created_at = Column(DateTime)
- updated_at = Column(DateTime)
- arch = Column(String(20), nullable=False)
+
+ ### FROM the .changes file
+ # The package name
+ name = Column(String(100))
+ # The package version, using the special DEBVERSION type
+ version = Column(DebVersion)
+ # Architecture of the Binary
+ arch = Column(String(50), nullable=False)
+ # Suite
suite = Column(String(50), nullable=False)
+ # Group (same as the source package)
group_id = Column(Integer, ForeignKey('groups.id'))
group = relationship("Group", backref=backref('binaries', order_by=name))
+
+ # Run number if this same version of the package has been uploaded several
+ # times by this user
run = Column(Integer)
+
+ # With the .changes and the X-Debile-Job field
+ # The source this binary package has been built from
+ source_id = Column(Integer, ForeignKey('sources.source_id'))
+ source = relationship("Source",
+ backref=backref('binaries', order_by=name),
+ foreign_keys=[source_id])
+ # The .deb filename
deb = Column(String(100))
+ # The compiler (build subtype/flavor) used to produce this binary.
compiler_type = Column(String(100))
+
def serialize(self):
binary_dict = row2dict(self)
binary_dict['type'] = 'binary'
@@ -108,19 +229,41 @@ class Binary(Package):
class Job(Base):
+ """
+ A Job is the core entity of debile, it represents one check for one Package
+ that can be worked on by a debile-slave unit.
+ """
+ # ORM internal
__tablename__ = 'jobs'
id = Column(Integer, primary_key=True)
- uuid = Column(UUID(as_uuid=True))
+
+ # Time a debile-slave took the job
assigned_at = Column(DateTime)
+ # Time a debile-slave closed the job
finished_at = Column(DateTime)
+
+ # The debile-slave instance which is doing the job
machine_id = Column(Integer, ForeignKey('machines.id'))
- machine = relationship("Machine", backref=backref('jobs', order_by=id), foreign_keys=[machine_id])
+ machine = relationship("Machine",
+ backref=backref('jobs', order_by=id),
+ foreign_keys=[machine_id])
+ # The job, corresponding to a plugin from debile-slave
type = Column(String(50), nullable=False)
+ # Subtype may be used as an additional parameter for the plugin (compiler
+ # for builds)
subtype = Column(String(50))
- package_id = Column(Integer, ForeignKey('packages.package_id'), nullable=False)
- package = relationship("Package", backref=backref('jobs', order_by=id), foreign_keys=[package_id])
+ # The package we are doing this job on
+ package_id = Column(Integer,
+ ForeignKey('packages.package_id'),
+ nullable=False)
+ package = relationship("Package",
+ backref=backref('jobs', order_by=id),
+ foreign_keys=[package_id])
+ # The arch the job need to run on
arch = Column(String(20), nullable=False)
+ # The suite used for the job (gives the name of the schroot)
suite = Column(String(50), nullable=False)
+ # A simple boolean, true if the job failed to run
failed = Column(Boolean)
def serialize(self):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git
More information about the Pkg-debile-commits
mailing list