Add support for callables in 'default'/'missing' serialization/deserialization #61

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

This commit add support in SchemaNode serialization/deserialization to allow the following code:

import colander
import datetime

class Log(colander.MappingSchema):
service_name = colander.SchemaNode(colander.String())
action = colander.SchemaNode(colander.String())
timestamp = colander.SchemaNode(colander.DateTime(),
default=datetime.datetime.now
missing=datetime.datetime.now)

Added tests to check the new feature.
Update docs inside SchemaNode.init to explain the new feature.

Add support for callables in 'default'/'missing' serialization/deseri…
…alization.

Add tests.
Change docs inside SchemaNode.__init__.
colander/__init__.py
@@ -1,6 +1,7 @@
import datetime
import decimal
import time
+import inspect
@jparise

jparise Aug 13, 2012

inspect appears to be unused.

@stefanofontanelli

stefanofontanelli Aug 13, 2012

Yes, I forgot to removed it.
I used it in a previous version.

I opened a new pull request with a two commits. The second one removes unused import.

Of course... I didn't read "You can add more commits to this pull request by pushing to the master branch on stefanofontanelli/colander" at the bottom of pull request :(

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