Modified:
branches/unhork/grassyknoll/lib/Norman.py
branches/unhork/grassyknoll/tests/test_Norman.py
Log:
Tired of looking at the complicated versions of Norman.{Timestamp,Etag};
uncommented the simple versions.
Modified: branches/unhork/grassyknoll/lib/Norman.py
==============================================================================
--- branches/unhork/grassyknoll/lib/Norman.py (original)
+++ branches/unhork/grassyknoll/lib/Norman.py Tue Jan 6 10:50:38 2009
@@ -528,29 +528,15 @@
return self._time(dt)
# XXX when called, these will silently clobber an existing value, which is
odd?
-# ??? Will they clobber it, or ignore it? Looks like they just ignore the
parameter.
-# TODO: use Factory instead of lambda
-def TimestampNorman(optional=False, filled=True, prohibited=True):
+class Timestamp(Norman):
"""Norman that returns a current L{datetime.datetime}"""
- return Factory(lambda x: datetime.datetime.now(),
- optional=optional, filled=filled, prohibited=prohibited)
+ def __call__(self, _):
+ return datetime.datetime.now()
-# ??? Why not the following? Same number of lines, much simpler.
-## class TimestampNorman(Norman):
-## """Norman that returns a current L{datetime.datetime}"""
-## def __call__(self, _):
-## return datetime.datetime.now()
-
-def EtagNorman(optional=False, filled=True, prohibited=True):
+class Etag(Norman):
"""Norman that returns a reasonable value for use as an etag"""
- return Factory(lambda x: util.unicode_unique_id(),
- optional=optional, filled=filled, prohibited=prohibited)
-
-# ??? Same thing applies here: we could have much simpler code:
-## class EtagNorman(Norman):
-## """Norman that returns a reasonable value for use as an etag"""
-## def __call__(self, _):
-## return util.unicode_unique_id()
+ def __call__(self, _):
+ return util.unicode_unique_id()
_type2norman = {}
def _build_type2norman():
Modified: branches/unhork/grassyknoll/tests/test_Norman.py
==============================================================================
--- branches/unhork/grassyknoll/tests/test_Norman.py (original)
+++ branches/unhork/grassyknoll/tests/test_Norman.py Tue Jan 6 10:50:38
2009
@@ -235,6 +235,10 @@
assert_raises(ValueError, Norman.type2norman, WhoCares)
assert_raises(ValueError, Norman.type2norman, None)
-def test_TimestampNorman():
- norm = Norman.TimestampNorman()
+def test_Timestamp():
+ norm = Norman.Timestamp()
+ assert_does_not_raise(norm, None)
+
+def test_Etag():
+ norm = Norman.Etag()
assert_does_not_raise(norm, None)