Google App und CherryPy Frage

Sockets, TCP/IP, (XML-)RPC und ähnliche Themen gehören in dieses Forum
Antworten
debian75
User
Beiträge: 90
Registriert: Dienstag 27. November 2007, 01:05

kann man mit dieser kombination hinbekommen, dass /url klassen darstellen? ich hatte mal das beispiel von gerold gemacht und das sah dann so aus:

Code: Alles auswählen

# Anwendung zusammensetzen
root = Root()
root.alpha = apha()
root.beta = beta()

def main():
    cherrypy.quickstart(root, config = INI_FILENAME)

if __name__ == "__main__":
    main()
damit wurde dann bei :

foobar.com root ausgeführt
foobar.com/alpha halt alpha ausgeführt etc...

geht das mit Google App? Weil ich bekomme die Meldung

"Root' object is not callable "

hier mein code:

Code: Alles auswählen

root = Root()
root.alpha = apha()
root.beta = beta()

def main():
    application = cherrypy.quickstart(root())
    wsgiref.handlers.CGIHandler().run(application)
    #application = cherrypy.Application(Root())
    #wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()
Leonidas
Python-Forum Veteran
Beiträge: 16025
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

Ich würde da eher einen NameError vermuten, weil du Root nutzt ohne es zu importieren.
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
EnTeQuAk
User
Beiträge: 986
Registriert: Freitag 21. Juli 2006, 15:03
Wohnort: Berlin
Kontaktdaten:

Ich vermute das nicht, sondern sehe:

Code: Alles auswählen

root = Root()
root.alpha = apha()
root.beta = beta()

def main():
    application = cherrypy.quickstart(root())
    wsgiref.handlers.CGIHandler().run(application)
    #application = cherrypy.Application(Root())
    #wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()
Ändere den Aufruf `application = cherrypy.quickstart(root()))` in `...quickstart(root)` – du Rufst sonst die Klasse `Root` auf, was `Root.__call__` aufruft, was erstmal definiert werden muss – das ist es nicht, ergo: ``"Root' object is not callable " ``

Wenn du die exakte Zeilennummer des Tracebacks anschaust, könnte das sogar klappen, das er die Zeile anzeigt ;)

Gruß, Christopher.
debian75
User
Beiträge: 90
Registriert: Dienstag 27. November 2007, 01:05

gracias leute :)
Antworten