Ticket #1075: xmlrpc-11.3-genshi.2.diff
| File xmlrpc-11.3-genshi.2.diff, 11.4 kB (added by mmay, 10 months ago) |
|---|
-
0.10/setup.py
old new 7 7 version='0.1', 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, 13 13 packages=['tracrpc'], -
0.10/tracrpc/api.py
old new 3 3 import inspect 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 8 10 except: … … 87 89 if result is None: 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 93 98 try: … … 224 229 version number, second is the minor. Changes to the major version 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] -
0.10/tracrpc/web_ui.py
old new 1 from pkg_resources import resource_filename 1 2 from trac.core import * 2 3 from trac.web.main import IRequestHandler 3 4 from trac.web.chrome import ITemplateProvider, add_stylesheet … … 8 9 class XMLRPCWeb(Component): 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) 14 15 … … 48 49 traceback.print_exc(file=out) 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 55 55 args, method = xmlrpclib.loads(req.read(int(req.get_header('Content-Length')))) … … 73 73 return [] 74 74 75 75 def get_templates_dirs(self): 76 from pkg_resources import resource_filename77 76 return [resource_filename(__name__, 'templates')] -
0.10/tracrpc/util.py
old new 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()) -
0.10/tracrpc/ticket.py
old new 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 7 8 from trac.ticket.api import TicketSystem … … 64 65 """Returns the actions that can be performed on the ticket.""" 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): 75 77 """ Create a new ticket, returning the ticket ID. """ … … 118 120 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) 124 127 … … 126 129 """ Lists attachments for a given ticket. Returns (filename, 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): 132 136 """ returns the content of an attachment. """ … … 240 244 getAll.__doc__ = """ Get a list of all ticket %s names. """ % cls.__name__.lower() 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 247 256 def delete(self, req, name): -
0.10/tracrpc/wiki.py
old new 4 4 from StringIO import StringIO 5 5 import xmlrpclib 6 6 import posixpath 7 import time 7 8 8 9 from trac.core import * 9 10 from trac.perm import IPermissionRequestor … … 12 13 from trac.wiki.formatter import wiki_to_html 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): 18 19 """ Implementation of the [http://www.jspwiki.org/Wiki.jsp?page=WikiRPCInterface2 WikiRPC API]. """ … … 92 93 page = WikiPage(self.env, pagename, version) 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): 99 101 """ writes the content of the page. """ -
0.10/tracrpc/search.py
old new 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: 6 7 a = set() … … 46 47 self.env.log.debug("Searching with %s" % filters) 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:])) 54 56 return results -
0.10/tracrpc/templates/xmlrpclist.cs
old new 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>
