def __init__(self): self.dispatcher = TracXMLRPCRequestHandler({ 'ircannouncer.getTicket': self.get_ticket, 'ircannouncer.getChangeset': self.get_changeset, 'ircannouncer.getWikiPage': self.get_wiki_page })
class BotService(Component): implements(IRequestHandler) def __init__(self): self.dispatcher = TracXMLRPCRequestHandler({ 'ircannouncer.getTicket': self.get_ticket, 'ircannouncer.getChangeset': self.get_changeset, 'ircannouncer.getWikiPage': self.get_wiki_page }) # -- RPC methods def get_ticket(self, req, ticket_id): try: ticket = Ticket(self.env, ticket_id) except ResourceNotFound: raise NotFound() return prepare_ticket_values(ticket) def get_changeset(self, req, ident): repo = self.env.get_repository() repo.sync() try: chgset = repo.get_changeset(ident) except NoSuchChangeset: raise NotFound() return prepare_changeset_values(self.env, chgset) def get_wiki_page(self, req, page_name): page = WikiPage(self.env, page_name) if not page.exists: raise NotFound() return prepare_wiki_page_values(page) # -- IRequestHandler methods def match_request(self, req): return req.path_info == '/ircannouncer_service' def process_request(self, req): self.dispatcher.dispatch(req)