Exemplo n.º 1
0
class Message(orm.SQLObject):
    """The class generates a Message table containing information
    about user messages.

    Args:
        text (str, optional):
        time (int, optional):
        filePicture (byte, optional):
        fileVideo (byte, optional):
        fileAudio (byte, optional):
        fileDocument (byte, optional):
        emoji (str, optional):
        editedTime (int, optional):
        editedStatus (bool, optional):

    Returns:
        None
    """
    text = orm.StringCol(default=None)
    time = orm.IntCol(default=None)
    filePicture = orm.BLOBCol(default=None)
    fileVideo = orm.BLOBCol(default=None)
    fileAudio = orm.BLOBCol(default=None)
    fileDocument = orm.BLOBCol(default=None)
    emoji = orm.BLOBCol(default=None)
    editedTime = orm.IntCol(default=None)
    editedStatus = orm.BoolCol(default=False)
    userConfig = orm.ForeignKey('UserConfig', refColumn="uuid")
    flow = orm.ForeignKey('Flow', refColumn="flowId")
Exemplo n.º 2
0
class Srv4FileInCatalog(sqlobject.SQLObject):
  """Assignment of a particular srv4 file to a specific catalog.

  There could be one more layer, to which arch and osrel could be moved.
  But for now, it's going to be a not-normalized structure.
  """
  arch = sqlobject.ForeignKey('Architecture', notNone=True)
  osrel = sqlobject.ForeignKey('OsRelease', notNone=True)
  catrel = sqlobject.ForeignKey('CatalogRelease', notNone=True)
  srv4file = sqlobject.ForeignKey('Srv4FileStats', notNone=True)
  created_on = sqlobject.DateTimeCol(
      notNone=True,
      default=sqlobject.DateTimeCol.now)
  created_by = sqlobject.UnicodeCol(length=50, notNone=True)
  uniqueness_idx = sqlobject.DatabaseIndex(
          'arch', 'osrel', 'catrel', 'srv4file',
          unique=True)

  # http://turbogears.org/1.0/docs/SQLObject/Caching.html#what-does-cache-false-do
  class sqlmeta:
    cacheValues = False

  def __unicode__(self):
    return (u"%s is in catalog %s %s %s"
            % (self.srv4file,
               self.arch.name, self.osrel.full_name, self.catrel.name))
Exemplo n.º 3
0
class Medicion(SO.SQLObject, Serializer):
    class sqlmeta:
        style = SO.MixedCaseStyle(longID=True)
    nombre = SO.StringCol(length=40, varchar=True)      
    intervalo = SO.IntCol()
    linea = SO.ForeignKey('Linea')
    unidad = SO.ForeignKey('Unidad')
Exemplo n.º 4
0
class CswFile(sqlobject.SQLObject):
    """Represents a file in a catalog.

  There can be multiple files with the same basename and the same path,
  belonging to different packages.

  This class needs to also contain files from the operating system,
  coming from SUNW packages, for which we don't have the original srv4
  files.  (Even if we could, they are generally not accessible.)  They
  need to be specific to Solaris release and architecture, so we need
  a way to link CswFile with a specific catalog.

  Fake registered Srv4FileStats object would do, but we would have to
  ensure that they can't be associated with a catalog.  Also, we'd have
  to generate fake md5 sums for them.
  """
    basename = sqlobject.UnicodeCol(length=255, notNone=True)
    path = sqlobject.UnicodeCol(notNone=True, length=900)
    line = sqlobject.UnicodeCol(notNone=True, length=900)
    pkginst = sqlobject.ForeignKey('Pkginst', notNone=True)
    srv4_file = sqlobject.ForeignKey('Srv4FileStats')
    basename_idx = sqlobject.DatabaseIndex('basename')

    def __unicode__(self):
        return u"File: %s" % os.path.join(self.path, self.basename)
Exemplo n.º 5
0
class ProfileCategory(so.SQLObject):
    """
    Model the many-to-many relationship between Profile and Category records.

    Attributes are based on a recommendation in the SQLObject docs.
    """

    profile = so.ForeignKey("Profile", notNull=True, cascade=True)
    category = so.ForeignKey("Category", notNull=True, cascade=True)
    uniqueIdx = so.DatabaseIndex(profile, category, unique=True)
Exemplo n.º 6
0
class TweetCampaign(so.SQLObject):
    """
    Model the many-to-many relationship between Tweet and Campaign records.

    Attributes are based on a recommendation in the SQLObject docs for doing
    this relationship.
    """

    tweet = so.ForeignKey("Tweet", notNull=True, cascade=True)
    campaign = so.ForeignKey("Campaign", notNull=True, cascade=True)
    uniqueIdx = so.DatabaseIndex(tweet, campaign, unique=True)
Exemplo n.º 7
0
    class URL(sqlobject.SQLObject):
        class sqlmeta:

            table = 'url'

        url = sqlobject.StringCol()
        clean = sqlobject.StringCol()
        author = sqlobject.ForeignKey('Author')
        channel = sqlobject.ForeignKey('Channel')
        citations = sqlobject.IntCol(default=0)
        posted = sqlobject.DateTimeCol(default=datetime.now)
        comments = sqlobject.MultipleJoin('Comments')
Exemplo n.º 8
0
class PageLabel(so.SQLObject):
    """
    Model the many-to-many relationship between Page and Label records.

    A Label may be applied to many Pages and a Page may have many Labels.
    But a paired relationship must be unique.

    Attributes here are based on a recommendation in the SQLObject docs.
    """

    page = so.ForeignKey('Page', notNull=True, cascade=True)
    label = so.ForeignKey('Label', notNull=True, cascade=True)
    unique_idx = so.DatabaseIndex(page, label, unique=True)
Exemplo n.º 9
0
class Page(so.SQLObject):
    """
    Model a URI for a webpage on the internet.

    Do not worry about duplicate pairs of domain and path, since we want
    to allow those to occur on an import and to clean them up later.

    A page may have a null Folder (as unsorted), though a folder must always
    have a parent folder, even if the top folder is "root".
    """

    # The host website for the page.
    # TODO: Ensure this is always converted lowercase rather than raising
    # an error.
    domain = so.ForeignKey('Domain', notNull=True)

    # The location of the webpage relative to the domain.
    # TODO: Should this start with forwardslash? Check what happens when
    # splitting and joining.
    # TODO: Create custom validator?
    path = so.UnicodeCol(notNull=True)

    # Webpage title, usually taken from the metadata of the HTML head section.
    title = so.UnicodeCol(default=None)

    # The date and time when the record was created. Defaults to the
    # current time.
    created_at = so.DateTimeCol(notNull=True, default=so.DateTimeCol.now)

    # Optional preview image for the link, scraped from the metadata.
    image_url = so.UnicodeCol(default=None)

    description = so.UnicodeCol(default=None)

    # The folder this link is placed into. If null then the link must still
    # be sorted. Domain and path pairs must be unique in a folder.
    folder = so.ForeignKey('Folder')
    unique_idx = so.DatabaseIndex(domain, path, folder, unique=True)

    source = so.ForeignKey('Source', notNull=True)

    # Link to labels which this page is assigned to.
    labels = so.SQLRelatedJoin('Labels',
                               intermediateTable='page_label',
                               createRelatedTable=False)

    def get_url(self):
        return "".join((self.domain.value, self.path))
Exemplo n.º 10
0
class CheckpkgOverride(sqlobject.SQLObject):
  # Overrides don't need to contain catalog parameters.
  srv4_file = sqlobject.ForeignKey('Srv4FileStats', notNone=True)
  pkgname = sqlobject.UnicodeCol(default=None, length=250)
  tag_name = sqlobject.UnicodeCol(notNone=True, length=250)
  tag_info = sqlobject.UnicodeCol(default=None, length=250)

  def __unicode__(self):
    return (u"Override: %s: %s %s" %
            (self.pkgname,
             self.tag_name,
             self.tag_info or ""))

  def DoesApply(self, tag):
    """Figures out if this override applies to the given tag."""
    basket_a = {}
    basket_b = {}
    if self.pkgname:
      basket_a["pkgname"] = self.pkgname
      basket_b["pkgname"] = tag.pkgname
    if self.tag_info:
      basket_a["tag_info"] = self.tag_info
      basket_b["tag_info"] = tag.tag_info
    basket_a["tag_name"] = self.tag_name
    basket_b["tag_name"] = tag.tag_name
    return basket_a == basket_b
Exemplo n.º 11
0
class CatalogRelease(sqlobject.SQLObject):
    "Release names: potato, etc."
    name = sqlobject.UnicodeCol(length=255, unique=True, notNone=True)
    type = sqlobject.ForeignKey('CatalogReleaseType', notNone=True)

    def __unicode__(self):
        return u"Catalog release: %s" % self.name
Exemplo n.º 12
0
class ValorMedicion(SO.SQLObject, Serializer):
    class sqlmeta:
        style = SO.MixedCaseStyle(longID=True)

    valor = SO.DecimalCol(size=10, precision=2)
    unixTimeStamp = SO.IntCol()
    medicion = SO.ForeignKey('Medicion')
Exemplo n.º 13
0
class Tag(sqlobject.SQLObject):
    class sqlmeta(myMeta):
        pass

    filedata = sqlobject.ForeignKey('Filedata', cascade=True)
    tagname = sqlobject.StringCol()
    tagvalue = sqlobject.StringCol()
Exemplo n.º 14
0
class Record(Base):
    """
    Template table for other record tables to derive from.
    """
    # Add a foreign key to id in User table.
    # This is user_id in SQL or userID in Python.
    user = so.ForeignKey('User')
    # The time the entry was is recorded for. Defaults to current time
    # if not set or set to None.
    timestamp = so.DateTimeCol(default=so.DateTimeCol.now)

    def _set_userID(self, userID):
        """
        Override default set method to enforce that the user ID exists in User
        table when a record entry is created.
        There may be a better way to do this with a contrainst or changing
        the foreign key creation.
        """
        try:
            User.get(userID)
        except so.SQLObjectNotFound:
            raise so.SQLObjectNotFound(
                "Unable to create entry since user ID "
                "{0} is not in User table.".format(userID))
        else:
            self._SO_set_userID(userID)
Exemplo n.º 15
0
class comment(so.SQLObject):
	post = so.ForeignKey('post', notNone=1)
	ctime = so.DateTimeCol(notNone=1,default=so.DateTimeCol.now)
	name = so.StringCol(length=128, notNone=1,default='')
	email = so.StringCol(length=128, notNone=1,default='')
	title = so.StringCol(length=128, notNone=1,default='')
	body = so.StringCol(notNone=1,default='')
Exemplo n.º 16
0
class Folder(so.SQLObject):
    """
    Model a folder, which can contain Page objects.

    A folder can be a tree structure with one parent and many children. A
    folder may contain zero or more Page objects.

    Folder name has a unique constrainst. If the same folder name needs
    to be used in different parts of the folder tree, it should probably
    by a label instead.
    """

    name = so.UnicodeCol(alternateID=True)

    # Self-join to an optional parent folder. If NULL, then it is at the top
    # level.
    # TODO: Unique constraint to prevent multiple top level folders?
    # Or use "root" instead and the res are unsorted?
    parent = so.ForeignKey('Folder', default=None)

    # Link to the child Folder records of a Folder.
    children = so.SQLMultipleJoin('Folder')

    # Link to Page records within a Folder.
    pages = so.SQLMultipleJoin('Page')
Exemplo n.º 17
0
class Subjects(sqlobject.SQLObject):
    _connection = conn
    maths = sqlobject.IntCol(name=None)
    hindi = sqlobject.IntCol(name=None)
    science = sqlobject.IntCol(name=None)
    english = sqlobject.IntCol(name=None)
    student = sqlobject.ForeignKey('Student')
Exemplo n.º 18
0
class CswFile(sqlobject.SQLObject):
  """Represents a file in a catalog.

  There can be multiple files with the same basename and the same path,
  belonging to different packages.

  This class needs to also contain files from the operating system,
  coming from SUNW packages, for which we don't have the original srv4
  files.  (Even if we could, they are generally not accessible.)  They
  need to be specific to Solaris release and architecture, so we need
  a way to link CswFile with a specific catalog.

  Fake registered Srv4FileStats object would do, but we would have to
  ensure that they can't be associated with a catalog.  Also, we'd have
  to generate fake md5 sums for them.
  """
  class sqlmeta:
    # MySQL uses case-insensitive collation by default, which doesn't make sense
    # for file names. If the utf8_bin (or other case sensitive) collation is not
    # used, it reports e.g. Zcat and zcat as a file collision, while it really
    # isn't one.
    createSQL = {
        'mysql' : [
        'ALTER TABLE csw_file CONVERT TO CHARACTER SET utf8 '
        'COLLATE utf8_bin']
    }
  basename = sqlobject.UnicodeCol(length=255, notNone=True)
  path = sqlobject.UnicodeCol(notNone=True, length=900)
  line = sqlobject.UnicodeCol(notNone=True, length=900)
  # Symlinks don't have permissions on their own
  perm_user = sqlobject.UnicodeCol(notNone=False, length=255)
  perm_group = sqlobject.UnicodeCol(notNone=False, length=255)
  perm_mode = sqlobject.UnicodeCol(notNone=False, length=5)
  target = sqlobject.UnicodeCol(notNone=False, length=900)
  mimetype = sqlobject.UnicodeCol(notNone=False, length=255)
  machine = sqlobject.UnicodeCol(notNone=False, length=255)
  pkginst = sqlobject.ForeignKey('Pkginst', notNone=True)
  srv4_file = sqlobject.ForeignKey('Srv4FileStats')
  basename_idx = sqlobject.DatabaseIndex('basename')
  path_idx = sqlobject.DatabaseIndex({'column': 'path', 'length': 255})

  def FullPath(self):
    return os.path.join(self.path, self.basename)

  def __unicode__(self):
    return u"%s %s %s %s %s" % (self.perm_user, self.perm_group, self.perm_mode,
                                self.FullPath(), self.mimetype)
