Monday, April 30, 2012

Django/Web Modules

Modernizer - Feature Detection for JS
http://modernizr.com/

Django-flash - Rails-like django flash messages:
https://github.com/danielfm/django-flash

Facebook-Graph - Django facebook graph API
https://github.com/feinheit/django-facebook-graph

django-cumulus - Rackspace manager

Django-ittybitty - Django based URL Shortener:
django-ittybitty

Django Storages

Python-Postmark - API for http://postmarkapp.com/

Django Cache Utils

stripe-python - API for Stripe.com (like Braintree)

FrogBugz - online ticket tracking system
http://www.fogcreek.com/fogbugz/pricing.html

Form Builder
http://www.wufoo.com

Factual - service for data information and places. GeoData
http://v2.factual.com/

CartoDB - open source data browser db
https://github.com/Vizzuality/cartodb

GeoCoda - Online Geocoding tool
https://geocoda.com/

Census Tiger Dataset
http://www.census.gov

SendGrid - Email Web applications
http://sendgrid.com/

RapidSSL - Cheap SSL Host

django-tables2 - manipulate html tables programmatically similar to Django forms.
http://django-tables2.readthedocs.org/en/latest/index.html

django-message-extends - extensions to Django messages such as sticky messages and assigned messages
https://github.com/AliLozano/django-messages-extends

Simple Logging

Simple Logging

In someplace like python shell, __init__.py, or settings.py (pre Django 1.3):

import logging
logger = logging.getLogger('mymodule.test')
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(lineno)s - %(levelname)s - %(message)s")

# Configure log to file
filelog = logging.FileHandler("mylogfile.log", 'a')
filelog.setLevel(logging.INFO)
filelog.setFormatter(formatter)
logger.addHandler(filelog)

# Configure log to stdout
conlog = logging.StreamHandler()
conlog.setLevel(logging.DEBUG)
conlog.setFormatter(formatter)
logger.addHandler(conlog)

In place you want to log in, like views.py:

import logging
logger = logging.getLogger('mymodule.test')
logger.debug("My Log text")
logger.info("My info text")

Another example of simple logging:

import logging
logger = logging.getLogger('mymodulename')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)


---------------------------------------------------

A simple example:

import logging
logging.basicConfig(filename='test.log', level=logging.DEBUG)
logging.info("INFO")
logging.debug("DEBUG")
logging.error("ERROR")


Sources:
http://dancingpenguinsoflight.com/2009/03/simple-and-effective-python-logging/
http://www.blog.pythonlibrary.org/2012/08/02/python-101-an-intro-to-logging/