View djangosessionjson.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
"""Session table that stores session data as JSON | |
Works similarily as :mod:`django.contrib.sessions.backends.db` | |
To use this add to your settings.py:: | |
SESSION_ENGINE = 'djangosessionjson' | |
""" |
View django_session.php
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
<?PHP | |
/* | |
DjangoUser object to Joomla in PHP. | |
(Can be adapted easily to other PHP frameworks) | |
Usage:: | |
$user =& DjangoUser::getUser(); | |
if ($user && $user->hasPerm("polls.can_vote")) { |
View objectperms.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
from django.conf import settings | |
class ObjectPermBackend(object): | |
"""Simple object permission backend that passesthrough the has_perm calls | |
to the object. | |
""" | |
supports_object_permissions = True | |
supports_anonymous_user = True | |
View django.fcgi.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
#!/usr/bin/python | |
import sys, os | |
# Add a custom Python path. | |
THE_SITE = "mysite" | |
PYTHONPATH = "/var/www/mysite.example.com/django-fcgi/pythonpath/" | |
# Following is inferred from above | |
THE_DIR = PYTHONPATH + THE_SITE | |
DJANGO_PATH = PYTHONPATH + "django" |
View keyboardlistener.cs
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
using System; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
using System.Runtime.CompilerServices; | |
using System.Windows.Input; | |
using System.Windows.Threading; | |
using System.Collections.Generic; | |
namespace Ownskit.Utils | |
{ |
View sitecache.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
"""Cache of Site related settings | |
Site IDs and urlconfs are such that are testd on *all* requests thus they need | |
to be cached. | |
""" | |
from django.conf import settings | |
from django.contrib.sites.models import Site |
View multisitedmiddleware.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
"""Allows serving multiple sites per Django instance | |
""" | |
from django.utils.cache import patch_vary_headers | |
from sitecache import get_site_id, get_urlconf | |
class MultiSitedMiddleware: |
View multisettings.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
"""Multisite - individual site for request""" | |
from django.conf import settings | |
from threading import local | |
def make_tls_property(default=None): | |
"""Creates a class-wide instance property with a thread-specific value.""" | |
class TLSProperty(object): | |
def __init__(self): | |
self.local = local() |
View forbiddenmixintests.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
from django.conf.urls.defaults import * #@UnusedWildImport | |
from django.contrib.auth.models import Permission, User | |
from django.http import HttpResponse | |
from django.test import TestCase | |
from django.test.client import Client | |
from django.views.generic.base import View | |
class ForbiddenMixin(object): | |
"""ForbiddenMixin""" | |
View forbiddenviewtests.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
# REPLACE urls parameter of the TestCase and create test.html in order to test | |
# this | |
from django.conf.urls.defaults import * #@UnusedWildImport | |
from django.contrib.auth.models import Permission, User | |
from django.http import HttpResponse | |
from django.test import TestCase | |
from django.test.client import Client | |
from django.views.generic.base import View, TemplateView |
OlderNewer