コード例 #1
0
 def test_set_get_separate_transactions(self):
     with transaction.wrap() as trans:
         trans.add_message('dummy')
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
     self.assert_file_exists('foo')
     with transaction.wrap() as trans:
         eq_(trans.get_blob(['foo']).decode('utf-8'), 'bar')
     self.assert_file_exists('foo')
コード例 #2
0
 def test_set_get_separate_transactions(self):
     with transaction.wrap() as trans:
         trans.add_message('dummy')
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
     self.assert_file_exists('foo')
     with transaction.wrap() as trans:
         eq_(trans.get_blob(['foo']).decode('utf-8'), 'bar')
     self.assert_file_exists('foo')
コード例 #3
0
ファイル: fields.py プロジェクト: jathanism/python-git-orm
 def __get__(self, instance, owner):
     if instance is None:
         return self
     with transaction.wrap() as trans:
         if instance.pk:
             return trans.stat(instance.path).updated_at
         return None
コード例 #4
0
 def test_wrap(self):
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         trans.add_message('foobar')
         self.assert_commit_count(0)
     self.assert_commit_count(1)
     self.assert_file_exists('foo')
コード例 #5
0
 def test_wrap(self):
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         trans.add_message('foobar')
         self.assert_commit_count(0)
     self.assert_commit_count(1)
     self.assert_file_exists('foo')
コード例 #6
0
ファイル: fields.py プロジェクト: keyvankhademi/tps-web
 def __get__(self, instance, owner):
     if instance is None:
         return self
     with transaction.wrap() as trans:
         if instance.pk:
             return trans.stat(instance.path).updated_at
         return None
コード例 #7
0
ファイル: git.py プロジェクト: natano/tiget
def init_repo():
    from git_orm import transaction

    if is_repo_initialized():
        raise GitError('repository is already initialized')

    with transaction.wrap() as trans:
        tigetrc = pkg_resources.resource_string('tiget', 'data/tigetrc')
        trans.set_blob(['config', 'tigetrc'], tigetrc)
        trans.add_message('Initialize Repository')
コード例 #8
0
ファイル: importer.py プロジェクト: jathanism/python-git-orm
 def load_module(self, fullname):
     with transaction.wrap():
         code = self.get_code(fullname)
         is_pkg = self.is_package(fullname)
     is_reload = fullname in sys.modules
     mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
     mod.__file__ = code.co_filename
     mod.__loader__ = self
     if is_pkg:
         path = '/'.join(
             [PATH_PREFIX, self.path, fullname.rpartition('.')[2]])
         mod.__path__ = [path]
         mod.__package__ = fullname
     else:
         mod.__package__ = fullname.rpartition('.')[0]
     try:
         exec(code, mod.__dict__)
     except:
         if not is_reload:
             del sys.modules[fullname]
         raise
     return mod
コード例 #9
0
 def load_module(self, fullname):
     with transaction.wrap():
         code = self.get_code(fullname)
         is_pkg = self.is_package(fullname)
     is_reload = fullname in sys.modules
     mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
     mod.__file__ = code.co_filename
     mod.__loader__ = self
     if is_pkg:
         path = '/'.join(
             [PATH_PREFIX, self.path,
              fullname.rpartition('.')[2]])
         mod.__path__ = [path]
         mod.__package__ = fullname
     else:
         mod.__package__ = fullname.rpartition('.')[0]
     try:
         exec(code, mod.__dict__)
     except:
         if not is_reload:
             del sys.modules[fullname]
         raise
     return mod
コード例 #10
0
ファイル: importer.py プロジェクト: jathanism/python-git-orm
 def _inner(*args, **kwargs):
     try:
         with transaction.wrap():
             return fn(*args, **kwargs)
     except GitError:
         raise ImportError()
コード例 #11
0
 def test_exists_separate_transaction(self):
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         trans.add_message('dummy')
     with transaction.wrap() as trans:
         ok_(trans.exists(['foo']))
コード例 #12
0
 def test_current(self):
     assert_raises(GitError, transaction.current)
     with transaction.wrap():
         transaction.current()
     assert_raises(GitError, transaction.current)
コード例 #13
0
 def _foo():
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         self.assert_commit_count(0)
         raise TestException()
コード例 #14
0
 def test_nochanges(self):
     with transaction.wrap():
         pass
     self.assert_commit_count(0)
コード例 #15
0
 def test_nochanges(self):
     with transaction.wrap():
         pass
     self.assert_commit_count(0)
コード例 #16
0
 def _foo():
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         self.assert_commit_count(0)
         raise TestException()
コード例 #17
0
 def _foo():
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         raise TestException()
コード例 #18
0
 def test_list_blobs_separate_transaction(self):
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         trans.add_message('dummy')
     with transaction.wrap() as trans:
         eq_(trans.list_blobs([]), set(['foo']))
コード例 #19
0
 def _foo():
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         raise TestException()
コード例 #20
0
 def create_file(self, path, id_):
     with transaction.wrap() as trans:
         trans.set_blob(
             path.lstrip('/').split('/'),
             'ID = {!r}'.format(id_).encode('utf-8'))
         trans.add_message('create file {}'.format(path))
コード例 #21
0
 def _inner(*args, **kwargs):
     try:
         with transaction.wrap():
             return fn(*args, **kwargs)
     except GitError:
         raise ImportError()
コード例 #22
0
 def test_current(self):
     assert_raises(GitError, transaction.current)
     with transaction.wrap():
         transaction.current()
     assert_raises(GitError, transaction.current)
コード例 #23
0
 def test_list_blobs_separate_transaction(self):
     with transaction.wrap() as trans:
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         trans.add_message('dummy')
     with transaction.wrap() as trans:
         eq_(trans.list_blobs([]), set(['foo']))
コード例 #24
0
 def test_exists(self):
     with transaction.wrap() as trans:
         trans.add_message('dummy')
         trans.set_blob(['foo'], 'bar'.encode('utf-8'))
         ok_(trans.exists(['foo']))