Example #1
0
    def respondToGet(self, transaction):
        err = None
        # Grab the inx for person, stories
        try:
            person = int(self.getField(transaction, FIELD_PERSON))
            story1 = int(self.getField(transaction, FIELD_STORY1))
            story2 = int(self.getField(transaction, FIELD_STORY2))
        except MissingFieldException as e:
            err = str(e)
        except ValueError as e:
            err = str(e)

        if err is None:
            # Check they're all in range
            if (person not in LookupData.getPeople().keys()) or \
               (story1 not in LookupData.getStories().keys()) or \
               (story2 not in LookupData.getStories().keys()):
                 err = "One of the supplied story or person values is not valid."

        # Return any error...
        if err is not None:
            self.response().sendError(400, err)
            self.response().write("400: %s" % err)
            self.endResponse()
        else:
            # let the bot know
            botthread.marbleBot().dropMarble(person, story1)
            botthread.marbleBot().dropMarble(person, story2)
            self.sendRedirectAndEnd("Main?grateful=lots")
Example #2
0
 def writeContent(self):
     # Add the lookup data to the request and forward to the PSP.
     if botthread.marbleBot().running():
         self.request().botError = None
     else:
         self.request().botError = botthread.marbleBot().error()
     self.request().people = LookupData.getPeople()
     self.request().stories = LookupData.getStories()
     self.forward('Main.psp')
Example #3
0
 def respondToGet(self, transaction):
     if botthread.marbleBot().running():
         err = "The bot seems fine. Reset using the button."
         self.response().sendError(400, err);
         self.response().write("400: %s" % err)
         self.endResponse()
     else:
         botthread.reset()
         self.sendRedirectAndEnd("Main")