How to use the sqlobject.DateTimeCol function in SQLObject

To help you get started, we’ve selected a few SQLObject examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github okfn / vdm / vdm / sqlobject / base.py View on Github external
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')
        return is_txn

    def set_model(self, model):
        self.model = model
github facundobatista / kilink / wsgi / backend.py View on Github external
self.kid = kid

    def __repr__(self):
        return "There is already kilink for kid = %s" % str(self.kid)

class KiUser(sqlobject.SQLObject):
    name = sqlobject.UnicodeCol()
    email = sqlobject.StringCol()

class Kilink(sqlobject.SQLObject):
    kid = sqlobject.StringCol()
    revno = sqlobject.IntCol()
    parent_revno = sqlobject.IntCol()
    user = sqlobject.ForeignKey('KiUser')
    content = sqlobject.PickleCol() ## in the future we can store preprocessed HTML objects
    timestamp  = sqlobject.DateTimeCol()


def create_user(name, email):
    p = KiUser(name = name, email = email)
    return p.id

def create_kilink(user, content, kid=None, timestamp=None):

    if not kid:
        kid = base62_encode(int(uuid.uuid4()))

    results = Kilink.selectBy(kid=kid)
    if results.count() > 0:
        raise ExistingKilink(kid)
github stoq / stoq / stoq / domain / purchase.py View on Github external
ORDER_QUOTING       : _('Quoting'),
                ORDER_PENDING       : _('Pending'),
                ORDER_CONFIRMED     : _('Confirmed'),
                ORDER_CLOSED        : _('Closed')}

    (FREIGHT_FOB,
     FREIGHT_CIF) = range(2)

    freight_types = {FREIGHT_FOB    : _('FOB'),
                     FREIGHT_CIF    : _('CIF')}
    
    status = IntCol(default=ORDER_QUOTING)
    # Field order_number must be unique. Waiting for bug 2214
    order_number = IntCol(default=None)
    open_date = DateTimeCol(default=datetime.datetime.now)
    quote_deadline = DateTimeCol(default=None)
    expected_receival_date = DateTimeCol(default=None)
    expected_pay_date = DateTimeCol(default=None)
    receival_date = DateTimeCol(default=None)
    confirm_date = DateTimeCol(default=None)
    notes = StringCol(default='')
    salesperson_name = StringCol(default='')
    freight_type = IntCol(default=FREIGHT_FOB)
    freight = FloatCol(default=0.0)
    charge_value = PriceCol(default=0.0)
    discount_value = PriceCol(default=0.0)
    supplier = ForeignKey('PersonAdaptToSupplier')
    branch = ForeignKey('PersonAdaptToBranch')
    transporter = ForeignKey('PersonAdaptToTransporter', default=None)

    #
    # SQLObject hooks
github hudora / huTools / huTools / huLint.py View on Github external
DATABASE_URI = "sqlite:///Users/chris/Desktop/database.db"
MINIMUM_SCORE = 8.0


class PythonScore(sqlobject.SQLObject):
    """
    OO mapping of the score for a Python file
    """
    username = sqlobject.StringCol()
    pathname = sqlobject.StringCol()
    revision = sqlobject.StringCol()
    score = sqlobject.FloatCol()
    old_score = sqlobject.FloatCol()
    credit = sqlobject.FloatCol()
    date = sqlobject.DateTimeCol(default=sqlobject.DateTimeCol.now)


def process_file(filename):
    """
    Analyze the file with pylint and write the result
    to a database
    """
    linter = PyLinter()

    checkers.initialize(linter)
    linter.read_config_file()
    linter.quiet = 1

    filemods = linter.expand_files((filename, ))
    if filemods:
        old_stats = config.load_results(filemods[0].get('basename'))
github stoq / stoq / stoq / domain / till.py View on Github external
are opening the till. This value is useful
                                  when providing change during sales.
        - I{branch}: a till operation is always associated with a branch 
                     which can means a store or a warehouse
    """

    (STATUS_PENDING, 
     STATUS_OPEN, 
     STATUS_CLOSED) = range(3)

    status = IntCol(default=STATUS_PENDING)
    balance_sent = FloatCol(default=None)
    initial_cash_amount = FloatCol(default=0.0)
    final_cash_amount = FloatCol(default=None)
    opening_date = DateTimeCol(default=datetime.datetime.now)
    closing_date = DateTimeCol(default=None)

    branch = ForeignKey('PersonAdaptToBranch')

    def get_balance(self):
        """ Return the total of all "extra" payments (like cash
        advance, till complement, ...) associated to this till
        operation *plus* all the payments, which payment method is
        money, of all the sales associated with this operation 
        *plus* the initial cash amount. 
        """

        conn = self.get_connection()
        result = Sale.selectBy(till=self, connection=conn)

        query = AND(Sale.q.status == Sale.STATUS_CONFIRMED,
                    Sale.q.tillID == self.id)
github AGProjects / openxcap / xcap / backend / sipthor.py View on Github external
class JSONCol(Col):
    baseClass = SOJSONCol


class SipAccount(SQLObject):
    class sqlmeta:
        table = 'sip_accounts_meta'
    username   = StringCol(length=64)
    domain     = StringCol(length=64)
    firstName  = StringCol(length=64)
    lastName   = StringCol(length=64)
    email      = StringCol(length=64)
    customerId = IntCol(default=0)
    resellerId = IntCol(default=0)
    ownerId    = IntCol(default=0)
    changeDate = DateTimeCol(default=DateTimeCol.now)
    ## joins
    data       = MultipleJoin('SipAccountData', joinColumn='account_id')

    def _set_profile(self, value):
        data = list(self.data)
        if not data:
            SipAccountData(account=self, profile=value)
        else:
            data[0].profile = value

    def _get_profile(self):
        return self.data[0].profile

    def set(self, **kwargs):
        kwargs = kwargs.copy()
        profile = kwargs.pop('profile', None)
github mikrosimage / OpenRenderManagement / src / octopus / dispatcher / db / pulidb.py View on Github external
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()
    maxRN = IntCol()
    taskId = IntCol()
github stoq / stoq / stoqlib / domain / payment / base.py View on Github external
STATUS_PAID,
     STATUS_REVIEWING,
     STATUS_CONFIRMED,
     STATUS_CANCELLED) = range(6)

    statuses = {STATUS_PREVIEW: _(u'Preview'),
                STATUS_PENDING: _(u'To Pay'),
                STATUS_PAID: _(u'Paid'),
                STATUS_REVIEWING: _(u'Reviewing'),
                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')
github shad7 / seedbox / seedbox / db / schema.py View on Github external
a value of type string
    .. py:attribute:: val_int
        a value of type int
    .. py:attribute:: val_list
        a value of type list
    .. py:attribute:: val_flag
        a value of type boolean
    .. py:attribute:: val_date
        a value of type date
    """
    name = sqlobject.StringCol(unique=True)
    val_str = sqlobject.StringCol(default=None)
    val_int = sqlobject.IntCol(default=-99999)
    val_list = sqlobject.StringCol(default=None)
    val_flag = sqlobject.BoolCol(default=False)
    val_date = sqlobject.DateTimeCol(default=sqlobject.DateTimeCol.now)


def _get_db_file():
    return os.path.abspath(os.path.join(cfg.CONF.config_dir, DB_NAME))


def _init_connection(dbloc):

    connect_str = '{0}{1}{2}'.format('sqlite:', dbloc, '?driver=sqlite3')
    LOG.trace('establishing connection to database: [%s]', connect_str)
    # create connection to the database
    sqlobject.sqlhub.processConnection = sqlobject.connectionForURI(
        connect_str)


def _init_tables():