Changeset 1188
- Timestamp:
- 08/25/06 21:27:53 (2 years ago)
- Files:
-
- xmlrpcplugin/0.10/tracrpc/api.py (modified) (1 diff)
- xmlrpcplugin/0.10/tracrpc/ticket.py (modified) (3 diffs)
- xmlrpcplugin/0.10/tracrpc/util.py (added)
- xmlrpcplugin/0.10/tracrpc/wiki.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
xmlrpcplugin/0.10/tracrpc/api.py
r848 r1188 163 163 for provider in self.method_handlers: 164 164 for candidate in provider.xmlrpc_methods(): 165 self.env.log.debug(candidate) 165 166 p = Method(provider, *candidate) 166 167 if p.name == method: xmlrpcplugin/0.10/tracrpc/ticket.py
r1154 r1188 2 2 from trac.core import * 3 3 from tracrpc.api import IXMLRPCHandler, expose_rpc 4 from tracrpc.util import to_timestamp 4 5 import trac.ticket.model as model 5 6 import trac.ticket.query as query 7 from trac.ticket.api import TicketSystem 6 8 7 9 import pydoc … … 20 22 def xmlrpc_methods(self): 21 23 yield ('TICKET_VIEW', ((list,), (list, str)), self.query) 24 yield ('TICKET_VIEW', ((list, xmlrpclib.DateTime),), self.getRecentChanges) 25 yield ('TICKET_VIEW', ((list, int),), self.getAvailableActions) 22 26 yield ('TICKET_VIEW', ((list, int),), self.get) 23 27 yield ('TICKET_CREATE', ((int, str, str), (int, str, str, dict)), self.create) … … 41 45 out.append(t['id']) 42 46 return out 47 48 def getRecentChanges(self, req, since): 49 """Returns a list of IDs of tickets that have changed since timestamp.""" 50 since = to_timestamp(since) 51 db = self.env.get_db_cnx() 52 cursor = db.cursor() 53 cursor.execute('SELECT id FROM ticket' 54 ' WHERE changetime >= %s', (since,)) 55 result = [] 56 for row in cursor: 57 result.append(int(row[0])) 58 return result 59 60 def getAvailableActions(self, req, id): 61 """Returns the actions that can be performed on the ticket.""" 62 ticketSystem = TicketSystem(self.env) 63 t = model.Ticket(self.env, id) 64 return ticketSystem.get_available_actions(t, req.perm) 43 65 44 66 def get(self, req, id): xmlrpcplugin/0.10/tracrpc/wiki.py
r1161 r1188 13 13 from trac.attachment import Attachment 14 14 from tracrpc.api import IXMLRPCHandler, expose_rpc 15 from tracrpc.util import to_timestamp 15 16 16 17 class WikiRPC(Component): … … 38 39 yield ('WIKI_VIEW', ((list, str),), self.listAttachments) 39 40 yield ('WIKI_VIEW', ((xmlrpclib.Binary, str),), self.getAttachment) 40 yield ('WIKI_MODIFY', ((bool, str, str, xmlrpclib.Binary), 41 (str, str, str, xmlrpclib.Binary, bool)), self.putAttachment) 41 yield ('WIKI_MODIFY', ((bool, str, xmlrpclib.Binary),), self.putAttachment) 42 yield ('WIKI_MODIFY', ((bool, str, str, str, xmlrpclib.Binary), 43 (bool, str, str, str, xmlrpclib.Binary, bool)), 44 self.putAttachmentEx) 42 45 yield ('WIKI_DELETE', ((bool, str),), self.deleteAttachment) 43 46 yield ('WIKI_VIEW', ((list, str),), self.listLinks) 44 47 yield ('WIKI_VIEW', ((str, str),), self.wikiToHtml) 45 46 def _to_timestamp(self, datetime):47 import time48 return time.mktime(time.strptime(datetime.value, '%Y%m%dT%H:%M:%S'))49 48 50 49 def _page_info(self, name, time, author, version): … … 54 53 def getRecentChanges(self, req, since): 55 54 """ Get list of changed pages since timestamp """ 56 since = self._to_timestamp(since)55 since = to_timestamp(since) 57 56 db = self.env.get_db_cnx() 58 57 cursor = db.cursor() … … 126 125 return xmlrpclib.Binary(attachment.open().read()) 127 126 128 def putAttachment(self, req, path, data, replace=True): 129 """ (over)writes an attachment. For compatibility with WikiRPC, if 130 replace=True then the return type is a boolean, otherwise it is the 131 attachment filename. """ 127 def putAttachment(self, req, path, data): 128 """ (over)writes an attachment. Returns True if successful. 129 130 This method is compatible with WikiRPC. `putAttachmentEx` has a more 131 extensive set of (Trac-specific) features. """ 132 132 pagename, filename = posixpath.split(path) 133 self.putAttachmentEx(req, pagename, filename, None, data) 134 return True 135 136 def putAttachmentEx(self, req, pagename, filename, description, data, replace=True): 137 """ Attach a file to a Wiki page. Returns the (possibly transformed) 138 filename of the attachment. 139 140 Use this method if you don't care about WikiRPC compatibility. """ 133 141 if not WikiPage(self.env, pagename).exists: 134 142 raise TracError, 'Wiki page "%s" does not exist' % pagename … … 141 149 attachment = Attachment(self.env, 'wiki', pagename) 142 150 attachment.author = req.authname or 'anonymous' 151 attachment.description = description 143 152 attachment.insert(filename, StringIO(data.data), len(data.data)) 144 if replace: 145 return True 146 else: 147 return attachment.filename 153 return attachment.filename 148 154 149 155 def deleteAttachment(self, req, path):
