This file contains 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.contrib.admin import widgets | |
from django import forms | |
from django.contrib import admin | |
# create wrappers for overriding the queryset | |
class ToWrapper(object): | |
def __init__(self, to, manager): | |
self.to = to | |
self._default_manager = manager |
This file contains 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
# see http://groups.google.com/group/django-users/browse_thread/thread/259c1679ddaaceb8 | |
# for the problem and http://code.djangoproject.com/ticket/12780 for the admin/options.py patch | |
# required to get this working | |
from django.forms.util import ErrorList | |
class ClipAdmin(admin.ModelAdmin): | |
def formsets_are_valid(self, formsets, form, form_is_valid, instance, | |
request): | |
valid = super(ClipAdmin, self).formsets_are_valid(formsets, |
This file contains 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
""" | |
Thread-safe Django cache backend for pylibmc. | |
Tested on Python 2.6, should work on 2.5 as well. | |
Use it by setting CACHE_BACKEND in settings.py, e.g.: | |
CACHE_BACKEND = 'projdir.utils.pylibmcd://127.0.0.1:11211/' | |
And here's how to properly install pylibmcd in Ubuntu for mod_wsgi: |
This file contains 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 fabfile automates deployment of and moving data between Django apps | |
in development (devel), staging (stage), and production (live) | |
environments. | |
Use it as: | |
fab -H user@host:port deploy:stage | |
Requirements |
This file contains 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
*.pyc | |
*.swp | |
timetrack_conf.py |
This file contains 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
# coding: utf-8 | |
""" | |
To my great disappointment, Dustin Sallings's otherwise excellent py-github | |
does not work with repositories that have / in branch names, as this breaks | |
the XML-based parser. Unfortunately, many projects use / for simulating | |
directory structure. See e.g. | |
http://github.com/api/v2/xml/repos/show/django/django/branches | |
for the error. | |
What follows is a comprehensive interface to the GitHub JSON API that does not |
This file contains 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
""" | |
Example of chaining descriptors and sharing a cache between them. | |
""" | |
class LeafDescriptor(object): | |
def __get__(self, obj, cls): | |
return obj.parent._cache | |
class Bar(object): | |
baz = LeafDescriptor() |
This file contains 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 | |
from django.core.management.base import CommandError, LabelCommand | |
from django.utils.datastructures import SortedDict | |
from django_commands.utils import parse_apps_and_models | |
class Command(LabelCommand): | |
args = '<upload-path> <appname.Model> [appname.Model] ...>' | |
help = ("Cleans orphaned file field files from <upload-path>.\n" | |
"'Orphaned' is defined as existing under <upload-path> " |
This file contains 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
class LazyCachedDescriptor(object): | |
def __init__(self, fn, *args, **kwargs): | |
self.cache = None | |
self.fn = fn | |
self.args = args | |
self.kwargs = kwargs | |
def __get__(self, obj, objtype): | |
if self.cache is None: | |
result = [self.fn(*self.args, **self.kwargs)] |
This file contains 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
#include <algorithm> | |
#include <vector> | |
#include <iostream> | |
// for C++03 | |
#include <boost/bind.hpp> | |
#include <boost/foreach.hpp> | |
#define foreach BOOST_FOREACH | |
using namespace std; |
OlderNewer