def element_delete_form(target, serial_id): return ''' <form method="POST" action="%(uri)s/delete"> <input type="hidden" name="serial_id" value="%(serial_id)s"> <input type="submit" value="Delete"> </form> ''' % { 'uri': get_uri(target), 'serial_id': serial_id }
def element_edit_form(target, serial_id): return ''' <form method="GET" action="%(uri)s/edit#%(serial_id)s"> <input type="hidden" name="serial_id" value="%(serial_id)s"> <input type="submit" value="Edit"> </form> ''' % { 'uri': get_uri(target), 'serial_id': serial_id }
def post_id_V_delete(self, http, hid, serial_id): actor = get_actor(hid) previous_element = actor.delete_element(int(serial_id)) if previous_element is None: uri = get_uri(actor) else: uri = element_uri(actor, previous_element) http.redirect(uri)
def post_id_V_addmethod(self, http, hid, content): actor = get_actor(hid) selector, parameters = parse_signature(content) actor.add_method(selector, parameters) element = actor.get_method(selector) http.redirect('%s/edit?%s#%s' % \ (get_uri(actor), urllib.parse.urlencode({'serial_id': element.serial_id}), element.serial_id))
def post_id_V_addmethod(self, http, hid, content): actor = get_actor(hid) selector, parameters = parse_signature(content) actor.add_method(selector, parameters) element = actor.get_method(selector) http.redirect('%s/edit?%s#%s' % \ (get_uri(actor), urllib.urlencode({'serial_id': element.serial_id}), element.serial_id))
def element_editor_form(target, serial_id, body): return ''' <form method="POST" action="%(uri)s/update"> <input type="hidden" name="serial_id" value="%(serial_id)s"> <input type="submit" value="Save"> <textarea name="body" style="width:100%%" rows="10">%(body)s</textarea> </form> ''' % { 'uri': get_uri(target), 'serial_id': serial_id, 'body': cgi.escape(body) }
def method_call_form(target, selector, argument_field): body = '<input type="submit" value="Call"> ' + argument_field return ''' <form method="POST" action="%(uri)s/call"> <input type="hidden" name="selector" value="%(selector)s"> %(body)s </form> ''' % { 'uri': get_uri(target), 'selector': cgi.escape(selector, True), 'body': body }
def method_call_form(target, selector, argument_field): body = '<input type="submit" value="Call"> ' + argument_field return ''' <form method="POST" action="%(uri)s/call"> <input type="hidden" name="selector" value="%(selector)s"> %(body)s </form> ''' % { 'uri': get_uri(target), 'selector': html.escape(selector, True), 'body': body }
def element_editor_form(target, serial_id, body): return ''' <form method="POST" action="%(uri)s/update"> <input type="hidden" name="serial_id" value="%(serial_id)s"> <input type="submit" value="Save"> <textarea name="body" style="width:100%%" rows="10">%(body)s</textarea> </form> ''' % { 'uri': get_uri(target), 'serial_id': serial_id, 'body': html.escape(body) }
def show_body(self, actor): # XXX the env should be a sprout of the actor's env # shared by its other examples # XXX skip result if actor is None if actor not in self.results: self._add_result(actor, self._run(actor)) result = self.results[actor] if type(result) == type(''): result_html = cgi.escape(result) else: # XXX we don't necessarily have editor privileges on the result result_html = '<a href="%s">%s</a>' % (get_uri(get_editor(result)), result.link_caption()) return '? %s<br>%s' % (self.expression.mark_up(actor.get_env()), result_html)
def show_body(self, actor): # XXX the env should be a sprout of the actor's env # shared by its other examples # XXX skip result if actor is None if actor not in self.results: self._add_result(actor, self._run(actor)) result = self.results[actor] if type(result) == type(''): result_html = html.escape(result) else: # XXX we don't necessarily have editor privileges on the result result_html = '<a href="%s">%s</a>' % (get_uri( get_editor(result)), result.link_caption()) return '? %s<br>%s' % (self.expression.mark_up( actor.get_env()), result_html)
def adder_form(target): return ''' <hr> <form method="POST" action="%(uri)s/addmethod"> <input type="textarea" name="content"> <input type="submit" value="Add method"> </form> <form method="POST" action="%(uri)s/addexample"> <input type="textarea" name="content"> <input type="submit" value="Add example"> </form> <form method="POST" action="%(uri)s/addtext"> <textarea name="content" style="width:90%%" rows="10"></textarea><br> <input type="submit" value="Add text"> </form> ''' % { 'uri': get_uri(target) }
def show_data(self): return """Contents: <a href="%s">contents</a>\n<hr>\n""" % \ get_uri(self.primitive_data)
def show(self): to_editor = '<a href="%s">[Unseal]</a><hr>' % get_uri(get_editor(self)) return to_editor + self.show_data() + self.get_script().show_bare(self)
def post_makeaccount(self, http): import builtin account = builtin.make_account() add_account(get_id(account)) http.redirect('%s' % get_uri(account))
def post_id_V_call(self, http, hid, selector, **query): actor = get_actor(hid) # XXX what if query needs to contain 'selector' as a key? arguments = parse_args(actor.get_method(selector), query) result = actor.call(selector, arguments) http.redirect('%s' % get_uri(result))
def element_uri(actor, element): return '%s#%s' % (get_uri(actor), element.serial_id)
def show(self): to_bare = '<a href="%s">[Seal]</a><hr>' % get_uri(self.actor) return to_bare + self.actor.show_data() + \ self.actor.get_script().show(self, self.editable)