Exemplo n.º 19
0
class Umbral(SO.SQLObject, Serializer):
    class sqlmeta:
        style = SO.MixedCaseStyle(longID=True)

    severidad = SO.EnumCol(enumValues=('leve', 'grave', 'critico'))
    umbralInferior = SO.DecimalCol(size=10, precision=2)
    umbralSuperior = SO.DecimalCol(size=10, precision=2) 
    medicion =SO.ForeignKey('Medicion')
Exemplo n.º 20
0
class CheckpkgErrorTag(CheckpkgErrorTagMixin, sqlobject.SQLObject):
  srv4_file = sqlobject.ForeignKey('Srv4FileStats', notNone=True)
  pkgname = sqlobject.UnicodeCol(default=None, length=250)
  tag_name = sqlobject.UnicodeCol(notNone=True, length=250)
  tag_info = sqlobject.UnicodeCol(default=None, length=250)
  msg = sqlobject.UnicodeCol(default=None, length=250)
  # To cache results from checkpkg
  overridden = sqlobject.BoolCol(default=False)
  # The same package might have different sets of errors for different
  # catalogs or Solaris releases.
  os_rel = sqlobject.ForeignKey('OsRelease', notNone=True)
  arch = sqlobject.ForeignKey('Architecture', notNone=True)
  catrel = sqlobject.ForeignKey('CatalogRelease', notNone=True)

  def __unicode__(self):
    return (u"CheckpkgErrorTag: %s %s %s"
            % (self.pkgname, self.tag_name, self.tag_info))
Exemplo n.º 21
0
class SingleImageRow(sqlobject.SQLObject):
    # single big text field for tags
    tags = sqlobject.StringCol()
    rawData = sqlobject.StringCol()
    hits = sqlobject.IntCol()
    originalPathName = sqlobject.StringCol()
    name = sqlobject.StringCol()
    dataType = sqlobject.StringCol()
    series = sqlobject.ForeignKey("ImageSeriesRow", default=None)
Exemplo n.º 22
0
class Town(Place):
    """
    Place which falls into Town or Unknown category in Twitter API.
    """

    _inheritable = False

    # Country which this Town belongs. Optional and defaults to None.
    country = so.ForeignKey("Country", default=None)
    countryIdx = so.DatabaseIndex(country)
Exemplo n.º 23
0
class Guest(DictSQLObject):
    """
    Collects information about Guests
    Refrenced to by the ChatMsg Table
    """
    name = so.UnicodeCol()
    admin = so.BoolCol(default=False)
    parprop = so.IntCol(default=-1)
    token = so.StringCol(length=8)
    event = so.ForeignKey('Event')
Exemplo n.º 24
0
class Srv4FileInCatalog(sqlobject.SQLObject):
    """Assignment of a particular srv4 file to a specific catalog.

  There could be one more layer, to which arch and osrel could be moved.
  But for now, it's going to be a not-normalized structure.
  """
    arch = sqlobject.ForeignKey('Architecture', notNone=True)
    osrel = sqlobject.ForeignKey('OsRelease', notNone=True)
    catrel = sqlobject.ForeignKey('CatalogRelease', notNone=True)
    srv4file = sqlobject.ForeignKey('Srv4FileStats', notNone=True)
    uniqueness_idx = sqlobject.DatabaseIndex('arch',
                                             'osrel',
                                             'catrel',
                                             'srv4file',
                                             unique=True)

    def __unicode__(self):
        return (u"%s is in catalog %s %s %s" %
                (self.srv4file, self.arch.name, self.osrel.full_name,
                 self.catrel.name))
