Various utility modules and classes for my applications
Python
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ncore
.gitignore
LICENSE
MANIFEST
README
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>