Example #1
0
File: rest.py Project: darius/hmph
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 }
Example #2
0
File: rest.py Project: darius/hmph
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 }
Example #3
0
File: rest.py Project: darius/hmph
 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)
Example #4
0
File: rest.py Project: void4/hmph
 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)
Example #5
0
File: rest.py Project: void4/hmph
 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))
Example #6
0
File: rest.py Project: darius/hmph
 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))
Example #7
0
File: rest.py Project: darius/hmph
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) }
Example #8
0
File: rest.py Project: darius/hmph
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 }
Example #9
0
File: rest.py Project: void4/hmph
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
    }
Example #10
0
File: rest.py Project: void4/hmph
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
    }
Example #11
0
File: rest.py Project: void4/hmph
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
    }
Example #12
0
File: rest.py Project: void4/hmph
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)
    }
Example #13
0
 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)
Example #14
0
File: actors.py Project: void4/hmph
 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)
Example #15
0
File: rest.py Project: darius/hmph
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) }
Example #16
0
File: rest.py Project: void4/hmph
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)
    }
Example #17
0
 def show_data(self):
     return """Contents: <a href="%s">contents</a>\n<hr>\n""" % \
         get_uri(self.primitive_data)
Example #18
0
File: actors.py Project: void4/hmph
 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)
Example #19
0
File: rest.py Project: darius/hmph
 def post_makeaccount(self, http):
     import builtin
     account = builtin.make_account()
     add_account(get_id(account))
     http.redirect('%s' % get_uri(account))
Example #20
0
File: rest.py Project: darius/hmph
 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))
Example #21
0
File: rest.py Project: darius/hmph
def element_uri(actor, element):
    return '%s#%s' % (get_uri(actor), element.serial_id)
Example #22
0
File: rest.py Project: void4/hmph
def element_uri(actor, element):
    return '%s#%s' % (get_uri(actor), element.serial_id)
Example #23
0
File: rest.py Project: void4/hmph
 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))
Example #24
0
 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)
Example #25
0
File: rest.py Project: void4/hmph
 def post_makeaccount(self, http):
     import builtin
     account = builtin.make_account()
     add_account(get_id(account))
     http.redirect('%s' % get_uri(account))
Example #26
0
File: actors.py Project: void4/hmph
 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)
Example #27
0
 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)
Example #28
0
 def show_data(self):
     return """Contents: <a href="%s">contents</a>\n<hr>\n""" % \
         get_uri(self.primitive_data)