Changeset 2609
- Timestamp:
- 09/03/07 04:30:23 (1 year ago)
- Files:
-
- xmlrpcplugin/trunk (copied) (copied from xmlrpcplugin/0.10)
- xmlrpcplugin/trunk/setup.py (modified) (1 diff)
- xmlrpcplugin/trunk/tracrpc/api.py (modified) (3 diffs)
- xmlrpcplugin/trunk/tracrpc/search.py (modified) (2 diffs)
- xmlrpcplugin/trunk/tracrpc/templates/xmlrpclist.cs (modified) (1 diff)
- xmlrpcplugin/trunk/tracrpc/ticket.py (modified) (5 diffs)
- xmlrpcplugin/trunk/tracrpc/util.py (modified) (1 diff)
- xmlrpcplugin/trunk/tracrpc/web_ui.py (modified) (4 diffs)
- xmlrpcplugin/trunk/tracrpc/wiki.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
xmlrpcplugin/trunk/setup.py
r1278 r2609 8 8 author='Alec Thomas', 9 9 author_email='alec@swapoff.org', 10 url='http://trac-hacks. swapoff.org/wiki/XmlRpcPlugin',10 url='http://trac-hacks.org/wiki/XmlRpcPlugin', 11 11 description='XML-RPC interface to Trac', 12 12 zip_safe=True, xmlrpcplugin/trunk/tracrpc/api.py
r1950 r2609 4 4 import types 5 5 import xmlrpclib 6 import datetime 7 from tracrpc.util import to_datetime 6 8 try: 7 9 set = set … … 88 90 result = 0 89 91 elif isinstance(result, dict): 90 pass 92 for key,val in result.iteritems(): 93 if isinstance(val, datetime.datetime): 94 result[key] = to_datetime(val) 95 #pass 91 96 elif not isinstance(result, basestring): 92 97 # Try and convert result to a list … … 225 230 indicate API breaking changes, while minor version changes are simple 226 231 additions, bug fixes, etc. """ 227 return [0, 2]232 return [0, 3] xmlrpcplugin/trunk/tracrpc/search.py
r1278 r2609 1 1 from trac.core import * 2 2 from tracrpc.api import IXMLRPCHandler 3 from trac.Search import ISearchSource 3 from tracrpc.util import to_datetime 4 from trac.search import ISearchSource 4 5 5 6 try: … … 47 48 48 49 results = [] 50 converters = [unicode, unicode, to_datetime, unicode, unicode] 49 51 for source in self.search_sources: 50 52 for result in source.get_search_results(req, query, filters): 51 result = map(unicode, result)53 result = [f(v) for f,v in zip(converters, result)] 52 54 results.append(['/'.join(req.base_url.split('/')[0:3]) 53 55 + result[0]] + list(result[1:])) xmlrpcplugin/trunk/tracrpc/templates/xmlrpclist.cs
r1519 r2609 1 <?cs include "header.cs"?> 2 <?cs include "macros.cs"?> 1 <!DOCTYPE html 2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml" 5 xmlns:py="http://genshi.edgewall.org/" 6 xmlns:xi="http://www.w3.org/2001/XInclude"> 7 <xi:include href="layout.html" /> 8 <xi:include href="macros.html" /> 9 <head> 10 <title>XML-RPC</title> 11 </head> 12 <body> 3 13 4 <div id="ctxtnav" class="nav"></div>14 <div id="ctxtnav" class="nav" /> 5 15 6 <div id="content" class="wiki">16 <div id="content" class="wiki"> 7 17 8 <h2>XML-RPC exported functions</h2>18 <h2>XML-RPC exported functions</h2> 9 19 10 <div id="searchable"> 11 <dl> 12 <?cs each:namespace = xmlrpc.functions ?> 20 <div id="searchable"> 21 <dl py:for="key in xmlrpc.functions" py:with="namespace = xmlrpc.functions[key]"> 22 <dt> 23 <h3 id="${'xmlrpc.' + to_unicode(namespace.namespace)}"> 24 ${namespace.namespace} - ${namespace.description} 25 </h3> 26 </dt> 27 <dd> 28 <table class="listing tickets"> 29 <thead> 30 <tr> 31 <th>Function</th> 32 <th>Description</th> 33 <th><nobr>Permission required</nobr></th> 34 </tr> 35 </thead> 36 <tbody py:for="idx, function in enumerate(namespace.methods)"> 37 <tr class="${'color3-' + (idx % 2 == 0 and 'even' or 'odd')}"> 38 <td><nobr>${function[0]}</nobr></td> 39 <td>${function[1]}</td> 40 <td>${function[2]}</td> 41 </tr> 42 </tbody> 43 </table> 44 </dd> 45 </dl> 46 </div> 13 47 14 <dt><h3 id=xmlrpc.<?cs var:namespace.namespace ?>><?cs var:namespace.namespace ?> - <?cs var:namespace.description ?></h3></dt> 15 <dd> 16 <table class="listing tickets"> 17 <thead> 18 <tr> 19 <th>Function</th> 20 <th>Description</th> 21 <th><nobr>Permission required</nobr></th> 22 </tr> 23 </thead> 48 <script type="text/javascript"> 49 addHeadingLinks(document.getElementById("searchable")); 50 </script> 51 </div> 24 52 25 <?cs set idx = #0 ?> 26 <tbody> 27 <?cs each:function = namespace.methods ?> 28 <tr class="color3-<?cs if idx % #2 == 0 ?>even<?cs else ?>odd<?cs /if ?>" style=""> 29 <td><nobr><?cs var:function.0?></nobr></td><td><?cs var:function.1?></td><td><?cs var:function.2 ?></td> 30 </tr> 31 <?cs set idx = idx + #1 ?> 32 <?cs /each ?> 33 </tbody> 34 </table> 35 </dd> 36 <?cs /each ?> 37 </dl> 38 </div> 39 40 <script type="text/javascript"> 41 addHeadingLinks(document.getElementById("searchable")); 42 </script> 43 44 </div> 45 46 <?cs include:"footer.cs"?> 53 </body> 54 </html> xmlrpcplugin/trunk/tracrpc/ticket.py
r1950 r2609 1 1 from trac.attachment import Attachment 2 2 from trac.core import * 3 from trac.perm import PermissionCache 3 4 from tracrpc.api import IXMLRPCHandler, expose_rpc 4 from tracrpc.util import to_timestamp 5 from tracrpc.util import to_timestamp, to_datetime 5 6 import trac.ticket.model as model 6 7 import trac.ticket.query as query … … 65 66 ticketSystem = TicketSystem(self.env) 66 67 t = model.Ticket(self.env, id) 67 return ticketSystem.get_available_actions( t, req.perm)68 return ticketSystem.get_available_actions(req, t) 68 69 69 70 def get(self, req, id): 70 71 """ Fetch a ticket. Returns [id, time_created, time_changed, attributes]. """ 71 72 t = model.Ticket(self.env, id) 72 return (t.id, t.time_created, t.time_changed, t.values) 73 return (t.id, to_datetime(t.time_created), 74 to_datetime(t.time_changed), t.values) 73 75 74 76 def create(self, req, summary, description, attributes = {}, notify=False): … … 119 121 def changeLog(self, req, id, when=0): 120 122 t = model.Ticket(self.env, id) 121 return t.get_changelog(when) 123 for date, author, field, old, new, permanent in t.get_changelog(when): 124 yield (to_datetime(date), author, field, old, new, permanent) 122 125 # Use existing documentation from Ticket model 123 126 changeLog.__doc__ = pydoc.getdoc(model.Ticket.get_changelog) … … 127 130 description, size, time, author) for each attachment.""" 128 131 for t in Attachment.select(self.env, 'ticket', ticket): 129 yield (t.filename, t.description or '', t.size, t.time, t.author) 132 yield (t.filename, t.description or '', t.size, 133 to_datetime(t.date), t.author) 130 134 131 135 def getAttachment(self, req, ticket, filename): … … 241 245 242 246 def get(self, req, name): 243 i = cls(self.env, name) 244 return i.value 247 if (cls.__name__ == 'Status'): 248 i = cls(self.env) 249 x = name 250 else: 251 i = cls(self.env, name) 252 x = i.value 253 return x 245 254 get.__doc__ = """ Get a ticket %s. """ % cls.__name__.lower() 246 255 xmlrpcplugin/trunk/tracrpc/util.py
r1735 r2609 1 1 import time 2 import xmlrpclib 2 3 3 4 def to_timestamp(datetime): 4 5 """ Convert xmlrpclib.DateTime string representation to UNIX timestamp. """ 5 6 return time.mktime(time.strptime('%s UTC' % datetime.value, '%Y%m%dT%H:%M:%S %Z')) - time.timezone 7 8 def to_datetime(dt): 9 """ Convert a datetime.datetime object to a xmlrpclib DateTime object """ 10 return xmlrpclib.DateTime(dt.utctimetuple()) xmlrpcplugin/trunk/tracrpc/web_ui.py
r1175 r2609 1 from pkg_resources import resource_filename 1 2 from trac.core import * 2 3 from trac.web.main import IRequestHandler … … 9 10 """ Handle XML-RPC calls from HTTP clients, as well as presenting a list of 10 11 methods available to the currently logged in user. Browsing to 11 <trac>/xmlrpc will display this list. """12 <trac>/xmlrpc or <trac>/login/xmlrpc will display this list. """ 12 13 13 14 implements(IRequestHandler, ITemplateProvider) … … 49 50 raise Exception('%s: %s\n%s' % (method.name, str(e), out.getvalue())) 50 51 add_stylesheet(req, 'common/css/wiki.css') 51 req.hdf['xmlrpc.functions'] = namespaces 52 return 'xmlrpclist.cs', None 52 return ('xmlrpclist.cs', {'xmlrpc': {'functions': namespaces}}, None) 53 53 54 54 # Handle XML-RPC call … … 74 74 75 75 def get_templates_dirs(self): 76 from pkg_resources import resource_filename77 76 return [resource_filename(__name__, 'templates')] xmlrpcplugin/trunk/tracrpc/wiki.py
r1735 r2609 5 5 import xmlrpclib 6 6 import posixpath 7 import time 7 8 8 9 from trac.core import * … … 13 14 from trac.attachment import Attachment 14 15 from tracrpc.api import IXMLRPCHandler, expose_rpc 15 from tracrpc.util import to_timestamp 16 from tracrpc.util import to_timestamp, to_datetime 16 17 17 18 class WikiRPC(Component): … … 93 94 if page.exists: 94 95 last_update = page.get_history().next() 95 return self._page_info(page.name, last_update[1], last_update[2], 96 page.version) 96 return self._page_info(page.name, 97 time.mktime(last_update[1].utctimetuple()), 98 last_update[2], page.version) 97 99 98 100 def putPage(self, req, pagename, content, attributes):