Exemplo n.º 25
0
class Lyric(sqlobject.SQLObject):
    _connection = conn
    sid = sqlobject.IntCol(length=14, unique=True)
    song = sqlobject.UnicodeCol(length=255)
    lrc = sqlobject.UnicodeCol(length=255)
    artist_id = sqlobject.ForeignKey('Artist')
    aid = sqlobject.IntCol(length=14)

    #new add field
    local_path = sqlobject.UnicodeCol(length=255, default=None)
    sizes = sqlobject.IntCol(default=None)
    source = sqlobject.UnicodeCol(default=None)
Exemplo n.º 26
0
class Continent(Place):
    """
    A continent, which can have countries.
    """

    _inheritable = False

    # Supername which this Continent belongs to.
    supername = so.ForeignKey("Supername")

    # Get Country objects belonging to the Continent. Defaults to null list.
    hasCountries = so.MultipleJoin("Country")
Exemplo n.º 27
0
class Source(so.SQLObject):
    """
    Model a datasource of exported or manually created webpage data.
    """

    # Creation date of source. This could be the last day that a source
    # was used and that could be related to moving away from using a device
    # or exporting data from a company computer before leaving a job.
    date_created = so.DateCol(notNull=True)
    date_created_idx = so.DatabaseIndex(date_created)

    # The format of the datasource.
    format_ = so.ForeignKey('Format', notNull=True)

    # The web browser where the data originated.
    browser = so.ForeignKey('Browser')

    # The location where one lived and worked when creating the datasource.
    location = so.ForeignKey('Location')

    # True if it was work related, false if it was personal.
    is_work = so.BoolCol(notNull=True)
Exemplo n.º 28
0
class Job(sqlobject.SQLObject):

    status = sqlobject.IntCol(default=JobStatus.UNKNOWN)
    package = sqlobject.ForeignKey('Package', cascade=True)

    dist = sqlobject.StringCol(default='unreleased')
    arch = sqlobject.StringCol(default='any')

    creation_date = sqlobject.DateTimeCol(default=sqlobject.DateTimeCol.now)
    build_host = sqlobject.StringCol(default=None)
    status_changed = sqlobject.DateTimeCol(default=None)
    build_start = sqlobject.DateTimeCol(default=None)
    build_end = sqlobject.DateTimeCol(default=None)

    def __init__(self, *args, **kwargs):
        sqlobject.SQLObject.__init__(self, *args, **kwargs)
        self.status_lock = status_lock

    def __setattr__(self, name, value):
        if name == "status":
            self.status_changed = sqlobject.DateTimeCol.now()

        sqlobject.SQLObject.__setattr__(self, name, value)

    def dict(self):

        result = {
            "id": self.id,
            "task": "%s/%s" % (self.dist, self.arch),
            "build_host": self.build_host,
            "status": JobStatus.whatis(self.status),
            "dist": self.dist,
            "arch": self.arch,
            "creation_date": try_strftime(self.creation_date),
            "build_start": try_strftime(self.build_start),
            "build_end": try_strftime(self.build_end),
            "status_changed": try_strftime(self.status_changed)
        }
        return result

    def start(self, slave, builder):
        if self.status != JobStatus.WAIT_LOCKED:
            raise ValueError("JobStatus is not WAIT_LOCKED")
        else:
            self.status = JobStatus.BUILDING
            self.build_start = sqlobject.DateTimeCol.now()
            self.build_host = slave.name
            kwargs = self.dict()
            kwargs.update(self.package.dict())
            return slave.build(self.id, builder, kwargs)
Exemplo n.º 29
0
class Country(Place):
    """
    Place which is a Country in Twitter API.
    """

    _inheritable = False

    # Continent which this Country belongs to.
    continent = so.ForeignKey("Continent", default=None)

    # Get Town objects belonging to the Country. Defaults to null list.
    hasTowns = so.MultipleJoin("Town")

    # Two-character string as the country's code.
    countryCode = so.StringCol(length=2, default=None)
Exemplo n.º 30
0
class ObservationCalibration(sqlobject.SQLObject):

    cluster = sqlobject.StringCol(length=55)
    filter = sqlobject.StringCol(length=55)
    mangledSpecification = sqlobject.StringCol(length=250)
    calibration = sqlobject.ForeignKey('ZeropointEntry')

    ClusterFilterIndex = sqlobject.DatabaseIndex('cluster',
                                                 'filter',
                                                 'mangledSpecification',
                                                 unique=True)

    def _get_specification(self):
        return unmangleSpecification(self.mangledSpecification)

    def _set_specification(self, **specification):
        self.mangledSpecification = mangleSpecification(specification)