def _make_row(self, label, cell, **kw): """ Create a row in the form table. """ self._table.append(html.TR().extend([ html.TD(**kw).extend([html.B().append(label), ' ']), html.TD().extend(cell), ]))
def create_form(self, create_only=False, recover_only=False): r = self.request ss = self.cfg.session_service format_time = lambda x: self.request.user.getFormattedDateTime( x) if x else x form = self.make_form(html.Text("Active sessions for your account")) ticket = wikiutil.createTicket(self.request) form.append( html.INPUT(type="hidden", name="ticket", value="%s" % ticket)) self._table.append(html.TR().extend([ html.TD().extend([""]), html.TD().extend([html.B().append("From IP")]), html.TD().extend([html.B().append("Login Date")]), html.TD().extend([html.B().append("Expiration")]), html.TD().extend([html.B().append("User Agent")]), ])) for sid in ss.get_all_session_ids(r): session = ss.get_session(r, sid) if session.get("user.id") != r.user.id: continue self._table.append(html.TR().extend([ html.TD().extend( [html.INPUT(type="checkbox", name="session.%s" % sid)]), html.TD().extend([session.get("from_ip")]), html.TD().extend([format_time(session.get("started"))]), html.TD().extend([format_time(session.get("expires"))]), html.TD().extend([session.get("from_ua")]), ])) form.append( unicode( html.INPUT(type="submit", name='save', value="Delete Sessions"))) form.append( unicode(html.INPUT(type="submit", name='cancel', value="Cancel"))) #form.append(repr(r.in_headers)) return unicode(form)