braydon fuller
nieprzeczytany,3 lut 2008, 18:29:523.02.2008Zaloguj się, aby odpowiedzieć autorowi
Zaloguj się, aby przekazać dalej
Nie masz uprawnień do usuwania wiadomości w tej grupie
Zaloguj się, aby zgłosić wiadomość
Pokaż pierwotną wiadomość
Adresy e-mail w tej grupie są anonimowe lub potrzebujesz uprawnienia „Kto może wyświetlać adresy e-mail członków” do wyświetlenia pierwotnej wiadomości
do cherrypy-users
Hi,
I am using my own 404 error page that allows
users to create URIs. However, because of this, every URI will be
returned as 202 successful, as i'm not using CP error class. How can I
tell
cherrypy to delivery the page w/ the 404 not header response?
For example, below is the code I'm using for each request:
def render(args, kwargs, location_st=None):
settings = Settings()
if len(args) >= 1:
location = []
for arg in args:
location.append(arg)
location_id = "-".join(location)
try:
get_uri(location_id)
return render_skeleton(location_id, location_st, kwargs)
except IndexError:
site_name = settings.root.site_name
session = get_session()
user = session["user"]
group = session["group"]
notfound =
Template(file=settings.root.core_views_path+"/404.tmpl",
searchList=[locals()])
body = notfound.respond()
cmds_array = ""
head = render_head(location, location_st, cmds_array)
t =
Template(file=settings.root.core_views_path+"/skeleton.tmpl",
searchList=[locals()])
return t.respond()
else:
location ="r"
location_st = settings.root.site_name
return render_skeleton(location, location_st, kwargs)
this is called by:
class Root():
def __init__(self):
self.cmd = __import__('exposed', globals(), locals(),
['sparrow'])
db.create_all()
def default(self, *args, **kwargs):
location_st = ""
for arg in args:
location_st += "/"+arg
try:
return render(args, kwargs, location_st)
except:
db.start_engine()
return render(args, kwargs, location_st)
default.exposed = True
which is started by:
if __name__ == "__main__":
cherrypy.quickstart(Root(), '/', config="config/.conf")
-Braydon