Software Freedom Law Center

Changeset 446

Show
Ignore:
Timestamp:
11/25/07 22:46:03 (1 year ago)
Author:
bkuhn
Message:

r3428@hughes: bkuhn | 2007-11-25 22:43:14 -0500

  • Began conversion of Wiki system in Trac to use new storage engine.
    The first step is to convert over the database storage to use the new
    interface. Then, I can give a try to create an SVN one.


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/patch-devel/trac/trac/wiki/api.py

    r437 r446  
    129129        For public sites where anonymous users can edit the wiki it is 
    130130        recommended to leave this option disabled (which is the default).""") 
     131 
     132    storage_mechanism = Option('wiki', 'storage_mechanism', 'db', 
     133        """Storage Mechanism to use for Wiki system 
     134        (choices are: `db` or `svn:/path/to/repository` 
     135        (''since 0.11'')""") 
    131136 
    132137    def __init__(self): 
     
    138143        self._helper_patterns = None 
    139144        self._external_handlers = None 
     145        self._storage = WikiStorage(self.storage_mechanism) 
    140146 
    141147    def _update_index(self): 
     
    145151            if now > self._last_index_update + WikiSystem.INDEX_UPDATE_INTERVAL: 
    146152                self.log.debug('Updating wiki page index') 
    147                 db = self.env.get_db_cnx() 
    148                 cursor = db.cursor() 
    149                 cursor.execute("SELECT DISTINCT name FROM wiki") 
    150153                self._index = {} 
    151                 for (name,) in cursor
     154                for name in self._storage.get_page_list
    152155                    self._index[name] = True 
    153156                self._last_index_update = now 
  • branches/patch-devel/trac/trac/wiki/macros.py

    r437 r446  
    9696                    limit = int(argv[1]) 
    9797 
    98         db = self.env.get_db_cnx() 
    99         cursor = db.cursor() 
    100  
    101         sql = 'SELECT name, ' \ 
    102               '  max(version) AS max_version, ' \ 
    103               '  max(time) AS max_time ' \ 
    104               'FROM wiki' 
    105         args = [] 
    106         if prefix: 
    107             sql += ' WHERE name LIKE %s' 
    108             args.append(prefix + '%') 
    109         sql += ' GROUP BY name ORDER BY max_time DESC' 
    110         if limit: 
    111             sql += ' LIMIT %s' 
    112             args.append(limit) 
    113         cursor.execute(sql, args) 
    114  
    11598        entries_per_date = [] 
    11699        prevdate = None 
    117         for name, version, time in cursor: 
     100        pages = self._storage.get_pages_by_prefix_mod_time_desc(prefix, limit) 
     101        for name, version, time in pages: 
    118102            date = format_date(time) 
    119103            if date != prevdate: 
  • branches/patch-devel/trac/trac/wiki/model.py

    r437 r446  
    3939 
    4040    def _fetch(self, name, version=None, db=None): 
    41         if not db: 
    42             db = self.env.get_db_cnx() 
    43         cursor = db.cursor() 
    44         if version: 
    45             cursor.execute("SELECT version,time,author,text,comment,readonly " 
    46                            "FROM wiki " 
    47                            "WHERE name=%s AND version=%s", 
    48                            (name, int(version))) 
    49         else: 
    50             cursor.execute("SELECT version,time,author,text,comment,readonly " 
    51                            "FROM wiki " 
    52                            "WHERE name=%s ORDER BY version DESC LIMIT 1", 
    53                            (name,)) 
    54         row = cursor.fetchone() 
    55         if row: 
    56             version,time,author,text,comment,readonly = row 
    57             self.version = int(version) 
    58             self.author = author 
    59             self.time = time 
    60             self.text = text 
    61             self.comment = comment 
    62             self.readonly = readonly and int(readonly) or 0 
    63         else: 
    64             self.version = 0 
    65             self.text = self.comment = self.author = '' 
    66             self.time = self.readonly = 0 
     41        (self.version, self.author, self.time, self.text, self.comment, \ 
     42             self.readonly) = self._storage.fetch_page(name, version) 
    6743 
    6844    exists = property(fget=lambda self: self.version > 0) 

SFLC Main Page

[frdm] Support SFLC