This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "Memcached cache backend" | |
| from django.core.cache.backends import memcached | |
| from django.utils.encoding import smart_unicode, smart_str | |
| MIN_COMPRESS_LEN = 150000 | |
| class CacheClass(memcached.CacheClass): | |
| def add(self, key, value, timeout=None, min_compress_len=MIN_COMPRESS_LEN): | |
| if isinstance(value, unicode): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Save the supervisord.initscript script as /etc/init.d/supervisord | |
| Run /usr/sbin/update-rc.d -f supervisord defaults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This code grabs all unknown browsers in django-request on a django project. | |
| from request.models import Request | |
| from request.utils import browsers | |
| requests = Request.objects.this_month().only('user_agent') | |
| user_agents = [request.user_agent for request in requests] | |
| unknown_agents = [agent for agent in user_agents if browsers.resolve(agent)[0] == 'Unknown'] | |
| print unknown_agents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import forms | |
| from django.utils.encoding import force_unicode | |
| from taggit.managers import TaggableManager | |
| from taggit.utils import parse_tags | |
| # Extended from django-taggit (http://github.com/alex/django-taggit) | |
| class ExtendedTagField(forms.CharField): | |
| """An extended TagField that makes use of the tag parser from django-tagging.""" | |
| def clean(self, value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| Run Django Tests with full test coverage | |
| This starts coverage early enough to get all of the model loading & | |
| other startup code. It also allows you to change the output location | |
| from $PROJECT_ROOT/coverage by setting the $TEST_COVERAGE_OUTPUT_DIR | |
| environmental variable. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| Run Django Tests with full test coverage | |
| This starts coverage early enough to get all of the model loading & | |
| other startup code. It also allows you to change the output location | |
| from $PROJECT_ROOT/coverage by setting the $TEST_COVERAGE_OUTPUT_DIR | |
| environmental variable. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| fabfile for Django | |
| ------------------ | |
| see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/ | |
| modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle) | |
| several additions, corrections and customizations, too |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from __future__ import with_statement # needed for python 2.5 | |
| from fabric.api import * | |
| from fabric.contrib.console import confirm | |
| # ================================================================ | |
| # NOTE: | |
| # using this fabfile expects that you have the python utility | |
| # fabric installed locally, ssh access to reamea.com, and your | |
| # ssh public key associated with the account 'mboza@reamea.com' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| This fabric file makes setting up and deploying a django application much | |
| easier, but it does make a few assumptions. Namely that you're using Git, | |
| Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have | |
| Django installed on your local machine and SSH installed on both the local | |
| machine and any servers you want to deploy to. | |
| _note that I've used the name project_name throughout this example. Replace | |
| this with whatever your project is called._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ===================== | |
| Readernaut Public API | |
| ===================== | |
| 1.0 (pre-release) | |
| ================= | |
| Reader Books | |
| ------------ |