zodb warnings removed
--HG-- branch : sandbox
This commit is contained in:
@@ -26,8 +26,9 @@ class Error(Exception):
|
|||||||
# Star.Trek.The.Next.Generation.1x01-02.Encounter.At.Farpoint.DVDRip-AMC.[tvu.org.ru].avi
|
# Star.Trek.The.Next.Generation.1x01-02.Encounter.At.Farpoint.DVDRip-AMC.[tvu.org.ru].avi
|
||||||
# Star Trek TNG - 1x01-2 - Encounter At Farpoint - DVDRip-AMC.divx.avi
|
# Star Trek TNG - 1x01-2 - Encounter At Farpoint - DVDRip-AMC.divx.avi
|
||||||
|
|
||||||
def main(argv = None):
|
|
||||||
if argv == None:
|
def main(argv=None):
|
||||||
|
if argv is None:
|
||||||
argv = sys.argv
|
argv = sys.argv
|
||||||
LOG.info("starting [%s]" % (argv[0],))
|
LOG.info("starting [%s]" % (argv[0],))
|
||||||
try:
|
try:
|
||||||
@@ -42,7 +43,7 @@ def main(argv = None):
|
|||||||
# tng = r"c:\Dokumente\Eigene Videos\Shaun the Sheep"
|
# tng = r"c:\Dokumente\Eigene Videos\Shaun the Sheep"
|
||||||
tng = "."
|
tng = "."
|
||||||
# os.chdir(tng)
|
# os.chdir(tng)
|
||||||
for (dirpath, dirnames, filenames) in os.walk(tng):
|
for (_, _, filenames) in os.walk(tng):
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
mot = re.match(p, f)
|
mot = re.match(p, f)
|
||||||
if mot is not None:
|
if mot is not None:
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
#! /usr/bin/env python2
|
#!/usr/bin/env python
|
||||||
# -*- coding: cp1252 -*-
|
# -*- coding: cp1252 -*-
|
||||||
|
# Copyright (c) 2014 Andreas
|
||||||
|
# See LICENSE for details.
|
||||||
|
|
||||||
# ZODB Tutorial
|
""" tutorial """
|
||||||
|
|
||||||
""" zodb.tutorial """
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
|
|
||||||
@@ -14,6 +19,7 @@ import transaction
|
|||||||
|
|
||||||
# Persistent objects
|
# Persistent objects
|
||||||
|
|
||||||
|
|
||||||
class Account(Persistent):
|
class Account(Persistent):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.balance = 0.0
|
self.balance = 0.0
|
||||||
@@ -27,29 +33,35 @@ class Account(Persistent):
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
storage = FileStorage(r"e:\workspaces\zodb3\data.zodb")
|
storage = FileStorage(r"e:\workspaces\zodb3\tutorial.zodb")
|
||||||
db = DB(storage)
|
db = DB(storage)
|
||||||
connection = db.open()
|
ctx = db.open()
|
||||||
root = connection.root()
|
root = ctx.root()
|
||||||
|
|
||||||
print root.keys()
|
print(root.keys())
|
||||||
|
|
||||||
# Storing objects
|
# Storing objects
|
||||||
|
|
||||||
root['account-1'] = Account()
|
a = b = Account()
|
||||||
if "account-2" not in root:
|
|
||||||
root['account-2'] = Account()
|
|
||||||
|
|
||||||
|
root['account-1'] = a
|
||||||
|
if "account-2" not in root:
|
||||||
|
root['account-2'] = b
|
||||||
|
|
||||||
|
print("id(a): {}, id(b): {}".format(id(a), id(b)))
|
||||||
# Transactions
|
# Transactions
|
||||||
root['account-2'].deposit(5)
|
root['account-2'].deposit(5)
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
print root.keys()
|
print(root.keys())
|
||||||
|
|
||||||
del root['account-1']
|
del root['account-1']
|
||||||
print root.keys()
|
print(root.keys())
|
||||||
# ['account-2']
|
# ['account-2']
|
||||||
transaction.abort()
|
transaction.abort()
|
||||||
print root.keys()
|
print(root.keys())
|
||||||
# ['account-1', 'account-2']
|
# ['account-1', 'account-2']
|
||||||
|
|
||||||
print root['account-2'].balance
|
print(root['account-2'].balance)
|
||||||
|
a = root['account-1']
|
||||||
|
b = root['account-2']
|
||||||
|
print("id(a): {}, id(b): {}".format(id(a), id(b)))
|
||||||
|
|||||||
Reference in New Issue
Block a user