cbackas wrote:
> Hello all,
>
> I'm evaluating various web technologies for use in my
company, and
> Python is a front-runner language due to the ability it
gives us to
> re-use an extensive Objective-C (Cocoa) codebase.
>
> Anyway, I've been looking into CherryPy on a friend's
enthusiastic
> recommendation, but I can't get a simple test of
sessions to work. When
> I check what headers I'm getting back the browsers all
agree (OmniWeb,
> Safari, FireFox, and even Curl) are agreeing that
they're getting a
> Session ID Cookie. However, the CherryPy server seems
to issue a new
> one for every request instead of maintaining session.
I'm convinced I'm
> overlooking something basic, but I can't see it =)
>
> Below is my script; I'm using a Cheetah template
that's working fine,
> and you can gloss over the strange Apple-ish stuff ;)
The line "print
> "index: " + str(cherrypy.session)" is
always printing a different value
> to console no matter what I do. I'll paste my .conf
file after the
> script.
>
> Thanks for any insight!
>
> Chris Backas
>
>
> #!/usr/local/bin/python
> # IPWeb.py
> # IPWeb
> #
> from cherrypy import expose, session, config, server,
NotFound,
> response
> import cherrypy
> from Cheetah.Template import Template
> import sys
> from Foundation import *
> from AppKit import NSBitmapImageRep
> import IPWebFramework
> import IPPostgreSQL
>
>
> def get_page(name):
> '''Get a page template'''
> return Template(file = '%s.tmpl' % name)
>
> # Connect to PostgreSQL database server
> pgConn = IPWebFramework.WebHelper.connectToPostgres()
>
>
> class IPWebTest:
> def index(self,requestID = None, cabinet = None,
carrier = None):
> # CherryPy will call this method for the root URI
("/") and send
> # its return value to the client.
>
> page = get_page("index")
> # Initial page
> if (requestID is None) or (cabinet is None) or
(carrier is None):
> return str(page)
>
> cherrypy.session.acquire_lock()
> cherrypy.session["requestID"] = requestID
> cherrypy.session["cabinet"] = cabinet
> cherrypy.session["carrier"] = carrier
> print "index: " + str(cherrypy.session)
> page.requestID = requestID
> page.cabinet = cabinet
> page.carrier = carrier
>
> return str(page)
> index.exposed = 1
>
>
> if __name__ == '__main__':
> # Use the configuration file
> cherrypy.config.update(file = 'IPWebApp.conf')
> cherrypy.config.update({'session_filter.on': True})
> # Start the CherryPy server.
> cherrypy.tree.mount(IPWebTest())
> cherrypy.server.start()
>
>
>
> IPWebAll.conf:
>
> [global]
> server.socketPort = 8080
> server.threadPool = 10
> server.environment = "production"
> server.session_filter.on = 1
> # server.showTracebacks = True
> # server.logToScreen = False
Well, I'm stumped. I ran a test very similar to yours and
got the same
id every time. Perhaps you have cookies disabled?
import cherrypy
class IPWebTest:
def index(self, requestID = None, cabinet = None,
carrier = None):
if (requestID is None) or (cabinet is None) or
(carrier is
None):
return "missing"
cherrypy.session.acquire_lock()
cherrypy.session["requestID"] =
requestID
cherrypy.session["cabinet"] = cabinet
cherrypy.session["carrier"] = carrier
print "index: " + str(cherrypy.session)
return "OK"
index.exposed = True
if __name__ == '__main__':
cherrypy.config.update({'server.socketPort': 8080,
'server.threadPool': 10,
'server.environment':
"production",
'session_filter.on': True,
'server.log_to_screen': False,
})
cherrypy.tree.mount(IPWebTest())
cherrypy.server.start()
index: {'carrier': 'c', '_id':
'b2e0af86bc9b7f8fa0e9ab6b0970c7fad097b680', 'requestID':
'a',
'cabinet': 'b'}
index: {'carrier': 'd', '_id':
'b2e0af86bc9b7f8fa0e9ab6b0970c7fad097b680', 'requestID':
'a',
'cabinet': 'b'}
index: {'carrier': 'e', '_id':
'b2e0af86bc9b7f8fa0e9ab6b0970c7fad097b680', 'requestID':
'a',
'cabinet': 'b'}
index: {'carrier': 'f', '_id':
'b2e0af86bc9b7f8fa0e9ab6b0970c7fad097b680', 'requestID':
'a',
'cabinet': 'b'}
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|