Skip to content

Commit

Permalink
Tightened up sessions, added redirects and setting headers from dbpy
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis Sobel committed Apr 18, 2012
1 parent 5ef5de2 commit b28f0c0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drapache/dbapiserver.py
Expand Up @@ -63,7 +63,7 @@ def serve(self,path):
#first check if it doesn't end with a slash #first check if it doesn't end with a slash
if not path.endswith('/'): if not path.endswith('/'):
redirect_location = path+'/' redirect_location = path+'/'
if self.query_string: if self.request.query_string:
redirect_location += '?'+self.request.query_string redirect_location += '?'+self.request.query_string


return ResponseObject(301,'redirect',headers={'Location':redirect_location}) return ResponseObject(301,'redirect',headers={'Location':redirect_location})
Expand Down
23 changes: 23 additions & 0 deletions drapache/dbpybuiltins.py
Expand Up @@ -17,6 +17,8 @@
import dropbox import dropbox


import os.path import os.path

import markdown


import StringIO import StringIO


Expand Down Expand Up @@ -230,6 +232,27 @@ def start_session():
def destroy_session(): def destroy_session():
session.destroy() session.destroy()


@register
def set_response_header(key,value):
response.set_header(key,value)

@register
def set_response_status(status):
response.status = status

@register
def redirect(where,immediately=True):
set_response_status(302)
set_response_header('Location',where)

if immediately:
die("redirecting")


@register
def markdown_to_html(markdown_string):
return markdown.markdown(markdown_string)

@register @register
def pretty_print(thingy,pre=True): def pretty_print(thingy,pre=True):
""" """
Expand Down
1 change: 1 addition & 0 deletions drapache/dbpyexecute.py
Expand Up @@ -18,6 +18,7 @@
import sandbox as pysandbox import sandbox as pysandbox
from util import ResponseObject from util import ResponseObject
import dbpybuiltins import dbpybuiltins

import dbapiio import dbapiio


class Timeout(Exception): class Timeout(Exception):
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
@@ -1,5 +1,8 @@
dropbox==1.3 dropbox==1.3
-e git+git://github.com/haypo/pysandbox.git#egg=sandbox -e git+git://github.com/haypo/pysandbox.git#egg=sandbox
markdown
beaker



### only needed if using mysql for the subdomain list ### only needed if using mysql for the subdomain list
#Mysql-python #Mysql-python

0 comments on commit b28f0c0

Please sign in to comment.