for what it's worth...

if you use simplejson instead of json (many people do), there is a 
'for_json' kwarg in the encoder...

     If *for_json* is true (not the default), objects with a for_json() method 
will use the return value of that method for encoding as JSON instead of 
the object.

so you can do things like:

     class Foo(object):
          def for_json(self):
                """return json representation"""
               return {}
           __json__ = for_json # enable for pyramid's magic method

i think the json serialization stuff either belongs in the model, or as a 
helper package that has no dependencies on pyramid.

my current SQLalchemy project started out as pyramid.  It also has Celery 
and Twisted portions, and a host of command line scripts.  Guess what 
component is re-used across every framework?  my SqlAchemy models.  

The json encoding stuff has been useful for debugging; but also for caching 
and cache manipulation.  I don't need to run everything in Pyramid.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to