Changeset 3052 for boxdbplugin
- Timestamp:
- 01/14/08 00:45:37 (10 months ago)
- Files:
-
- boxdbplugin/0.11/boxdb/api.py (modified) (2 diffs)
- boxdbplugin/0.11/boxdb/compat.py (added)
- boxdbplugin/0.11/boxdb/model.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
boxdbplugin/0.11/boxdb/api.py
r2987 r3052 7 7 8 8 from boxdb import db_default 9 from boxdb.compat import simplejson 9 10 10 11 class IDocumentPropertyRenderer(Interface): … … 30 31 for name in renderer.get_properties(): 31 32 self.renderers_map[name] = renderer 33 34 # Public methods 35 def get_documents(self, type=None, db=None): 36 db = db or self.env.get_db_cnx() 37 cursor = db.cursor() 38 39 if type is None: 40 cursor.execute('SELECT DISTINCT name FROM boxdb') 41 else: 42 cursor.execute('SELECT DISTINCT name FROM boxdb WHERE ') 43 44 for document, in cursor: 45 yield document 32 46 33 47 # IEnvironmentSetupParticipant methods boxdbplugin/0.11/boxdb/model.py
r2987 r3052 6 6 from trac.util.compat import set 7 7 8 try:9 import simplejson10 except ImportError:11 import _simplejson as simplejson12 13 8 from boxdb.api import BoxDBSystem 9 from boxdb.compat import simplejson 14 10 15 11 class Document(dict): … … 50 46 if type: 51 47 # Fetch and decode collection 52 type = simplejson.loads(type [0])48 type = simplejson.loads(type) 53 49 if type == self.name: 54 50 raise ValueError('Document cannot be its own type') … … 58 54 inherit = self._get_db(cursor, name, '__inherit__') 59 55 if inherit: 60 inherit = simplejson.loads(inherit [0])56 inherit = simplejson.loads(inherit) 61 57 self._fetch(inherit, db) 62 58 … … 70 66 cursor.execute('SELECT value FROM boxdb WHERE name=%s AND key=%s', 71 67 (name, key)) 72 return cursor.fetchone() 68 val = cursor.fetchone() 69 if val is None: 70 return val 71 else: 72 return val[0] 73 73 74 74 def save(self, db=None):
