def WeatherDemo(handler, tropo):
    """
    """
    choices = tropo.Choices("[5 digits]").obj

    tropo.ask(choices, 
              say="Please enter your 5 digit zip code.", 
              attempts=3, bargein=True, name="zip", timeout=5, voice="dave")

    tropo.on(event="continue", 
#             next="%s/weather.py?uri=end" % THIS_URL,
             next="/weather.py?uri=end",
             say="Please hold.")

    tropo.on(event="error",
#             next="%s/weather.py?uri=error" % THIS_URL,
             next="/weather.py?uri=error",
             say="Ann error occurred.")

    json = tropo.RenderJson()
    logging.info ("Json result: %s " % json)
    pretty = tropo.PrettyJson()
    logging.info ("WeatherDemo json: %s" % pretty)

    handler.response.out.write(pretty)
def WeatherDemo(handler, tropo):
    """
    """
    choices = tropo.Choices("[5 digits]").obj

    tropo.ask(choices,
              say="Please enter your 5 digit zip code.",
              attempts=3,
              bargein=True,
              name="zip",
              timeout=5,
              voice="dave")

    tropo.on(
        event="continue",
        #             next="%s/weather.py?uri=end" % THIS_URL,
        next="/weather.py?uri=end",
        say="Please hold.")

    tropo.on(
        event="error",
        #             next="%s/weather.py?uri=error" % THIS_URL,
        next="/weather.py?uri=error",
        say="Ann error occurred.")

    json = tropo.RenderJson()
    logging.info("Json result: %s " % json)
    pretty = tropo.PrettyJson()
    logging.info("WeatherDemo json: %s" % pretty)

    handler.response.out.write(pretty)
    def post(self):
        if (1):
            tropo = tropo.Tropo()
            tropo.say ("Welcome to the Tropo web API demo")

            request = "Please press"
            choices_string = ""
            choices_counter = 1
            for key in sorted(DEMOS.iterkeys()):
                if (len(choices_string) > 0):
                    choices_string = "%s,%s" % (choices_string, choices_counter)
                else:
                    choices_string = "%s" % (choices_counter)
                demo_name = DEMOS[key][0]
                demo = DEMOS[key][1]
                request = "%s %s for %s," % (request, key, demo_name)
                choices_counter += 1
            choices = tropo.Choices(choices_string).obj

            tropo.ask(choices, say=request, attempts=3, bargein=True, name="zip", timeout=5, voice="dave")

            tropo.on(event="continue", 
                     next="/demo_continue.py",
                     say="Please hold.")

            tropo.on(event="error",
                     next="/demo_continue.py",
                     say="An error occurred.")

            json = tropo.RenderJson()
            logging.info ("Json result: %s " % json)
            self.response.out.write(json)
    def post(self):
        if (1):
            tropo = tropo.Tropo()
            tropo.say("Welcome to the Tropo web API demo")

            request = "Please press"
            choices_string = ""
            choices_counter = 1
            for key in sorted(DEMOS.iterkeys()):
                if (len(choices_string) > 0):
                    choices_string = "%s,%s" % (choices_string,
                                                choices_counter)
                else:
                    choices_string = "%s" % (choices_counter)
                demo_name = DEMOS[key][0]
                demo = DEMOS[key][1]
                request = "%s %s for %s," % (request, key, demo_name)
                choices_counter += 1
            choices = tropo.Choices(choices_string).obj

            tropo.ask(choices,
                      say=request,
                      attempts=3,
                      bargein=True,
                      name="zip",
                      timeout=5,
                      voice="dave")

            tropo.on(event="continue",
                     next="/demo_continue.py",
                     say="Please hold.")

            tropo.on(event="error",
                     next="/demo_continue.py",
                     say="An error occurred.")

            json = tropo.RenderJson()
            logging.info("Json result: %s " % json)
            self.response.out.write(json)