Changeset 3052

Show
Ignore:
Timestamp:
01/14/08 00:45:37 (1 year ago)
Author:
coderanger
Message:

Moving to desktop.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • boxdbplugin/0.11/boxdb/api.py

    r2987 r3052  
    77 
    88from boxdb import db_default 
     9from boxdb.compat import simplejson 
    910 
    1011class IDocumentPropertyRenderer(Interface): 
     
    3031            for name in renderer.get_properties(): 
    3132                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 
    3246 
    3347    # IEnvironmentSetupParticipant methods 
  • boxdbplugin/0.11/boxdb/model.py

    r2987 r3052  
    66from trac.util.compat import set 
    77 
    8 try: 
    9     import simplejson 
    10 except ImportError: 
    11     import _simplejson as simplejson 
    12  
    138from boxdb.api import BoxDBSystem 
     9from boxdb.compat import simplejson 
    1410 
    1511class Document(dict): 
     
    5046        if type: 
    5147            # Fetch and decode collection 
    52             type = simplejson.loads(type[0]
     48            type = simplejson.loads(type
    5349            if type == self.name: 
    5450                raise ValueError('Document cannot be its own type') 
     
    5854            inherit = self._get_db(cursor, name, '__inherit__') 
    5955            if inherit: 
    60                 inherit = simplejson.loads(inherit[0]
     56                inherit = simplejson.loads(inherit
    6157                self._fetch(inherit, db) 
    6258             
     
    7066        cursor.execute('SELECT value FROM boxdb WHERE name=%s AND key=%s', 
    7167                       (name, key)) 
    72         return cursor.fetchone() 
     68        val = cursor.fetchone() 
     69        if val is None: 
     70            return val 
     71        else: 
     72            return val[0] 
    7373 
    7474    def save(self, db=None):