This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| 6fd9fe18 » | lkcl | 2008-09-05 | 1 | from lxml import etree | |
| 26ca332d » | lkcl | 2008-09-05 | 2 | import sys | |
| 3 | import inspect | ||||
| 6fd9fe18 » | lkcl | 2008-09-05 | 4 | ||
| 5 | def JS(txt): | ||||
| 6 | error | ||||
| 7 | return txt | ||||
| 8 | |||||
| 9 | def console(txt): | ||||
| 10 | print txt | ||||
| 11 | |||||
| 12 | global xml_doc | ||||
| 13 | xml_doc = None | ||||
| 14 | |||||
| 15 | def init_doc(html_file): | ||||
| 16 | global xml_doc | ||||
| 17 | doc = open(html_file).read() | ||||
| 18 | xml_doc = etree.HTML(doc) | ||||
| 19 | |||||
| 20 | def doc(): | ||||
| 21 | global xml_doc | ||||
| 22 | return xml_doc | ||||
| 23 | |||||
| 26ca332d » | lkcl | 2008-09-05 | 24 | def module_stack_name(fn, todo): | |
| 25 | if todo and hasattr(fn, todo): | ||||
| 26 | # it's a class | ||||
| 27 | return "%s.%s.%s" % (fn.__module__, fn.__class__.__name__, todo) | ||||
| 28 | # it's a function | ||||
| 29 | return "%s.%s" % (fn.__module__, fn.func_code.co_name) | ||||
| 30 | |||||
| 31 | def frame_stack_name(fn=None, skip=0, break_at=None): | ||||
| 32 | if fn is None: | ||||
| 33 | fn = sys._getframe(1) | ||||
| 34 | name = [] | ||||
| 35 | |||||
| 36 | old_txt = None | ||||
| 37 | while fn.f_back and fn.f_code.co_name != break_at: | ||||
| 38 | if skip: | ||||
| 39 | skip -= 1 | ||||
| 40 | else: | ||||
| 41 | txt = fn.f_code.co_name | ||||
| 42 | self_obj = fn.f_locals.get('self') | ||||
| 43 | if self_obj: #inspect.isclass(fn): | ||||
| 44 | txt = "%s.%s" % (self_obj.__class__.__name__, txt) | ||||
| 45 | if txt != old_txt: | ||||
| 46 | name.append(txt) | ||||
| 47 | old_txt = txt | ||||
| 48 | fn = fn.f_back | ||||
| 49 | name.reverse() | ||||
| 50 | return '+'.join(name) | ||||
| 51 | |||||
| 52 | def doc_process(module, REQUEST): | ||||
| 53 | from ui import RootPanel, get_widget_by_id, reset_widgets | ||||
| 54 | import DOM | ||||
| 55 | global xml_doc | ||||
| 56 | |||||
| 57 | # first, carry out the initial document creation. | ||||
| 58 | reset_widgets() | ||||
| de9c54ad » | lkcl | 2008-09-06 | 59 | m = module() | |
| 60 | m.onModuleLoad() | ||||
| 26ca332d » | lkcl | 2008-09-05 | 61 | ||
| 62 | p = RootPanel() | ||||
| 63 | |||||
| 64 | if REQUEST.has_key('__post__'): | ||||
| 65 | for k in REQUEST.keys(): | ||||
| 66 | if k == '__post__': | ||||
| 67 | continue | ||||
| 68 | widget = get_widget_by_id(k) | ||||
| 69 | if not widget: | ||||
| 70 | continue | ||||
| 71 | event = DOM.BrowserEvent("click") | ||||
| 72 | DOM.dispatchEvent(event, widget.getElement(), widget) | ||||
| 73 | |||||
| 74 | # last, set up a FORM around the entire document. | ||||
| 75 | body = xml_doc.find('body') | ||||
| 76 | form = DOM.createElement('form') | ||||
| 77 | DOM.setAttribute(form, "action", "./") | ||||
| 78 | DOM.setAttribute(form, "method", "GET") | ||||
| 79 | hidden = DOM.createElement('input') | ||||
| 80 | DOM.setAttribute(hidden, "type", "hidden") | ||||
| 81 | DOM.setAttribute(hidden, "name", "__post__") | ||||
| 82 | form.append(hidden) | ||||
| 83 | while len(body): | ||||
| 84 | child = body[0] | ||||
| 85 | body.remove(child) | ||||
| 86 | form.append(child) | ||||
| 87 | body.append(form) | ||||
| de9c54ad » | lkcl | 2008-09-06 | 88 | ||
| 89 | #from pickle import dump | ||||
| 90 | #f = open("/tmp/dump.obj", "w") | ||||
| 91 | #dump(m, f) | ||||
| 26ca332d » | lkcl | 2008-09-05 | 92 | return etree.tostring(xml_doc) | |







