Skip to content

Instantly share code, notes, and snippets.

View beniwohli's full-sized avatar

Benjamin Wohlwend beniwohli

View GitHub Profile
$ ./manage.py syncdb
/var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
Syncing...
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
from django.conf import settings
from django.utils.translation import string_concat, ugettext_lazy
from haystack import indexes, site
from cms.models.managers import PageManager
from cms.models.pagemodel import Page
def page_index_factory(lang, lang_name):
if isinstance(lang_name, basestring):
diff --git a/threadedcomments/forms.py b/threadedcomments/forms.py
index 4f64699..cdcd4c8 100644
--- a/threadedcomments/forms.py
+++ b/threadedcomments/forms.py
@@ -16,6 +16,8 @@ class ThreadedCommentForm(CommentForm):
initial.update({'parent': self.parent})
super(ThreadedCommentForm, self).__init__(target_object, data=data,
initial=initial)
+ self.fields.keyOrder.remove('title')
+ self.fields.keyOrder.insert(self.fields.keyOrder.index('comment'), 'title')
diff --git a/cms/models/__init__.py b/cms/models/__init__.py
index bca24e6..557e1cf 100644
--- a/cms/models/__init__.py
+++ b/cms/models/__init__.py
@@ -35,7 +35,7 @@ def monkeypatch_reverse():
url = ''
i18n = 'cms.middleware.multilingual.MultilingualURLMiddleware' in settings.MIDDLEWARE_CLASSES
lang = None
- if viewname.split(":")[0] in dict(settings.LANGUAGES).keys():
+ if isinstance(viewname, basestring) and viewname.split(":")[0] in dict(settings.LANGUAGES).keys():
Traceback:
File "/var/www/projects/abc/src/django/django/core/handlers/base.py" in get_response
101. response = callback(request, *callback_args, **callback_kwargs)
File "/var/www/projects/abc/src/django-cms/cms/utils/__init__.py" in _dec
34. return render_to_response(t, context, context_instance=RequestContext(request))
File "/var/www/projects/abc/src/django/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/var/www/projects/abc/src/django/django/template/loader.py" in render_to_string
173. return t.render(context_instance)
File "/var/www/projects/abc/src/django/django/test/utils.py" in instrumented_test_render
@beniwohli
beniwohli / greek_alphabet.py
Created January 4, 2011 19:29
A Python dictionary mapping the Unicode codes of the greek alphabet to their names
greek_alphabet = {
u'\u0391': 'Alpha',
u'\u0392': 'Beta',
u'\u0393': 'Gamma',
u'\u0394': 'Delta',
u'\u0395': 'Epsilon',
u'\u0396': 'Zeta',
u'\u0397': 'Eta',
u'\u0398': 'Theta',
u'\u0399': 'Iota',
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xsl:template match="/charlist">
<xsl:text>
unicode_to_latex = {
</xsl:text>
<xsl:for-each select="character">
@beniwohli
beniwohli / unicode_to_latex.py
Created January 27, 2011 14:08
Map to convert unicode characters to their respective LaTeX representation
# original XML at http://www.w3.org/Math/characters/unicode.xml
# XSL for conversion: https://gist.github.com/798546
unicode_to_latex = {
u"\u0020": "\\space ",
u"\u0023": "\\#",
u"\u0024": "\\textdollar ",
u"\u0025": "\\%",
u"\u0026": "\\&amp;",
@beniwohli
beniwohli / gist:1173019
Created August 26, 2011 09:04
Sentry Example Config
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
@beniwohli
beniwohli / fill_translations.py
Created February 2, 2012 09:03
Django management command to copy translations from one po file into another
# -*- coding: utf-8 -*-
import os
from optparse import make_option
import polib
from django.core.management import CommandError
from django.core.management.base import AppCommand