Example #1
0
    def command(self, command):

        # todo: integrate swil parsing matter

        # a command parsing stand in, for now
        # TODO replace this parser with something worthy
        pos = command.find(" ")
        if pos != -1:
            args = command[pos+1:].split(" ")
            command = command[:pos]
        else:
            args = []

        # command dispatch
        if command in self.commands:
            function = self.commands[command]
            try:
                function(self, *args)
            except TypeError, exception:
                self.message(
                    """
                        <p>That is not the <b>proper usage</b>
                        for the <tt>%s</tt> command.</p>
                    """ % inoculate(repr(command))
                )
                print_exc()
            except Exception, exception:
                if hasattr(self, 'message'):
                    self.message(tags.hr().xml)
                    self.message(html_repr(exception))
                    self.message(tags.hr().xml)
Example #2
0
                function(self, *args)
            except TypeError, exception:
                self.message(
                    """
                        <p>That is not the <b>proper usage</b>
                        for the <tt>%s</tt> command.</p>
                    """ % inoculate(repr(command))
                )
                print_exc()
            except Exception, exception:
                if hasattr(self, 'message'):
                    self.message(tags.hr().xml)
                    self.message(html_repr(exception))
                    self.message(tags.hr().xml)
        else:
            self.message("<p><b>Huh?</b>  <tt>%s</tt> isn't a command.</p>" % repr(inoculate(command)))

class Factory(ServiceFactory):
    """Provides HTTP protocol services, by creating HTTP Channels
    for the MAGE protocol.
    
    Also manages sessions which persist
    between HTTP requests, and provides a reference to a common service
    mode for all all requests."""

    # whether to log individual HTTP Requests
    log_requests = False

    manageGreedySessions = False
    session_url = 'session'