class TicketDocument(BaseDocument):
    def __init__(self, app):
        BaseDocument.__init__(self, app)
        self.manager = TicketManager(self.app)

    def setID(self, clause=None, ids=None):
        self.clear_body()
        rows = self.manager.get_tickets(clause)
        for row in rows:
            element = TicketInfoElement(row.ticketid, row.title, row.author, row.created)
            self.body.appendChild(element)
class TicketInfoDoc(BaseDocument):
    def __init__(self, app):
        BaseDocument.__init__(self, app)
        self.manager = TicketManager(self. app)

    def set_clause(self, clause):
        self.clear_body()
        rows = self.db.select(fields=['title'], table='tickets')

    def setID(self, ticketid):
        row = self.manager.get_ticket(ticketid, data=True)
        self.current = ticketid
        self.clear_body()
        #make header
        self.body.appendChild(TitleTable(row.title))
        self.header = TicketHeader(ticketid, row)
        self.body.appendChild(self.header)
        hr = BaseElement('hr')
        self.body.appendChild(hr)
        #append ticket data
        tdata = TicketData(row.data)
        self.body.appendChild(tdata)
        hr = BaseElement('hr')
        self.body.appendChild(hr)
        #append ticket footer
        self.tfooter = TicketFooter(ticketid)
        self.body.appendChild(self.tfooter)
        actions, rows, trows, crows = self.manager.get_actions(ticketid, True)
        athreads = ActionThreads(self.body, actions, trows, crows)
        self.body.appendChild(athreads)
        self.threads = athreads

    def showActionData(self, actionid):
        data = self.manager.get_actiondata(self.current, actionid)
        self.threads.show_data(actionid, data)

    def hideActionData(self, actionid):
        self.threads.hide_data(actionid)
 def __init__(self, app):
     BaseDocument.__init__(self, app)
     self.manager = TicketManager(self. app)