Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Ticket #20687 -- Added documentation for django.core.signing API. #1323

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

@timgraham timgraham and 1 other commented on an outdated diff Jul 3, 2013

django/core/signing.py
@@ -183,6 +183,11 @@ def sign(self, value):
return super(TimestampSigner, self).sign(value)
def unsign(self, value, max_age=None):
+ """
+ Retrieve original value and check it wasn't signed longer than
@timgraham

timgraham Jul 3, 2013

Owner

rephrase: signed more than max_age seconds ago (also remove extra newline in docstring)

@tricoder42

tricoder42 Jul 3, 2013

Contributor

Extra newline is suggested in PEP 8 http://www.python.org/dev/peps/pep-0008/#documentation-strings
However, I'll try to rephrase it and maybe it fits to oneline.

@timgraham

timgraham Jul 3, 2013

Owner

I'd prefer to keep the docstring consistent with those in the rest of the file (which don't have the extra line).

@tricoder42

tricoder42 Jul 3, 2013

Contributor

Sure, I've deleted it. I didn't check the rest of the file before.

@timgraham timgraham commented on an outdated diff Jul 3, 2013

docs/topics/signing.txt
@@ -124,6 +125,17 @@ created within a specified period of time::
>>> signer.unsign(value, max_age=20)
u'hello'
+.. class:: TimestampSigner(key=None, sep=':', salt=None)
+
+.. function:: TimestampSigner.sign(value)
+
+ Sign ``value`` and append current timestamp to it.
+
+.. function:: TimestampSigner.unsing(value, max_age=None)
@timgraham

timgraham Jul 3, 2013

Owner

typo: unsign
should be method rather than function

@timgraham timgraham commented on an outdated diff Jul 3, 2013

docs/topics/signing.txt
@@ -124,6 +125,17 @@ created within a specified period of time::
>>> signer.unsign(value, max_age=20)
u'hello'
+.. class:: TimestampSigner(key=None, sep=':', salt=None)
+
+.. function:: TimestampSigner.sign(value)
+
+ Sign ``value`` and append current timestamp to it.
+
+.. function:: TimestampSigner.unsing(value, max_age=None)
+
@timgraham

timgraham Jul 3, 2013

Owner

same phrasing as above

@timgraham timgraham commented on an outdated diff Jul 3, 2013

docs/topics/signing.txt
@@ -124,6 +125,17 @@ created within a specified period of time::
>>> signer.unsign(value, max_age=20)
u'hello'
+.. class:: TimestampSigner(key=None, sep=':', salt=None)
+
+.. function:: TimestampSigner.sign(value)
+
+ Sign ``value`` and append current timestamp to it.
+
+.. function:: TimestampSigner.unsing(value, max_age=None)
+
+ Checks if ``value`` was signed less than ``max_age`` seconds before, otherwise
+ raises ``SignatureExpired``
@timgraham

timgraham Jul 3, 2013

Owner

add period at end of sentence

@timgraham timgraham commented on an outdated diff Jul 3, 2013

docs/topics/signing.txt
.. function:: loads(string, key=None, salt='django.core.signing', max_age=None)
- Reverse of dumps(), raises ``BadSignature`` if signature fails.
+ Reverse of ``dumps()``, raises ``BadSignature`` if signature fails. Optionaly
@timgraham

timgraham Jul 3, 2013

Owner

I'd say, "Checks max_age if given.`` -- (just saying "optionally", doesn't indicate exactly how it's optional)

Owner

timgraham commented Jul 3, 2013

merged in c5bc98d, thanks!

@timgraham timgraham closed this Jul 3, 2013

@tricoder42 tricoder42 deleted the tricoder42:ticket-20687 branch Jul 3, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment