braydon fuller
unread,Feb 3, 2008, 6:29:52 PM2/3/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 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