Changeset 3161

Show
Ignore:
Timestamp:
01/30/08 07:47:35 (10 months ago)
Author:
Blackhex
Message:
  • Component and version filtering.
  • Full support for DB update.
  • Support for TagsPlugin.
  • Script for DB entries clearance adde.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • screenshotsplugin/0.10/tracscreenshots/api.py

    r2659 r3161  
    7373        columns = ('id', 'name', 'description', 'time', 'author', 'tags', 
    7474          'file', 'width', 'height') 
     75        versions_str = (', '.join(['%s'] * len(versions))) or 'NULL' 
     76        components_str = (', '.join(['%s'] * len(components))) or 'NULL' 
    7577        sql = 'SELECT DISTINCT ' + ', '.join(columns) + ' FROM screenshot s ' \ 
    7678          'LEFT JOIN (SELECT screenshot, version FROM screenshot_version) v ' \ 
    7779          'ON s.id = v.screenshot LEFT JOIN (SELECT screenshot, component ' \ 
    7880          'FROM screenshot_component) c ON s.id = c.screenshot WHERE ' \ 
    79           'v.version IN (' + ', '.join(['%s'] * len(versions)) + ')' + \ 
    80           (('none' in versions) and ' OR v.version IS NULL' or '') + \ 
    81           ' OR c.component IN (' + ', '.join(['%s'] * len(components)) + \ 
    82           ')' + (('none' in components) and ' OR c.component IS NULL' or '') 
    83         self.log.debug(sql) 
     81          'v.version IN (' + versions_str + ')' + (('none' in versions) and \ 
     82          ' OR v.version IS NULL' or '') + ' OR c.component IN (' + \ 
     83          components_str + ')' + (('none' in components) and \ 
     84          ' OR c.component IS NULL' or '') 
    8485        self.log.debug(versions + components) 
    8586        self.log.debug(sql % tuple(versions + components)) 
  • screenshotsplugin/0.10/tracscreenshots/core.py

    r2659 r3161  
    11# -*- coding: utf8 -*- 
    22 
    3 import sets, re, os, os.path, time, mimetypes, Image 
     3import sets, re, os, os.path, time, mimetypes, unicodedata, Image 
    44 
    55from trac.core import * 
     
    3535    # Items for not specified component and version. 
    3636    none_component = {'name' : 'none', 
    37                   'description' : 'none'} 
     37                      'description' : 'none'} 
    3838    none_version = {'name' : 'none', 
    39                   'description' : 'none'} 
     39                    'description' : 'none'} 
    4040 
    4141    # Configuration options. 
     
    4646    ext = Option('screenshots', 'ext', 'jpg png', 
    4747      'List of screenshot file extensions that can be uploaded. Must be' 
    48       ' supported by ImageMagick.') 
     48      ' supported by PIL.') 
    4949    formats = Option('screenshots', 'formats', 'raw html jpg png', 
    5050      'List of allowed formats for screenshot download.') 
     
    269269 
    270270                # Prepare file paths 
    271                 path = os.path.join(self.path, unicode(screenshot['id'])) 
    272                 filename = os.path.join(path, '%s-%ix%i.%s' % (result.group(1), 
    273                   screenshot['width'], screenshot['height'], result.group(2))) 
    274                 filename = filename.encode('utf-8') 
     271                filename = os.path.join(self.path, unicode(screenshot['id']), 
     272                  '%s-%ix%i.%s' % (result.group(1), screenshot['width'], 
     273                  screenshot['height'], result.group(2))) 
     274                filename = unicodedata.normalize('NFC', filename) 
     275                filename = filename.replace('\\', '/').replace(':', '/') 
     276                path = os.path.dirname(filename) 
    275277                self.log.debug('filename: %s' % (filename,)) 
     278                self.log.debug('filename: %s' % (path,)) 
    276279 
    277280                # Store uploaded image. 
     
    283286                    try: 
    284287                        os.remove(filename) 
     288                    except: 
     289                        pass 
     290                    try: 
    285291                        os.rmdir(path) 
    286292                    except: 
    287293                        pass 
    288                     raise TracError('Error storing file. Is directory specified' \ 
    289                       ' in path config option in [screenshots] section of' \ 
    290                       ' trac.ini existing?') 
     294                    raise TracError('Error storing file. Is directory' \ 
     295                      ' specified in path config option in [screenshots]' \ 
     296                      ' section of trac.ini existing?') 
    291297 
    292298                # Notify change listeners. 
  • screenshotsplugin/0.11/tracscreenshots/api.py

    r3140 r3161  
    7474        columns = ('id', 'name', 'description', 'time', 'author', 'tags', 
    7575          'file', 'width', 'height') 
     76        versions_str = (', '.join(['%s'] * len(versions))) or 'NULL' 
     77        components_str = (', '.join(['%s'] * len(components))) or 'NULL' 
    7678        sql = 'SELECT DISTINCT ' + ', '.join(columns) + ' FROM screenshot s ' \ 
    7779          'LEFT JOIN (SELECT screenshot, version FROM screenshot_version) v ' \ 
    7880          'ON s.id = v.screenshot LEFT JOIN (SELECT screenshot, component ' \ 
    7981          'FROM screenshot_component) c ON s.id = c.screenshot WHERE ' \ 
    80           'v.version IN (' + ', '.join(['%s'] * len(versions)) + ')' + \ 
    81           (('none' in versions) and ' OR v.version IS NULL' or '') + \ 
    82           ' OR c.component IN (' + ', '.join(['%s'] * len(components)) + \ 
    83           ')' + (('none' in components) and ' OR c.component IS NULL' or '') 
    84         self.log.debug(sql) 
     82          'v.version IN (' + versions_str + ')' + (('none' in versions) and \ 
     83          ' OR v.version IS NULL' or '') + ' OR c.component IN (' + \ 
     84          components_str + ')' + (('none' in components) and \ 
     85          ' OR c.component IS NULL' or '') 
    8586        self.log.debug(versions + components) 
    8687        self.log.debug(sql % tuple(versions + components))