def object_xml_repr(value, host = None, depth = 1, memo = None): values = [value] if hasattr(value, '__class__'): if hasattr(value.__class__, '__mro__'): values.extend(value.__class__.__mro__) elif hasattr(value, '__bases__'): considers = [value] while considers: consider = considers.pop(0) values.append(consider) considers.extend(consider.__bases__) return tags.div( tags.p( tags.b(repr(value)), tags.ol( # for prettiness hasattr(value, '__dict__') and ( tags.table( {'class': 'definition'}, ( tags.tr( tags.th(xml_repr(heading, host, depth - 1, memo)), tags.td(xml_repr(row, host, depth - 1, memo)), ) for heading, row in sorted(vars(value).items()) ) ) ) or '' ) ) for value in values[::-1] )
def message_buffer_body(self, kit): tags = kit.tags id = kit.next_id() command_id = '%s_command' % id prompt_id = '%s_prompt' % id return tags.div( tags.table( tags.tr( tags.td( tags.nobr('', id = prompt_id), style = 'vertical-align: bottom;' ), tags.td( CommandBoxWidget(id = command_id), style = 'width: 100%' ), ), style = ''' width: 100%; ''' ), Javascript( '''shell.open( %s, %s, %s, document.getElementsByTagName('body')[0] );''' % ( repr(self.session_service.base_path), repr(prompt_id), repr(command_id), ), {'shell': javascripts.shell,} ), self.shell_body(kit), )
def dict_xml_repr(value, host = None, depth = 1, memo = None): return tags.p( tags.b(name_repr(value, memo)), tags.ol( # for prettiness tags.table( {'class': 'definition'}, ( tags.tr( tags.th(xml_repr(heading, host, depth - 1, memo)), tags.td(xml_repr(row, host, depth - 1, memo)), ) for heading, row in sorted(value.items()) ) ) ) )
def message_buffer_body(self, kit): tags = kit.tags id = kit.id host = kit.host debug = kit.debug command_id = '%s_command' % id prompt_id = '%s_prompt' % id session = self.Session() host(service = session, timeout = 20) return tags.div( tags.table( tags.tr( tags.td( tags.nobr('', id = prompt_id), style = 'vertical-align: bottom;' ), tags.td( CommandBoxWidget(id = command_id), style = 'width: 100%' ), ), style = ''' width: 100%; ''' ), Javascript( "shell.open(%s, %s, %s, %s, {'debug': %s});" % ( repr(session.base_path), repr(prompt_id), repr(command_id), repr(id), debug and '1' or '0' ), {'shell': javascripts.shell,} ), self.shell_body(kit), )