synack / ncore

Various utility modules and classes for my applications

This URL has Read+Write access

Jeremy Grosser (author)
Sun Oct 25 00:23:48 -0700 2009
commit  e429849e03c588cf6d98a7164837130d361fdc9e
tree    fddcdff5e5a3a631708e95f04a43741ef8ddff86
parent  84bad0bce90b2bd00fca886a581a3635363f793a
ncore /
name age message
file .gitignore Mon Dec 22 18:16:09 -0800 2008 Initial commit [synack]
file LICENSE Mon Dec 22 18:31:03 -0800 2008 Added README and BSD license [synack]
file MANIFEST Mon Dec 22 18:35:39 -0800 2008 Adding manifest generated by distutils [synack]
file README Loading commit data...
directory ncore/
file setup.py
README
ncore contains a number of utility modules for neohippie.net applications

daemon.py
This module performs the common task of daemonizing a process by forking it and 
separating it from the current session.
>> from ncore.daemon import become_daemon
>> become_daemon()

rest.py
Implements some convenience methods for working with RESTful services
>> from ncore.rest import request
>> status, headers, response = request('GET', 'http://twitter.com/statuses/public_timeline.json')
>> status
200

serialize.py
For use with WebOb, allow serialization of multiple formats for use in HTTP
responses.
>>> from ncore.serialize import dumps, loads
>>> from webob import Request
>>> r = Request({'QUERY_STRING': 'format=json&callback=cbfunc1'})
>>> dumps(r.params, {'a': 1, 'b': 2, 'c': 3})
'cbfunc1({\n    "a": 1, \n    "c": 3, \n    "b": 2\n})'
>>> r = Request({'QUERY_STRING': 'format=yaml'})
>>> dumps(r.params, {'a': 1, 'b': 2, 'c': 3})
'{a: 1, b: 2, c: 3}\n'

xml.py
Build XML trees in a fairly pythonic way.
>>> from ncore.xml import XMLBuilder
>>> root = XMLBuilder()
>>> root.foo.bar = 'Hello world'
>>> root.foo['id'] = 20
>>> root.baz = 'gir'
>>> print str(root)
<foo><bar id="20">Hello world</bar></foo><baz>gir</baz>