|
Revision 8223, 0.5 kB
(checked in by jacob, 4 months ago)
|
Major refactoring of django.dispatch with an eye towards speed. The net result is that signals are up to 90% faster.
Though some attempts and backwards-compatibility were made, speed trumped compatibility. Thus, as usual, check BackwardsIncompatibleChanges for the complete list of backwards-incompatible changes.
Thanks to Jeremy Dunck and Keith Busell for the bulk of the work; some ideas from Brian Herring's previous work (refs #4561) were incorporated.
Documentation is, sigh, still forthcoming.
Fixes #6814 and #3951 (with the new dispatch_uid argument to connect).
|
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
""" |
|---|
| 2 |
Creates the default Site object. |
|---|
| 3 |
""" |
|---|
| 4 |
|
|---|
| 5 |
from django.db.models import signals |
|---|
| 6 |
from django.contrib.sites.models import Site |
|---|
| 7 |
from django.contrib.sites import models as site_app |
|---|
| 8 |
|
|---|
| 9 |
def create_default_site(app, created_models, verbosity, **kwargs): |
|---|
| 10 |
if Site in created_models: |
|---|
| 11 |
if verbosity >= 2: |
|---|
| 12 |
print "Creating example.com Site object" |
|---|
| 13 |
s = Site(domain="example.com", name="example.com") |
|---|
| 14 |
s.save() |
|---|
| 15 |
Site.objects.clear_cache() |
|---|
| 16 |
|
|---|
| 17 |
signals.post_syncdb.connect(create_default_site, sender=site_app) |
|---|