|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -#$Id: back_anydbm.py,v 1.134 2003-12-10 01:40:51 richard Exp $ |
19 | | -''' |
20 | | -This module defines a backend that saves the hyperdatabase in a database |
21 | | -chosen by anydbm. It is guaranteed to always be available in python |
| 18 | +#$Id: back_anydbm.py,v 1.135 2004-02-11 23:55:08 richard Exp $ |
| 19 | +'''This module defines a backend that saves the hyperdatabase in a |
| 20 | +database chosen by anydbm. It is guaranteed to always be available in python |
22 | 21 | versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several |
23 | 22 | serious bugs, and is not available) |
24 | 23 | ''' |
| 24 | +__docformat__ = 'restructuredtext' |
25 | 25 |
|
26 | 26 | try: |
27 | 27 | import anydbm, sys |
@@ -50,10 +50,10 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): |
50 | 50 | '''A database for storing records containing flexible data types. |
51 | 51 |
|
52 | 52 | Transaction stuff TODO: |
53 | | - . check the timestamp of the class file and nuke the cache if it's |
54 | | - modified. Do some sort of conflict checking on the dirty stuff. |
55 | | - . perhaps detect write collisions (related to above)? |
56 | | -
|
| 53 | + |
| 54 | + - check the timestamp of the class file and nuke the cache if it's |
| 55 | + modified. Do some sort of conflict checking on the dirty stuff. |
| 56 | + - perhaps detect write collisions (related to above)? |
57 | 57 | ''' |
58 | 58 | def __init__(self, config, journaltag=None): |
59 | 59 | '''Open a hyperdatabase given a specifier to some storage. |
@@ -92,14 +92,15 @@ def __init__(self, config, journaltag=None): |
92 | 92 | self.lockfile.flush() |
93 | 93 |
|
94 | 94 | def post_init(self): |
95 | | - ''' Called once the schema initialisation has finished. |
| 95 | + '''Called once the schema initialisation has finished. |
96 | 96 | ''' |
97 | 97 | # reindex the db if necessary |
98 | 98 | if self.indexer.should_reindex(): |
99 | 99 | self.reindex() |
100 | 100 |
|
101 | 101 | def refresh_database(self): |
102 | | - "Rebuild the database" |
| 102 | + """Rebuild the database |
| 103 | + """ |
103 | 104 | self.reindex() |
104 | 105 |
|
105 | 106 | def reindex(self): |
@@ -1366,8 +1367,11 @@ def destroy(self, nodeid): |
1366 | 1367 | WARNING: this method should never be used except in extremely rare |
1367 | 1368 | situations where there could never be links to the node being |
1368 | 1369 | deleted |
| 1370 | +
|
1369 | 1371 | WARNING: use retire() instead |
| 1372 | +
|
1370 | 1373 | WARNING: the properties of this node will not be available ever again |
| 1374 | +
|
1371 | 1375 | WARNING: really, use retire() instead |
1372 | 1376 |
|
1373 | 1377 | Well, I think that's enough warnings. This method exists mostly to |
@@ -1418,14 +1422,15 @@ def getkey(self): |
1418 | 1422 | return self.key |
1419 | 1423 |
|
1420 | 1424 | def labelprop(self, default_to_id=0): |
1421 | | - ''' Return the property name for a label for the given node. |
| 1425 | + '''Return the property name for a label for the given node. |
1422 | 1426 |
|
1423 | 1427 | This method attempts to generate a consistent label for the node. |
1424 | 1428 | It tries the following in order: |
1425 | | - 1. key property |
1426 | | - 2. "name" property |
1427 | | - 3. "title" property |
1428 | | - 4. first property from the sorted property name list |
| 1429 | +
|
| 1430 | + 1. key property |
| 1431 | + 2. "name" property |
| 1432 | + 3. "title" property |
| 1433 | + 4. first property from the sorted property name list |
1429 | 1434 | ''' |
1430 | 1435 | k = self.getkey() |
1431 | 1436 | if k: |
@@ -1597,21 +1602,23 @@ def getnodeids(self, db=None): |
1597 | 1602 |
|
1598 | 1603 | def filter(self, search_matches, filterspec, sort=(None,None), |
1599 | 1604 | group=(None,None), num_re = re.compile('^\d+$')): |
1600 | | - ''' Return a list of the ids of the active nodes in this class that |
1601 | | - match the 'filter' spec, sorted by the group spec and then the |
1602 | | - sort spec. |
1603 | | -
|
1604 | | - "filterspec" is {propname: value(s)} |
1605 | | - "sort" and "group" are (dir, prop) where dir is '+', '-' or None |
1606 | | - and prop is a prop name or None |
1607 | | - "search_matches" is {nodeid: marker} |
1608 | | -
|
1609 | | - The filter must match all properties specificed - but if the |
1610 | | - property value to match is a list, any one of the values in the |
1611 | | - list may match for that property to match. Unless the property |
1612 | | - is a Multilink, in which case the item's property list must |
1613 | | - match the filterspec list. |
1614 | | - ''' |
| 1605 | + """Return a list of the ids of the active nodes in this class that |
| 1606 | + match the 'filter' spec, sorted by the group spec and then the |
| 1607 | + sort spec. |
| 1608 | +
|
| 1609 | + "filterspec" is {propname: value(s)} |
| 1610 | +
|
| 1611 | + "sort" and "group" are (dir, prop) where dir is '+', '-' or None |
| 1612 | + and prop is a prop name or None |
| 1613 | +
|
| 1614 | + "search_matches" is {nodeid: marker} |
| 1615 | +
|
| 1616 | + The filter must match all properties specificed - but if the |
| 1617 | + property value to match is a list, any one of the values in the |
| 1618 | + list may match for that property to match. Unless the property |
| 1619 | + is a Multilink, in which case the item's property list must |
| 1620 | + match the filterspec list. |
| 1621 | + """ |
1615 | 1622 | cn = self.classname |
1616 | 1623 |
|
1617 | 1624 | # optimise filterspec |
|
0 commit comments