Issue Details (XML | Word | Printable)

Key: MODPYTHON-42
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Nicolas Lehuen
Reporter: Vivian De Smedt
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Cookie documentation, small correction

Created: 29/Mar/05 02:33 PM   Updated: 05/Mar/06 01:50 PM
Return to search
Component/s: documentation
Affects Version/s: 3.2.7
Fix Version/s: 3.2.7

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works modpython4-doc-patch 2005-03-30 02:21 AM Jim Gallacher 0.4 kB
Environment: Documentation found on the mod_python website

Resolution Date: 01/May/05 07:27 PM


 Description  « Hide
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.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.