Created: (MODPYTHON-42) Cookie documentation, small correction
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Created: (MODPYTHON-42) Cookie documentation, small correction




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Created: (MODPYTHON-42) Cookie documentation, small correction  
Vivian De Smedt (JIRA)


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-31-05 12:20 AM

Cookie documentation, small correction
--------------------------------------

Key: MODPYTHON-42
URL: http://issues.apache.org/jira/browse/MODPYTHON-42
Project: mod_python
Type: Bug
Components: documentation
Versions: 3.2.0
Environment: Documentation found on the mod_python website
Reporter: Vivian De Smedt
Priority: Minor


Dear mod_python developper,

I just want notify you a small mistakes the Cookie module documentation.
The sample section use the get_cookie api instead of the get_cookies one.
In consequence the following section:

from mod_python import apache, Cookie

def handler(req):

cookies = Cookie.get_cookie(req, Cookie.MarshalCookie,
secret='secret007')
if cookies.has_key('spam'):
spamcookie = cookies['spam']

req.write('Great, a spam cookie was found: %s\n' \
% str(spamcookie))
if type(spamcookie) is Cookie.MarshalCookie:
req.write('Here is what it looks like decoded: %s=%s\n'
% (spamcookie.name, spamcookie.value))
else:
req.write('WARNING: The cookie found is not a \
MarshalCookie, it may have been tapered with!')

else:

# MarshaCookie allows value to be any marshallable object
value = {'egg_count': 32, 'color': 'white'}
Cookie.add_cookie(req, Cookie.MarshalCookie('spam', value, \
'secret007'))
req.write('Spam cookie not found, but we just set one!\n')

return apache.OK

should be rewritten:

from mod_python import apache, Cookie

def handler(req):

cookies = Cookie.get_cookie*s*(req, Cookie.MarshalCookie,
secret='secret007')
if cookies.has_key('spam'):
spamcookie = cookies['spam']

req.write('Great, a spam cookie was found: %s\n' \
% str(spamcookie))
if type(spamcookie) is Cookie.MarshalCookie:
req.write('Here is what it looks like decoded: %s=%s\n'
% (spamcookie.name, spamcookie.value))
else:
req.write('WARNING: The cookie found is not a \
MarshalCookie, it may have been tapered with!')

else:

# MarshaCookie allows value to be any marshallable object
value = {'egg_count': 32, 'color': 'white'}
Cookie.add_cookie(req, Cookie.MarshalCookie('spam', value, \
'secret007'))
req.write('Spam cookie not found, but we just set one!\n')

return apache.OK

Thanks for your nice module,
Vivian.







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:27 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register