Ticket #1075: xmlrpc-datetime.patch
| File xmlrpc-datetime.patch, 5.7 kB (added by eblot, 1 year ago) |
|---|
-
0.10/tracrpc/api.py
old new 224 224 version number, second is the minor. Changes to the major version 225 225 indicate API breaking changes, while minor version changes are simple 226 226 additions, bug fixes, etc. """ 227 return [0, 2]227 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 … … 73 74 return [] 74 75 75 76 def get_templates_dirs(self): 76 from pkg_resources import resource_filename77 77 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 3 from tracrpc.api import IXMLRPCHandler, expose_rpc 4 from tracrpc.util import to_timestamp 4 from tracrpc.util import to_timestamp, to_datetime 5 5 import trac.ticket.model as model 6 6 import trac.ticket.query as query 7 7 from trac.ticket.api import TicketSystem … … 42 42 # Exported methods 43 43 def query(self, req, qstr='status!=closed'): 44 44 """ Perform a ticket query, returning a list of ticket ID's. """ 45 q = query.Query.from_string(self.env, qstr)45 q = query.Query.from_string(self.env, req, qstr) 46 46 out = [] 47 47 for t in q.execute(req): 48 48 out.append(t['id']) … … 69 69 def get(self, req, id): 70 70 """ Fetch a ticket. Returns [id, time_created, time_changed, attributes]. """ 71 71 t = model.Ticket(self.env, id) 72 return (t.id, t.time_created, t.time_changed, t.values) 72 return (t.id, to_datetime(t.time_created), 73 to_datetime(t.time_changed), t.values) 73 74 74 75 def create(self, req, summary, description, attributes = {}, notify=False): 75 76 """ Create a new ticket, returning the ticket ID. """ … … 126 127 """ Lists attachments for a given ticket. Returns (filename, 127 128 description, size, time, author) for each attachment.""" 128 129 for t in Attachment.select(self.env, 'ticket', ticket): 129 yield (t.filename, t.description or '', t.size, t.time, t.author) 130 yield (t.filename, t.description or '', t.size, 131 to_datetime(t.date), t.author) 130 132 131 133 def getAttachment(self, req, ticket, filename): 132 134 """ returns the content of an attachment. """ -
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
