I though I'd share some of the things I'm discovering as I'm attempting to write a MongoDB+Pyramid application. I'm implementing a traversal based system, which may or may not be the right approach, but at least it forced me to start with the default pyramid_starter template which doesn't have dependencies on ZODB or SQLAlchemy as a startinging point.
Documentation is a bit lacking on the whole custom renderer thing, specially with what renderers are supposed to be doing. At first I thought I would have to be creating and using a Response object, but it doesn't seem it's the case. In my __init__.py file ... #Create the application configurator config = Configurator(root_factory=get_root, settings=settings) # Add custom renderers config.add_renderer('mongo_json', 'pyramidtest.renderers.MongoJSONRenderer') # Add views config.add_view('pyramidtest.views.json_view', name='', renderer='mongo_json') ... created a new renderers.py file import json from pymongo import json_util class MongoJSONRenderer: def __init__(self, info): """ Constructor: info will be an object having the the following attributes: name (the renderer name), package (the package that was 'current' at the time the renderer was registered), type (the renderer type name), registry (the current application registry) and settings (the deployment settings dictionary). """ def __call__(self, value, system): """ Call a the renderer implementation with the value and the system value passed in as arguments and return the result (a string or unicode object). The value is the return value of a view. The system value is a dictionary containing available system values (e.g. view, context, and request). """ request = system.get('request') if request is not None: if not hasattr(request, 'response_content_type'): request.response_content_type = 'application/json' return json.dumps(value, default=json_util.default) Is this right? it seems to work, but I'm not sure it's the best way to implement that. oO -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.