Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class State(sqlobject.SQLObject):
name = sqlobject.StringCol(alternateID=True)
class Revision(sqlobject.SQLObject):
"""A Revision to the domain model.
A revision in the is valid only if {number} is not null (there may be some
non-valid revisions in the database which correspond to failed or pending transactions).
"""
# should default to pending category
state = sqlobject.ForeignKey('State', default=3)
number = sqlobject.IntCol(default=None, unique=True)
author = sqlobject.UnicodeCol(default=None)
log_message = sqlobject.UnicodeCol(default=None)
# for a transaction this time it started
# for a revision time it was completed
timestamp = sqlobject.DateTimeCol(default=datetime.now())
base_revision = sqlobject.ForeignKey('Revision', default=None)
# sqlobject takees over __init__ ...
def _init(self, *args, **kw):
sqlobject.SQLObject._init(self, *args, **kw)
# TODO: start db transaction .... actually not sure about this (maybe
# txns can persist across sessions)
# self.model = DomainModel(self, self.is_transaction)
self.model = None
def is_transaction(self):
is_txn = self.state == State.byName('pending')
from sylk.database import Database
db = Null()
class MessageHistory(SQLObject):
class sqlmeta:
table = ConferenceConfig.history_table
date = DateTimeCol()
room_uri = UnicodeCol()
sip_from = UnicodeCol()
cpim_body = UnicodeCol(sqlType='LONGTEXT')
cpim_content_type = UnicodeCol()
cpim_sender = UnicodeCol()
cpim_recipient = UnicodeCol()
cpim_timestamp = DateTimeCol()
def initialize():
global db
db = Database(ConferenceConfig.db_uri)
MessageHistory._connection = db.connection
db.create_table(MessageHistory)
def _save_message(sip_from, room_uri, cpim_body, cpim_content_type, cpim_sender, cpim_recipient, cpim_timestamp):
for x in xrange(0, 3):
try:
return MessageHistory(date = datetime.datetime.utcnow(),
room_uri = room_uri,
sip_from = sip_from,
def jsonify_group(obj):
"""Convert group to JSON."""
result = jsonify_sqlobject(obj)
result["users"] = [u.user_name for u in obj.users]
result["permissions"] = [p.permission_name for p in obj.permissions]
return result
class TG_User(InheritableSQLObject):
"""Reasonably basic User definition."""
class sqlmeta:
table = "tg_user"
user_name = UnicodeCol(length=16, alternateID=True,
alternateMethodName="by_user_name")
email_address = UnicodeCol(length=255, alternateID=True,
alternateMethodName="by_email_address")
display_name = UnicodeCol(length=255)
password = UnicodeCol(length=40)
created = DateTimeCol(default=datetime.now)
# Old attribute names
userId = DeprecatedAttr("userId", "user_name")
emailAddress = DeprecatedAttr("emailAddress", "email_address")
displayName = DeprecatedAttr("displayName", "display_name")
# groups this user belongs to
groups = RelatedJoin("TG_Group", intermediateTable="tg_user_group",
joinColumn="user_id", otherColumn="group_id")
def _get_permissions(self):
perms = set()
# TODO: probably should not have this on the revision as immutable
name = sqlobject.UnicodeCol(default=None)
class PackageTagRevision(vdm.sqlobject.base.ObjectRevisionSQLObject):
base = sqlobject.ForeignKey('PackageTag')
class Package(vdm.sqlobject.base.VersionedDomainObject):
sqlobj_version_class = PackageRevision
versioned_attributes = vdm.sqlobject.base.get_attribute_names(sqlobj_version_class)
name = sqlobject.UnicodeCol(alternateID=True)
# should be attribute_name, module_name, module_object
m2m = [ ('tags', 'vdm.sqlobject.demo', 'Tag', 'PackageTag') ]
class Tag(vdm.sqlobject.base.VersionedDomainObject):
sqlobj_version_class = TagRevision
name = sqlobject.UnicodeCol(alternateID=True)
versioned_attributes = vdm.sqlobject.base.get_attribute_names(sqlobj_version_class)
m2m = []
class PackageTag(vdm.sqlobject.base.VersionedDomainObject):
name = UnicodeCol()
taskNodeId = IntCol()
folderNodeId = IntCol()
class Tasks(SQLObject):
class sqlmeta:
lazyUpdate = True
name = UnicodeCol()
parentId = IntCol()
user = UnicodeCol()
priority = IntCol()
dispatchKey = FloatCol()
maxRN = IntCol()
runner = UnicodeCol()
environment = UnicodeCol()
requirements = UnicodeCol()
minNbCores = IntCol()
maxNbCores = IntCol()
ramUse = IntCol()
licence = UnicodeCol()
tags = UnicodeCol()
validationExpression = UnicodeCol()
archived = BoolCol()
args = UnicodeCol()
# REZ env management support
runnerPackages = UnicodeCol()
watcherPackages = UnicodeCol()
# Adding autoretry capability on task
maxAttempt = IntCol()
maxRN = IntCol()
runner = UnicodeCol()
environment = UnicodeCol()
requirements = UnicodeCol()
minNbCores = IntCol()
maxNbCores = IntCol()
ramUse = IntCol()
licence = UnicodeCol()
tags = UnicodeCol()
validationExpression = UnicodeCol()
archived = BoolCol()
args = UnicodeCol()
# REZ env management support
runnerPackages = UnicodeCol()
watcherPackages = UnicodeCol()
# Adding autoretry capability on task
maxAttempt = IntCol()
class Commands(SQLObject):
class sqlmeta:
lazyUpdate = True
description = UnicodeCol()
taskId = IntCol()
status = IntCol()
completion = FloatCol()
creationTime = DateTimeCol()
startTime = DateTimeCol()
updateTime = DateTimeCol()
endTime = DateTimeCol()
from octopus.core import singletonconfig
LOGGER = logging.getLogger('main.dispatcher')
class FolderNodes(SQLObject):
class sqlmeta:
lazyUpdate = True
name = UnicodeCol()
parentId = IntCol()
user = UnicodeCol()
priority = IntCol()
dispatchKey = FloatCol()
maxRN = IntCol()
taskGroupId = IntCol()
strategy = UnicodeCol()
creationTime = DateTimeCol()
startTime = DateTimeCol()
updateTime = DateTimeCol()
endTime = DateTimeCol()
archived = BoolCol()
dependencies = MultipleJoin('Dependencies')
class TaskNodes(SQLObject):
class sqlmeta:
lazyUpdate = True
name = UnicodeCol()
parentId = IntCol()
user = UnicodeCol()
priority = IntCol()
dispatchKey = FloatCol()
"""Runs cleartext_password through the hash algorithm before saving."""
password_hash = identity.encrypt_password(cleartext_password)
self._SO_set_password(password_hash)
def set_password_raw(self, password):
"""Saves the password as-is to the database."""
self._SO_set_password(password)
class Permission(SQLObject):
"""
A relationship that determines what each Group can do
"""
permission_name = UnicodeCol(length=16, alternateID=True,
alternateMethodName='by_permission_name')
description = UnicodeCol(length=255)
groups = RelatedJoin('Group',
intermediateTable='group_permission',
joinColumn='permission_id',
otherColumn='group_id')
from sylk.applications.conference.configuration import ConferenceConfig
from sylk.applications.conference.logger import log
from sylk.database import Database
db = Null()
class MessageHistory(SQLObject):
class sqlmeta:
table = ConferenceConfig.history_table
date = DateTimeCol()
room_uri = UnicodeCol()
sip_from = UnicodeCol()
cpim_body = UnicodeCol(sqlType='LONGTEXT')
cpim_content_type = UnicodeCol()
cpim_sender = UnicodeCol()
cpim_recipient = UnicodeCol()
cpim_timestamp = DateTimeCol()
def initialize():
global db
db = Database(ConferenceConfig.db_uri)
MessageHistory._connection = db.connection
db.create_table(MessageHistory)
def _save_message(sip_from, room_uri, cpim_body, cpim_content_type, cpim_sender, cpim_recipient, cpim_timestamp):
for x in xrange(0, 3):
try:
STATUS_CONFIRMED: _(u'Confirmed'),
STATUS_CANCELLED: _(u'Cancelled')}
identifier = AutoIncCol('stoqlib_payment_identifier_seq')
status = IntCol(default=STATUS_PREVIEW)
open_date = DateTimeCol(default=datetime.now)
due_date = DateTimeCol()
paid_date = DateTimeCol(default=None)
cancel_date = DateTimeCol(default=None)
paid_value = PriceCol(default=0)
base_value = PriceCol()
value = PriceCol()
interest = PriceCol(default=0)
discount = PriceCol(default=0)
description = UnicodeCol(default=None)
payment_number = UnicodeCol(default=None)
method = ForeignKey('AbstractPaymentMethodAdapter')
# FIXME: Move to methods itself?
method_details = ForeignKey('PaymentMethodDetails', default=None)
group = ForeignKey('AbstractPaymentGroup')
till = ForeignKey('Till')
destination = ForeignKey('PaymentDestination')
def _check_status(self, status, operation_name):
assert self.status == status, ('Invalid status for %s '
'operation: %s' % (operation_name,
self.statuses[self.status]))
#
# SQLObject hooks
#