46 | | * Trac 10.x and 11.x source code must be manually modified for SEAT plugin to work. |
47 | | The file to modify is '''attachment.py''', on a Linux Fedora system, it is located in |
48 | | /usr/lib/python2.4/site-packages/trac[[BR]] |
49 | | '''Comment''': This is already done for Trac 0.11.4. |
50 | | {{{#!python |
51 | | 162 def insert(self, filename, fileobj, size, t=None, db=None): |
52 | | ... |
53 | | ... |
54 | | 184 try: |
55 | | 185 # Note: `path` is an unicode string because `self.path` was one. |
56 | | 186 # As it contains only quoted chars and numbers, we can use `ascii` |
57 | | 187 basename = os.path.basename(path).encode('ascii') |
58 | | 188 filename = unicode_unquote(basename) |
59 | | 189 |
60 | | 190 cursor = db.cursor() |
61 | | 191 cursor.execute("INSERT INTO attachment " |
62 | | 192 "VALUES (%s,%s,%s,%s,%s,%s,%s,%s)", |
63 | | 193 (self.parent_type, self.parent_id, filename, |
64 | | 194 self.size, self.time, self.description, self.author, |
65 | | 195 self.ipnr)) |
66 | | 196 shutil.copyfileobj(fileobj, targetfile) |
67 | | 197 self.filename = filename |
68 | | 198 |
69 | | 199 self.env.log.info('New attachment: %s by %s', self.title, |
70 | | 200 self.author) |
71 | | 201 |
72 | | 202 if handle_ta: |
73 | | 203 db.commit() |
74 | | 204 |
75 | | 205 targetfile.close() # << Line to add for SEAT plugin |
76 | | 206 |
77 | | 207 for listener in AttachmentModule(self.env).change_listeners: |
78 | | 208 listener.attachment_added(self) |
79 | | 209 finally: |
80 | | 210 targetfile.close() |
81 | | |
82 | | }}} |
83 | | |
84 | | |