zodb warnings removed

--HG--
branch : sandbox
This commit is contained in:
baloan
2014-12-09 21:43:29 +01:00
parent 2359d9251d
commit a6010663ac
2 changed files with 36 additions and 23 deletions

View File

@@ -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 TNG - 1x01-2 - Encounter At Farpoint - DVDRip-AMC.divx.avi
def main(argv=None):
if argv == None:
if argv is None:
argv = sys.argv
LOG.info("starting [%s]" % (argv[0],))
try:
@@ -42,7 +43,7 @@ def main(argv = None):
# tng = r"c:\Dokumente\Eigene Videos\Shaun the Sheep"
tng = "."
# os.chdir(tng)
for (dirpath, dirnames, filenames) in os.walk(tng):
for (_, _, filenames) in os.walk(tng):
for f in filenames:
mot = re.match(p, f)
if mot is not None:

View File

@@ -1,9 +1,14 @@
#! /usr/bin/env python2
#!/usr/bin/env python
# -*- 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
@@ -14,6 +19,7 @@ import transaction
# Persistent objects
class Account(Persistent):
def __init__(self):
self.balance = 0.0
@@ -27,29 +33,35 @@ class Account(Persistent):
# Configuration
storage = FileStorage(r"e:\workspaces\zodb3\data.zodb")
storage = FileStorage(r"e:\workspaces\zodb3\tutorial.zodb")
db = DB(storage)
connection = db.open()
root = connection.root()
ctx = db.open()
root = ctx.root()
print root.keys()
print(root.keys())
# Storing objects
root['account-1'] = Account()
if "account-2" not in root:
root['account-2'] = Account()
a = b = 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
root['account-2'].deposit(5)
transaction.commit()
print root.keys()
print(root.keys())
del root['account-1']
print root.keys()
print(root.keys())
# ['account-2']
transaction.abort()
print root.keys()
print(root.keys())
# ['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)))