source: TI03-DataExtractor/branches/old_stuff/extractor/test.py @ 793

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI03-DataExtractor/branches/old_stuff/extractor/test.py@793
Revision 793, 1.5 KB checked in by astephen, 14 years ago (diff)

Put all the old code in the old_stuff branch.

  • Property svn:executable set to *
Line 
1#!/usr/local/cdat/bin/python
2
3import sys, os
4sys.path.append("/home/tornado/internal/badc/software/pythonlib/badc")
5import Cookie
6
7# Create a cookie dictionary object
8#os.environ["HTTP_COOKIE"]=""
9c1 = Cookie.Cookie()
10
11# Create a cookie in c1
12# This will be temporary and will disappear when the session is closed
13#c1["cracker"] = "hello"
14# The RFC says you should always set this but it seems to work ok without it
15#c1["cracker"]["version"] = 1
16
17# Create another one
18# Make the browser store it for one hour
19c1["abc"] = "astephen"
20
21
22#c1["badcid"]["max-age"] = 3600 # Time to keep, in seconds
23#c1["badcid"]["expires"] = 3600 # Obsolete, but Netscape still seems to require it
24#c1["badcid"]["version"] = 1
25
26
27# Print the headers that sets the cookies
28print c1
29
30print "Content-Type: text/html\n\n"
31
32
33# Load and print any cookies that were received
34print "<h3>Received cookies</h3>"
35
36try:
37    cookie = os.environ["HTTP_COOKIE"]
38except KeyError:
39    print "No cookies were received"
40else:
41    print "HTTP_COOKIE: "+cookie
42    print "<p>"
43    cookie = Cookie.Cookie()
44    cookie.load(os.environ["HTTP_COOKIE"])
45    print "<pre>"
46    if cookie.has_key("badcid"): print "UOUOUO"
47    print "CC:", cookie["BADC"].value
48    print "</pre>"
49
50    print "If you run it more than once within"
51    print "a session, the cookies set by this script"
52    print "will also be received from the browser."
53
54#cookie=Cookie.SimpleCookie()
55#cookie.load("badcid")
56#"badcid"
57
58
59#from security import *
60#s=Security()
61#s.login()
62
63#print "Content-Type: text/html\n\n"
64#print "Cookie_____: ", cookie
65#print "DONE"
Note: See TracBrowser for help on using the repository browser.