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.db import models, connection | |
class SearchQuerySet(models.query.QuerySet): | |
"""SearchQuerySet""" | |
def __init__(self, model=None, fields=None, using=None, query=None): | |
super(SearchQuerySet, self).__init__(model, query, using) | |
self._search_fields = fields | |
def search(self, squery): |
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
import logging | |
l = logging.getLogger('django.db.backends') | |
l.setLevel(logging.DEBUG) | |
l.addHandler(logging.StreamHandler()) |
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
import re | |
import urllib | |
""" | |
strip html tags from a webpage | |
need's regex to remove js too | |
""" | |
url = '' |
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
def get_monitor(): | |
"""download and enable auto restart of wsgi""" | |
run('cd %(path)s;git clone git://gist.github.com/258020.git gist-258020' % env) | |
run('cd %(path)s/gist-258020; mv monitor.py %(path)s/%(projectname)s/; rm -rf %(path)s/gist-258020' % env) | |
append("\nimport %(projectname)s.monitor\n%(projectname)s.monitor.start(interval=1.0)" % env,"%(apache_path)s/%(projectname)s.wsgi" % env) |
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
def enable_site(): | |
"""this enable your site using httpd.conf""" | |
append('#enabling %(projectname)s\nInclude %(apache_path)s/%(projectname)s.conf\n' % env,'%(httpd)s' % env, use_sudo=True) | |
append('%(ip)s %(projectname)s.local' % env, '/etc/hosts', use_sudo=True) |
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
def write_wsgi(): | |
"""docstring for write_wsgi""" | |
file = open("%(apache_path)s/%(projectname)s.wsgi" % env, "w") | |
file.write("import os, sys\nsys.path = ['%(path)s'] + sys.path\n\n\nos.environ['DJANGO_SETTINGS_MODULE'] = '%(projectname)s.settings'\n \n\nimport django.core.handlers.wsgi\napplication = django.core.handlers.wsgi.WSGIHandler()" % env) | |
file.close() | |
def write_conf(): | |
"""docstring for write_conf""" | |
file = open("%(apache_path)s/%(projectname)s.conf" % env, "w") | |
file.write("WSGIPythonHome '%(path)s'\nWSGIRestrictStdout Off\nWSGIDaemonProcess %(projectname)s\nWSGIProcessGroup %(projectname)s\n\n<VirtualHost *:80>\n ServerName %(projectname)s.local\n Alias /site_media/ '%(apache_path)s/public/site_media'\n<Directory '%(apache_path)s/public/site_media'>\n Order allow,deny\n Options Indexes\n Allow from all\n\n</Directory>\n\n\n\nAlias /media/ '%(path)s/lib/python2.6/site-packages/django/contrib/admin/media/'\n<Directory '%(path)s/python2.6/site-packages/django/contrib/admin/media/'>\n Orde |
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
def setup(): | |
"""docstring for setup""" | |
require('hosts', provided_by=[local]) | |
require('path') | |
with cd(env.workspace): | |
run('virtualenv --no-site-packages %(projectname)s' % env) | |
sudo('easy_install pip', pty=True) | |
run('source %(activate_path)s; pip install django' % env) | |
with cd(env.path): | |
run('source %(activate_path)s; django-admin.py startproject %(projectname)s' % env) |
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
def local(): | |
"""your local setup""" | |
env.hosts = ['localhost'] | |
env.user = 'username' | |
env.password = 'secret' | |
env.projectname = 'test_project' | |
env.workspace = '/Users/%(username)s/Sites' #name of workspace dir | |
env.path = '%(workspace)s/%(projectname)s' % env | |
env.activate_path = '%(workspace)s/%(projectname)s/bin/activate' % env | |
env.apache_path = '%(path)s/apache' % env |
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
import os, sys | |
sys.path = ['/Users/username/Sites/sitename.tld'] + sys.path | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'sitename.settings' | |
import django.core.handlers.wsgi | |
application = django.core.handlers.wsgi.WSGIHandler() |
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
WSGIPythonHome /Users/username/Sites/sitename.tld | |
WSGIRestrictStdout Off | |
WSGIDaemonProcess sitename.tld | |
WSGIProcessGroup sitename.tld | |
<VirtualHost *:80> | |
ServerName sitename.local | |
Alias /site_media/ "/Users/username/Sites/sitename.tld/site-media/" | |
<Directory "/Users/username/Sites/sitename.tld/site-media/"> | |
Order allow,deny |