List Info

Thread: cherrypy.InternalRedirect results in infinite loop




cherrypy.InternalRedirect results in infinite loop
country flaguser name
United States
2007-03-09 19:57:16
The subroutine login_proc() has this line:
               raise
cherrypy.InternalRedirect('/data_entry')

and that line is resulting in infinite calls to login_proc
instead of
redirecting to /data_entry... how can I fix this?



import StringIO
import cherrypy, meld3


class WelcomePage:

    def index(self):
        # Ask for the user's name.
        skel = meld3.parse_html("html/base.html")
        meat =
meld3.parse_html("html/login.html")

        skelmeat = skel.findmeld('meat')
        skelmeat.clear()

        for c in meat.findmeld('meat').getchildren():
            skelmeat.append(c)

        o = StringIO.StringIO()
        skel.write_xml(o)
        return o.getvalue()
    index.exposed = True


    def login_proc(self, username = None, password = None):
        if username and password:
            # Greet the user!
            raise cherrypy.InternalRedirect('/data_entry')
        else:
            return 'Please enter username/password <a
href="./">here</
a>.'
    login_proc.exposed = True

class DataEntry:
    def index(self, **arg):
        skel = meld3.parse_html("html/base.html")
        meat =
meld3.parse_html("html/data_entry.html")

        skelmeat = skel.findmeld('meat')
        skelmeat.clear()

        for c in meat.findmeld('meat').getchildren():
            skelmeat.append(c)

        o = StringIO.StringIO()
        skel.write_xml(o)
        return o.getvalue()
    index.exposed = True


cherrypy.root = WelcomePage()
cherrypy.root.data_entry = DataEntry()


if __name__ == '__main__':
    cherrypy.config.update(file = 'app.conf')
    cherrypy.server.start()


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cherrypy.InternalRedirect results in infinite loop
country flaguser name
United States
2007-03-10 02:15:20
Well I came up with a solution. I replaced the redirect
with:

            return cherrypy.root.data_entry.index()


On Mar 9, 8:57 pm, "metaperl" <metap...gmail.com> wrote:
> The subroutine login_proc() has this line:
>                raise
cherrypy.InternalRedirect('/data_entry')
>
> and that line is resulting in infinite calls to
login_proc instead of
> redirecting to /data_entry... how can I fix this?
>
> import StringIO
> import cherrypy, meld3
>
> class WelcomePage:
>
>     def index(self):
>         # Ask for the user's name.
>         skel =
meld3.parse_html("html/base.html")
>         meat =
meld3.parse_html("html/login.html")
>
>         skelmeat = skel.findmeld('meat')
>         skelmeat.clear()
>
>         for c in meat.findmeld('meat').getchildren():
>             skelmeat.append(c)
>
>         o = StringIO.StringIO()
>         skel.write_xml(o)
>         return o.getvalue()
>     index.exposed = True
>
>     def login_proc(self, username = None, password =
None):
>         if username and password:
>             # Greet the user!
>             raise
cherrypy.InternalRedirect('/data_entry')
>         else:
>             return 'Please enter username/password
<a href="./">here</
> a>.'
>     login_proc.exposed = True
>
> class DataEntry:
>     def index(self, **arg):
>         skel =
meld3.parse_html("html/base.html")
>         meat =
meld3.parse_html("html/data_entry.html")
>
>         skelmeat = skel.findmeld('meat')
>         skelmeat.clear()
>
>         for c in meat.findmeld('meat').getchildren():
>             skelmeat.append(c)
>
>         o = StringIO.StringIO()
>         skel.write_xml(o)
>         return o.getvalue()
>     index.exposed = True
>
> cherrypy.root = WelcomePage()
> cherrypy.root.data_entry = DataEntry()
>
> if __name__ == '__main__':
>     cherrypy.config.update(file = 'app.conf')
>     cherrypy.server.start()


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )