Skip to content

Commit f721476

Browse files
author
Alexander Smishlajev
committed
Database instances must have method close()
trim trailing spaces, fix vim modeline
1 parent 1e1f65f commit f721476

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

roundup/hyperdb.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17-
#
18-
# $Id: hyperdb.py,v 1.105 2004-11-12 04:07:03 richard Exp $
17+
#
18+
# $Id: hyperdb.py,v 1.106 2004-11-13 07:11:14 a1s Exp $
1919

2020
"""Hyperdatabase implementation, especially field types.
2121
"""
@@ -163,7 +163,7 @@ def __init__(self, config, journaltag=None):
163163
raise NotImplementedError
164164

165165
def post_init(self):
166-
"""Called once the schema initialisation has finished.
166+
"""Called once the schema initialisation has finished.
167167
If 'refresh' is true, we want to rebuild the backend
168168
structures.
169169
"""
@@ -245,7 +245,7 @@ def countnodes(self, classname):
245245

246246
def storefile(self, classname, nodeid, property, content):
247247
'''Store the content of the file in the database.
248-
248+
249249
The property may be None, in which case the filename does not
250250
indicate which property is being saved.
251251
'''
@@ -292,12 +292,19 @@ def rollback(self):
292292
'''
293293
raise NotImplementedError
294294

295+
def close(self):
296+
"""Close the database.
297+
298+
This method must be called at the end of processing.
299+
300+
"""
301+
295302
#
296303
# The base Class class
297304
#
298305
class Class:
299306
""" The handle to a particular class of nodes in a hyperdatabase.
300-
307+
301308
All methods except __repr__ and getnode must be implemented by a
302309
concrete backend Class.
303310
"""
@@ -325,13 +332,13 @@ def create(self, **propvalues):
325332
326333
The values of arguments must be acceptable for the types of their
327334
corresponding properties or a TypeError is raised.
328-
335+
329336
If this class has a key property, it must be present and its value
330337
must not collide with other key strings or a ValueError is raised.
331-
338+
332339
Any other properties on this class that are missing from the
333340
'propvalues' dictionary are set to None.
334-
341+
335342
If an id in a link or multilink property does not refer to a valid
336343
node, an IndexError is raised.
337344
"""
@@ -367,7 +374,7 @@ def getnodeids(self, retired=None):
367374

368375
def set(self, nodeid, **propvalues):
369376
"""Modify a property on an existing node of this class.
370-
377+
371378
'nodeid' must be the id of an existing node of this class or an
372379
IndexError is raised.
373380
@@ -387,10 +394,10 @@ class or a KeyError is raised.
387394

388395
def retire(self, nodeid):
389396
"""Retire a node.
390-
397+
391398
The properties on the node remain available from the get() method,
392399
and the node's id is never reused.
393-
400+
394401
Retired nodes are not returned by the find(), list(), or lookup()
395402
methods, and other nodes may reuse the values of their key properties.
396403
"""
@@ -402,15 +409,15 @@ def restore(self, nodeid):
402409
Make node available for all operations like it was before retirement.
403410
'''
404411
raise NotImplementedError
405-
412+
406413
def is_retired(self, nodeid):
407414
'''Return true if the node is rerired
408415
'''
409416
raise NotImplementedError
410417

411418
def destroy(self, nodeid):
412419
"""Destroy a node.
413-
420+
414421
WARNING: this method should never be used except in extremely rare
415422
situations where there could never be links to the node being
416423
deleted
@@ -489,7 +496,7 @@ def lookup(self, keyvalue):
489496
def find(self, **propspec):
490497
"""Get the ids of nodes in this class which link to the given nodes.
491498
492-
'propspec' consists of keyword args propname={nodeid:1,}
499+
'propspec' consists of keyword args propname={nodeid:1,}
493500
'propname' must be the name of a property in this class, or a
494501
KeyError is raised. That property must be a Link or Multilink
495502
property, or a TypeError is raised.
@@ -782,7 +789,7 @@ def items(self, protected=1):
782789
return l
783790
def has_key(self, name):
784791
return self.cl.getprops().has_key(name)
785-
def get(self, name, default=None):
792+
def get(self, name, default=None):
786793
if self.has_key(name):
787794
return self[name]
788795
else:
@@ -821,4 +828,4 @@ def Choice(name, db, *options):
821828
cl.create(name=options[i], order=i)
822829
return hyperdb.Link(name)
823830

824-
# vim: set filetype=python ts=4 sw=4 et si
831+
# vim: set filetype=python sts=4 sw=4 et si :

0 commit comments

Comments
 (0)