Stephen McDonald stephenmcd

View django_browsable_email_backend.py
1 2 3 4 5 6 7 8 9 10
from tempfile import NamedTemporaryFile
import webbrowser
from django.core.mail import EmailMultiAlternatives
 
 
class BrowsableEmailBackend(BaseEmailBackend):
 
def send_messages(self, email_messages):
for message in email_messages:
for body, content_type in getattr(message, "alternatives", []):
View hardcoded_url_field.py
1 2 3 4 5 6 7 8 9 10
from rest_framework import serializers
 
class HyperlinkedIdentityField(serializers.HyperlinkedIdentityField):
"""
This is a performance wrapper for HyperlinkedIdentityField.
We save a ton of time by not calling reverse potentially
thousands of times per request.
"""
 
def __init__(self, *args, **kwargs):
View metrics.py
1 2 3 4 5 6 7 8 9 10
import os
import time
 
from django.conf import settings
from django.contrib.auth.models import User
from django.core.management.base import NoArgsCommand
from django.db.models import Sum
import psutil
import redis
import statsd
View rtl_field.py
1 2 3 4 5 6 7 8 9
from unicodedata import bidirectional
from django.template.defaultfilters import striptags
from rest_framework import serializers
 
class RTLField(serializers.BooleanField):
 
def __init__(self, *args, **kwargs):
kwargs.setdefault("read_only", True)
super(RTLField, self).__init__(*args, **kwargs)
View linkedin_viewers_rss.py
1 2 3 4 5 6 7 8
 
import cgi
import getpass
import mechanize
import json
import SimpleHTTPServer
import SocketServer
import uuid
View gist:7441463
1 2 3 4 5 6 7 8 9 10
diff --git a/django/forms/models.py b/django/forms/models.py
index 6934925..4713a45 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -82,7 +82,9 @@ def save_instance(form, instance, fields=None, fail_message='saved',
# Wrap up the saving of m2m data as a function.
def save_m2m():
cleaned_data = form.cleaned_data
- for f in opts.many_to_many:
+ for f in (opts.virtual_fields + opts.many_to_many):
View deep_force_unicode.py
1 2 3 4 5 6 7 8 9 10
from django.utils.encoding import force_unicode
from django.utils.functional import Promise
 
def deep_force_unicode(value):
"""
Recursively call force_unicode on value.
"""
if isinstance(value (list, tuple, set)):
value = type(value)(map(deep_force_unicode, value))
elif isinstance(value, dict):
View cache_stats.py
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env python
 
import os
import sys
import urllib
 
name, url, num = sys.argv[1:]
print name, url, num
first = not os.path.exists("output.csv")
f = open("output.csv", "a")
View trans_stats.py
1 2 3 4 5 6 7 8 9 10
import os
 
translators = []
languages = []
 
for root, dirs, files in os.walk("mezz_current/mezzanine"):
if root.endswith("locale"):
languages.extend(dirs)
for name in files:
if name == "django.po":
View requirements_report.py
1 2 3 4 5 6 7 8 9
#!/usr/bin/env python
"""
Given the current directory contains multiple repositories, each with a
requirements/project.txt file, build a report of all requirements.
"""
 
import os
 
reqs = {}
Something went wrong with that request. Please try again.