Esempio n. 1
0
 def __init__(self, uri=None, supports_transactions=True):
     if not uri:
         uri = config.get("sqlobject.dburi")
     self.uri = uri
     self.supports_transactions = supports_transactions
     hub_registry.add(self)
     ConnectionHub.__init__(self)
Esempio n. 2
0
 def __init__(self, uri=None, supports_transactions=True):
     if not uri:
         uri = config.get("sqlobject.dburi")
     self.uri = uri
     self.supports_transactions = supports_transactions
     hub_registry.add(self)
     ConnectionHub.__init__(self)
Esempio n. 3
0
 def doInTransaction(self, func, *args, **kw):
     """Run a function in a transaction"""
     if not hasattr(self.threadingLocal, "connection"):
         self.getConnection()
     return ConnectionHub.doInTransaction(self, func, *args, **kw)
Esempio n. 4
0
 def __init__(self, uri=None, pool_connections=True):
     if not uri:
         uri = pylons.config.get('sqlobject.dburi')
     self.uri = uri
     self.pool_connections = pool_connections
     ConnectionHub.__init__(self)
Esempio n. 5
0
from sqlobject import *
from sqlobject.dbconnection import ConnectionHub

hub = ConnectionHub()
__connection__ = hub


class Person(SQLObject):
    name = StringCol(length=100, default=None)
    address = StringCol(default=None)
    birthday = DateCol(default=None)
    phones = MultipleJoin("Phone")
    category = ForeignKey("Category", default=None)


class Phone(SQLObject):
    number = StringCol(length=20, default=None)
    person = ForeignKey("Person")


class Category(SQLObject):
    name = StringCol(length=20, alternateID=True)
    persons = RelatedJoin("Person")


def createTables(ifNotExists=True):
    Person.createTable(ifNotExists=ifNotExists)
    Phone.createTable(ifNotExists=ifNotExists)
    Category.createTable(ifNotExists=ifNotExists)

Esempio n. 6
0
 def doInTransaction(self, func, *args, **kw):
     """Run a function in a transaction"""
     if not hasattr(self.threadingLocal, "connection"):
         self.getConnection()
     return ConnectionHub.doInTransaction(self, func, *args, **kw)
Esempio n. 7
0
 def __init__(self, uri=None, pool_connections=True):
     if not uri:
         uri = pylons.config.get('sqlobject.dburi')
     self.uri = uri
     self.pool_connections = pool_connections
     ConnectionHub.__init__(self)