def setUp(self): self.ps = Server.getService("PersistenceService") self.ms = Server.getService("MappingService") self.ms.registerMapper(Widget, InMemoryDataMapper() ) self.rs = Server.getService("RelationService") Server.txn.begin()
def setUp(self): self.ps = Server.getService("PersistenceService") self.ms = Server.getService("MappingService") self.mapper = ZODBMapper.ZODBEntityMapper() self.ms.registerMapper(MoneyWidget, self.mapper ) self.currency = getCurrency('usd') self.money = Money(10.00, self.currency) Server.txn.begin()
def setUp(self): self.ps = Server.getService("PersistenceService") self.wh = Server.getHome("widgetHome") # self.ms = Server.getService("MappingService") # self.mapper = InMemoryDataMapper() # self.ms.registerMapper(Widget, self.mapper ) Server.txn.begin()
def setUp(self): txnStart() self._pool = Server.getService("PSQLPool") self._conn = self._pool.getConnection() self._cursor = self._conn.cursor() self.wHome = Server.getHome("widgetHome") self.dHome = Server.getHome("doodleHome") self.d1 = self.dHome.create() self.w1 = self.wHome.create() self.w1._set_doodle(self.d1)
def testKey(self): kgs = Server.getService("KeyGenService") kg = kgs.getKeyGenerator('') key = kg.nextKey() key2 = kg.nextKey() assert (int(key.split('-')[1]) +1) == (int(key2.split('-')[1])) Server.txn.commit(0) txnStart() key = kg.currentKey() assert key == key2
def testCreateEntity(self): wHome = Server.getHome("widgetHome") widget = wHome.create() pKey = widget._get_primaryKey() Server.txn.commit(0) txnStart() pool = Server.getService("PSQLPool") conn = pool.getConnection() cursor = conn.cursor() cursor.execute("SELECT primaryKey, wedgie FROM Widget WHERE primaryKey='%s'" % pKey) assert cursor.rowcount == 1, "Should have found 1 record matching widget. Found: %s" % cursor.rowcount data = cursor.fetchone() assert data[0] == pKey assert data[1] == 0
##from Rambler import ZODBPool, ZODBMapper ##from ZODB import FileStorage, Persistent, DB ##from tempfile import mktemp ##tempdir = '/tmp' # Just for now ##filename = mktemp() ##storage = FileStorage.FileStorage(filename) ##db = DB(storage, cache_size=1000) ##Server.registerService(ZODBPool.ZODBConnectionPool(db, 6), "ZODBPool") from Rambler.ciRelationService import ciRelationService RS = Server.registerService(ciRelationService, "RelationService") Server.loadDescriptor('widget.xml') #RS.registerRelation("relation", Promiscuous()) ES = Server.getService("EventService") ES.publishEvent("Initializing", Server, "") # Needed to init the ZODB properly from Rambler.tests.Widget import Widget, WidgetHome #Server.loadConfig(Widget, 'Widget.cfg') #Server.registerEntity(WidgetHome, Widget) # Commit the transaction server starts at init Server.txn.commit(0) from time import time, sleep
def setUp(self): self.ds = Server.getService("EntityDescriptionService")
from Rambler import Server Server.init("giop:tcp::6666") # from Rambler.PersistenceService import PersistenceService, InMemoryDataMapper from Rambler.PSQLPool import PSQLPool Server.registerService(PSQLPool("host=dev2", 20), "PSQLPool") Server.loadDescriptor("widget.xml") import Rambler.PostgresMappers tid = Server.txn.get_transaction_name() Server.getService("EventService").publishEvent("Initializing", Server, tid) # from tempfile import mktemp # from threading import Thread from time import time # from thread import get_ident from Rambler.tests.Widget import Widget # Commit the transaction server starts at init Server.txn.commit(0) class Test(unittest.TestCase): def setUp(self):
def setUp(self): self.ds = Server.getService("TXNDescriptionService")
def setUp(self): self.ps = Server.getService("PersistenceService") self.ms = Server.getService("MappingService") self.mapper = ZODBMapper.ZODBEntityMapper() self.ms.registerMapper(Widget, self.mapper ) Server.txn.begin()
def setUp(self): self.eds = Server.getService("EntityDescriptionService") self.rr = Server.getService("RelationRegistryService") self.qs = PostgresQueryService txnStart()
#from Rambler.tests.Widget import Widget from Rambler.PSQLPool import PSQLPool Server.registerService(PSQLPool("",10), "PSQLPool") from Rambler.HiLowKeyGenService import HiLowKeyGenService, IncrementalKeyGenService, Key Server.registerService(HiLowKeyGenService, "KeyGenService") Server.registerService(IncrementalKeyGenService, "IKeyGenService") from Rambler.SQLDescriptionService import PostgresSQLDescriptionService sqld=Server.registerService(PostgresSQLDescriptionService, "SQLDescriptionService") from Rambler.PostgresMappers import PostgresEntityMapper, PostgresRelationMapper, PostgresKeyMapper ED = Server.getService("EntityDescriptionService") MS = Server.getService("MappingService") from Rambler.ciRelationService import SingleRelationRecord, ManyRelationRecord, RelationDiary MS.registerMapper(SingleRelationRecord, PostgresRelationMapper) MS.registerMapper(ManyRelationRecord, PostgresRelationMapper) MS.registerMapper(RelationDiary, PostgresRelationMapper) MS.registerMapper(Key, PostgresKeyMapper) #Server.registerService(ciRelationService, "RelationService") Server.loadDescriptor("widget.xml") sqld.load("deployment.xml") PostgresRelationMapper.init() PostgresEntityMapper.init()
def setUp(self): self.ec = Server.getService("EventChannel") self.ps = Server.getService("PersistenceService") Server.txn.begin() self.ps._getUnitOfWork()
def __init__(self): self.ec = Server.getService("EventService") self.ec.registerEvent("vote", self, Vote) self.ec.subscribeToEvent("prepare", self, str)
import unittest from Rambler import Server Server.init("giop:tcp::6666") # Forget about the first transaction Server.txn.commit(0) PS = Server.getService("PersistenceService") from CosTransactions import StatusActive, StatusMarkedRollback from PSQLPool import PSQLPool import logging import logging.config logging.config.fileConfig("log.cfg") log = logging.getLogger("DBPool") import thread import threading from time import sleep def txnStart(): # Starts the txn and tickles the PersistenceService so the right # events are published Server.txn.begin() # Gurantees that the commit/rollback events will be published PS._getUnitOfWork() class Test(unittest.TestCase):