コード例 #1
0
ファイル: stores.py プロジェクト: olivecoder/mamba-storm
 def test_get_store(self):
     conf.settings.MIDDLEWARE_CLASSES += (
         "storm.django.middleware.ZopeTransactionMiddleware",)
     conf.settings.STORM_STORES = {"name": "sqlite:"}
     store = stores.get_store("name")
     self.assertTrue(isinstance(store, Store))
     # Calling get_store() twice returns the same store.
     store2 = stores.get_store("name")
     self.assertTrue(store is store2)
コード例 #2
0
ファイル: backend.py プロジェクト: olivecoder/mamba-storm
    def test_create_wrapper(self):
        wrapper = make_wrapper()
        self.assertTrue(isinstance(wrapper, self.get_wrapper_class()))

        # The wrapper uses the same database connection as the store.
        store = stores.get_store("django")
        self.assertEqual(store._connection._raw_connection, wrapper.connection)
コード例 #3
0
ファイル: backend.py プロジェクト: datnguyen0606/storm
    def test_create_wrapper(self):
        wrapper = make_wrapper()
        self.assertTrue(isinstance(wrapper, self.get_wrapper_class()))

        # The wrapper uses the same database connection as the store.
        store = stores.get_store("django")
        self.assertEqual(store._connection._raw_connection, wrapper.connection)
コード例 #4
0
ファイル: base.py プロジェクト: Jokymon/timetracker
 def _get_connection(self):
     if self._store is None:
         self._store = get_store(settings.DATABASE_NAME)
     # Make sure that the store is registered with the transaction
     # manager: we don't know what the connection will be used for.
     self._store._event.emit("register-transaction")
     self._store._connection._ensure_connected()
     return self._store._connection._raw_connection
コード例 #5
0
ファイル: base.py プロジェクト: olivecoder/mamba-storm
 def _get_connection(self):
     if self._store is None:
         self._store = get_store(settings.DATABASE_NAME)
     # Make sure that the store is registered with the transaction
     # manager: we don't know what the connection will be used for.
     self._store._event.emit("register-transaction")
     self._store._connection._ensure_connected()
     return self._store._connection._raw_connection
コード例 #6
0
ファイル: stores.py プロジェクト: olivecoder/mamba-storm
    def test_get_store_returns_per_thread_stores(self):
        conf.settings.MIDDLEWARE_CLASSES += (
            "storm.django.middleware.ZopeTransactionMiddleware",)
        conf.settings.STORM_STORES = {"name": "sqlite:"}

        store = stores.get_store("name")
        other_stores = []
        def f():
            other_stores.append(stores.get_store("name"))

        thread = threading.Thread(target=f)
        thread.start()
        thread.join()
        self.assertEqual(len(other_stores), 1)
        self.assertNotEqual(other_stores[0], store)
コード例 #7
0
ファイル: stores.py プロジェクト: olivecoder/mamba-storm
 def f():
     other_stores.append(stores.get_store("name"))
コード例 #8
0
ファイル: backend.py プロジェクト: datnguyen0606/storm
 def drop_tables(self):
     store = stores.get_store("django")
     store.execute("DROP TABLE django_test")
     transaction.commit()
コード例 #9
0
ファイル: backend.py プロジェクト: datnguyen0606/storm
 def create_tables(self):
     store = stores.get_store("django")
     store.execute("CREATE TABLE django_test ("
                   "  id INT AUTO_INCREMENT PRIMARY KEY,"
                   "  title TEXT) ENGINE=InnoDB")
     transaction.commit()
コード例 #10
0
ファイル: backend.py プロジェクト: datnguyen0606/storm
 def create_tables(self):
     store = stores.get_store("django")
     store.execute("CREATE TABLE django_test ("
                   "  id SERIAL PRIMARY KEY,"
                   "  title TEXT)")
     transaction.commit()
コード例 #11
0
ファイル: backend.py プロジェクト: datnguyen0606/storm
 def test_using_wrapper_joins_transaction(self):
     wrapper = make_wrapper()
     cursor = wrapper.cursor()
     cursor.execute("SELECT 1")
     self.assertInTransaction(stores.get_store("django"))
コード例 #12
0
ファイル: base.py プロジェクト: anilbektash/storm
 def _get_connection(self):
     if self._store is None:
         self._store = get_store(settings.DATABASE_NAME)
     return self._store._connection._raw_connection
コード例 #13
0
ファイル: backend.py プロジェクト: olivecoder/mamba-storm
 def drop_tables(self):
     store = stores.get_store("django")
     store.execute("DROP TABLE django_test")
     transaction.commit()
コード例 #14
0
ファイル: backend.py プロジェクト: olivecoder/mamba-storm
 def create_tables(self):
     store = stores.get_store("django")
     store.execute("CREATE TABLE django_test ("
                   "  id INT AUTO_INCREMENT PRIMARY KEY,"
                   "  title TEXT) ENGINE=InnoDB")
     transaction.commit()
コード例 #15
0
ファイル: backend.py プロジェクト: olivecoder/mamba-storm
 def create_tables(self):
     store = stores.get_store("django")
     store.execute("CREATE TABLE django_test ("
                   "  id SERIAL PRIMARY KEY,"
                   "  title TEXT)")
     transaction.commit()
コード例 #16
0
ファイル: backend.py プロジェクト: olivecoder/mamba-storm
 def test_using_wrapper_joins_transaction(self):
     wrapper = make_wrapper()
     cursor = wrapper.cursor()
     cursor.execute("SELECT 1")
     self.assertInTransaction(stores.get_store("django"))