Login

Snippets by henning

Snippet List

My approach on class based views

By using __new__ the result of a class instantiation is not an object but the result of a method call. This way classes can be used for views the same way as functions.

  • class based views
Read More

Search djangosnippets.org

I was tired browsing via tag to find snippets I saw a while ago. So I created a custom search engine with Google. To try it out go to [http://henning.cco-ev.de/django/djangosnippets.html](http://henning.cco-ev.de/django/djangosnippets.html)

  • snippets
  • search
  • google
  • snippet
  • djangosnippets
  • cse
Read More

Create nice looking PDFs from developer documentation

You need htmldoc, rst2html, the Python Imaging Libraray, BeautfiulSoup and spoon. The Debian/Ubuntu-packages are called htmldoc, python-docutils, python-imaging and python-beautifulsoup You can get spoon.py http://beautifulspoon.googlecode.com/svn/trunk/spoon.py To create the pdf files you have to call the script from django_src/docs Here is an example output: http://henning.cco-ev.de/django/essential.pdf

  • pdf
  • documentation
  • docs
Read More

browscap.ini-parser

Sometimes you need to know if a visitor is a bot or if the browser supports certain features or if it is a mobile device. The easiest way to do so would be to lookup the user agent in a capabilities database. Fortunately there is already such a database called browscap.ini which is widely known among PHP users. I found the file accidently on my harddrive because it is also used by Mono: /etc/mono/browscap.ini Read http://browsers.garykeith.com/index.asp for more information. Before importing the module you need to call the script from commandline to retrieve the browscap.ini file. Look at the test function to see how to use it. You can also create a file called "bupdate.ini" which can contain fixes for wrong or incomplete entries, e.g: [Konqueror] javaapplets=True

  • ie
  • browscap
  • browser
  • detection
  • firefox
  • opera
  • mozilla
  • safari
Read More

henning has posted 5 snippets.