本文整理汇总了Python中south.signals.post_migrate.connect函数的典型用法代码示例。如果您正苦于以下问题:Python connect函数的具体用法?Python connect怎么用?Python connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: patch
def patch():
global PATCHED
post_migrate.connect(_invalidate_on_migration)
if 'south' in settings.INSTALLED_APPS:
from south.signals import post_migrate as south_post_migrate
south_post_migrate.connect(_invalidate_on_migration)
_patch_cursor()
_patch_atomic()
_patch_orm()
PATCHED = True
开发者ID:dan-passaro,项目名称:django-cachalot,代码行数:13,代码来源:monkey_patch.py
示例2: post_migrate
continue
role.save()
role.permission_flags.add(permissionflag)
role.save()
if verbosity >= 2:
print "Created new role '%s' for group '%s' and assigned permission '%s'" % (rolename, group.name, permissionflag.name)
# handle both post_syncdb and post_migrate (if south is used)
def syncdb_compat(app_label, handler=None, *args, **kwargs):
if app_label=='community':
app = get_app(app_label)
models = get_models(app)
handler(app=app, created_models=models, verbosity=1, **kwargs)
def syncdb_compat_init_data(app, *args, **kwargs):
syncdb_compat(app, handler=init_data, *args, **kwargs)
def syncdb_compat_create_permission_flags(app, *args, **kwargs):
syncdb_compat(app, handler=create_permission_flags, *args, **kwargs)
if 'south' in settings.INSTALLED_APPS:
from south.signals import post_migrate
post_migrate.connect(syncdb_compat_init_data, dispatch_uid="communitytools.sphenecoll.sphene.community.management")
post_migrate.connect(syncdb_compat_create_permission_flags)
else:
from django.db.models.signals import post_syncdb
post_syncdb.connect(init_data, sender=models, dispatch_uid="communitytools.sphenecoll.sphene.community.management")
post_syncdb.connect(create_permission_flags)
开发者ID:hmm,项目名称:sct-communitytools,代码行数:30,代码来源:__init__.py
示例3: update_permissions
from south.signals import post_migrate
def update_permissions(**kwargs):
import sys
sys.stdout.write("If there are new content types or permissions added, remember to run-> labgeeks update_permissions\n\n")
post_migrate.connect(update_permissions)
开发者ID:swansong,项目名称:labgeeks-hermes,代码行数:8,代码来源:__init__.py
示例4: SiteSettings
perm, created = Permission.objects.get_or_create(codename='can_view', name='Can View Users', content_type=ct)
group, created = Group.objects.get_or_create(name='Volunteer')
if created:
p = Permission.objects.get(codename='add_userevent')
group.permissions.add(p)
group, created = Group.objects.get_or_create(name='Org_Admin')
if created:
p = Permission.objects.get(codename='add_organization')
group.permissions.add(p)
group, created = Group.objects.get_or_create(name='NHS_Admin')
if created:
p = Permission.objects.get(codename='can_view')
group.permissions.add(p)
if not SiteSettings.objects.exists():
settings = SiteSettings(site=Site.objects.get(pk=1), candidate_leadership_hours=50,
candidate_service_hours=100, member_service_hours=6).save()
def create_userprof(sender, instance, created, **kwargs):
"""for when the user is created on the first syncdb"""
if created and instance.is_superuser:
try:
up = instance.user_profile
except ObjectDoesNotExist:
UserProfile(user=instance, email_valid=True, grad_class=2000, membership_status='MEM').save()
#post_migrate.connect(add_user_permissions, sender=auth_models)
post_migrate.connect(add_groups)
post_save.connect(create_userprof, sender=User, dispatch_uid="create_userprof")
开发者ID:mattr555,项目名称:AtYourService-school,代码行数:29,代码来源:__init__.py
示例5: update_permissions_after_migration
# register a signal do update permissions every migration.
# This is based on app django_extensions update_permissions command
from south.signals import post_migrate
def update_permissions_after_migration(app,**kwargs):
"""
Update app permission just after every migration.
This is based on app django_extensions update_permissions management command.
"""
import settings
from django.db.models import get_app, get_models
from django.contrib.auth.management import create_permissions
create_permissions(get_app(app), get_models(), 2 if settings.DEBUG else 0)
post_migrate.connect(update_permissions_after_migration)
开发者ID:akosiaris,项目名称:ganetimgr,代码行数:16,代码来源:__init__.py
示例6:
# coding: utf-8
from south.signals import post_migrate, pre_migrate
from new_django_project._lib.db import load_customized_sql
pre_migrate.connect(load_customized_sql(name='pre_migrate'), weak=False)
post_migrate.connect(load_customized_sql(name='post_migrate'), weak=False)
开发者ID:torchingloom,项目名称:new_django_project,代码行数:8,代码来源:__init__.py
示例7: sync_create_groups
# Remove all social auth associations
user.social_auth.all().delete()
@receiver(post_syncdb)
def sync_create_groups(sender, app, **kwargs):
'''
Create groups on syncdb.
'''
if (app == 'accounts'
or getattr(app, '__name__', '') == 'weblate.accounts.models'):
create_groups(False)
if 'south' in settings.INSTALLED_APPS:
from south.signals import post_migrate
post_migrate.connect(sync_create_groups)
@receiver(post_save, sender=User)
def create_profile_callback(sender, instance, created=False, **kwargs):
'''
Automatically adds user to Users group.
'''
if created:
# Add user to Users group if it exists
try:
group = Group.objects.get(name='Users')
instance.groups.add(group)
except Group.DoesNotExist:
pass
开发者ID:JDGrimes,项目名称:weblate,代码行数:30,代码来源:models.py
示例8: _migrate_perms
def _migrate_perms(*args, **kwargs):
"""
Ensure that all declared permissions on a model have been installed once
South migrations have been run.
"""
import sys
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.db.models import get_app, get_models
for model in get_models(get_app(kwargs['app'])):
content_type = ContentType.objects.get_for_model(model)
for codename, name in model._meta.permissions:
perm, created = Permission.objects.get_or_create(
content_type=content_type,
codename=codename,
defaults={
'name': name
}
)
if created:
sys.stdout.write(
"Installed new permission {app_label}.{codename}\n".format(
app_label=model._meta.app_label,
codename=codename
)
)
post_migrate.connect(_migrate_perms)
开发者ID:ColinBarnwell,项目名称:django-hairdresser,代码行数:29,代码来源:migrate_south.py
示例9: get_preindex_plugins
sync_docs.copy_designs(
db=self.db(app_label),
design_name=app_label,
temp=temp,
delete=delete,
)
def get_preindex_plugins():
return PREINDEX_PLUGINS.values()
def catch_signal(app, **kwargs):
"""Function used by syncdb signal"""
app_name = app.__name__.rsplit('.', 1)[0]
app_label = app_name.split('.')[-1]
if app_label in PREINDEX_PLUGINS:
PREINDEX_PLUGINS[app_label].sync_design_docs()
signals.post_syncdb.connect(catch_signal)
# and totally unrelatedly...
def sync_south_app(app, **kwargs):
syncdb(get_app(app), None, **kwargs)
post_migrate.connect(sync_south_app)
开发者ID:bradmerlin,项目名称:commcare-hq,代码行数:30,代码来源:__init__.py
示例10: post_save_handler
if os.path.isfile(theme_info_file):
config = ConfigParser.ConfigParser()
config.read(theme_info_file)
default = ConfigParser.DEFAULTSECT
theme_name = config.get(default, 'name', self.directory_name)
theme_description = config.get(default, 'description', '')
else:
theme_name = self.directory_name
theme_description = ''
self.name = theme_name
self.description = theme_description
if commit:
self.save()
def post_save_handler(sender, instance, **kwargs):
if instance.active:
for theme in Theme.objects.filter(active=True).exclude(id=instance.id):
theme.active = False
theme.save()
Theme.objects.clear_cache()
def check_for_themes(sender, **kwargs):
from merengue.theming.checker import check_themes
check_themes()
signals.post_save.connect(post_save_handler, sender=Theme)
post_migrate.connect(check_for_themes)
开发者ID:creativify,项目名称:merengueproj,代码行数:30,代码来源:models.py
示例11: update_contenttypes
# coding:utf-8
from django.contrib.contenttypes.models import ContentType
from django.db.models import signals
from django.utils.encoding import smart_unicode
from django.conf import settings
def update_contenttypes(app, **kwargs):
#No post_syncdb o app é um object, já no post_migrate é uma string
if not isinstance(app, str):
app = app.__name__.split('.')[-2]
for ct in ContentType.objects.filter(app_label=app):
try:
name = smart_unicode(ct.model_class()._meta.verbose_name_raw)
if ct.name != name:
print "Updating ContentType's name: '%s' -> '%s'" % (ct.name, name)
ct.name=name
ct.save()
except: pass
# Se tiver a aplicação south no INSTALLED_APPS,
# ele conecta o update_contenttypes ao post_migrate
if 'south' in settings.INSTALLED_APPS:
from south.signals import post_migrate
post_migrate.connect(update_contenttypes)
signals.post_syncdb.connect(update_contenttypes)
开发者ID:AndreLobato,项目名称:raizcidadanista,代码行数:27,代码来源:management.py
示例12: ensure_auth_objects
password='',
first_name='Guest',
last_name='McGuesterson',
)
user.set_unusable_password()
user.save()
member = Member.objects.get(user=user)
member.hidden = True
member.save()
else:
user = User.objects.get(id=settings.ANONYMOUS_USER_ID)
try:
member = user.member
except Member.DoesNotExist:
user.member, created = Member.objects.get_or_create(user=user)
user.save()
return user
post_save.connect(create_member, sender=AnonymousUser)
post_save.connect(create_rank, sender=AuthenticatedUserGroup)
def ensure_auth_objects(*args, **kwargs):
try:
get_anonymous_user()
get_authenticated_user_group()
except:
pass
post_migrate.connect(ensure_auth_objects)
post_syncdb.connect(ensure_auth_objects)
开发者ID:SYNHAK,项目名称:spiff,代码行数:30,代码来源:models.py
示例13: __unicode__
callback = models.TextField()
def __unicode__(self):
return "Achievement(%s, %s)" % (self.name, self.bonus)
class UserAchievement(models.Model):
user = models.ForeignKey(User)
achievement = models.ForeignKey(Achievement, related_name="userachievements")
registered_at = models.DateTimeField(auto_now_add=True)
class AchievementEngineConf(AppConf):
""" Configuration class used by Django AppConf to ease the setup"""
USE_CELERY = False
CLASSES = []
class Meta:
prefix = 'achievement'
#def configure_classes(self, value):
# pass
# connect to the end of the syncdb command signal to reload achievements at that time.
if 'south' in settings.INSTALLED_APPS:
from south.signals import post_migrate
post_migrate.connect(load_classes)
else:
from django.db.models.signals import post_syncdb
post_syncdb.connect(load_classes)
开发者ID:lostcitizen,项目名称:django-achievements,代码行数:30,代码来源:models.py
示例14: map
from django.db import connection
from south import migration
from south.signals import post_migrate
from boris import reporting
# Get a list of all the apps that use migrations.
APPS_TO_WAIT_FOR = map(methodcaller('app_label'), migration.all_migrations())
def install_views(app, **kwargs):
global APPS_TO_WAIT_FOR
APPS_TO_WAIT_FOR.remove(app)
if len(APPS_TO_WAIT_FOR) == 0:
print "Installing reporting views ..."
cursor = connection.cursor()
sql_file = open(join(dirname(reporting.__file__), 'sql', 'reporting-views.mysql.sql'), 'r')
try:
cursor.execute(sql_file.read())
finally:
sql_file.close()
post_migrate.connect(install_views)
开发者ID:jinkt,项目名称:BorIS,代码行数:30,代码来源:install_views.py
示例15: isinstance
auth = resource._meta.authorization
content_type = ContentType.objects.get_for_model(resource._meta.queryset.model)
if isinstance(auth, SpiffAuthorization):
conditions = auth.conditions()
operations = auth.operations()
if len(conditions) == 0:
conditions = (None,)
for condition in conditions:
for operation in operations:
# build our permission slug
if condition:
codename = "%s_%s_%s" % (operation[0], condition[0], content_type.model)
name = "Can %s %s, when %s" % (operation[1], content_type.name,
condition[1])
else:
codename = "%s_%s" % (operation[1], content_type.model)
name = "Can %s %s" % (operation[1], content_type.name)
# if it doesn't exist..
if not Permission.objects.filter(content_type=content_type, codename=codename):
# add it
Permission.objects.create(content_type=content_type,
codename=codename,
name=name[:49])
funcLog().debug("Created permission %s.%s (%s)", content_type.app_label, codename, name)
# check for all our view permissions after a syncdb
post_migrate.connect(add_resource_permissions)
post_syncdb.connect(add_resource_permissions)
开发者ID:SYNHAK,项目名称:spiff,代码行数:30,代码来源:models.py
示例16: active_plugin_with_deps
for plugin_dir in settings.REQUIRED_PLUGINS:
active_plugin_with_deps(plugin_dir)
# populate menu
from merengue.section.models import Menu
name_attr = get_fallback_fieldname('name')
attrs = {name_attr: 'Portal menu', 'slug': settings.MENU_PORTAL_SLUG}
try:
portal_menu = Menu.objects.get(slug=settings.MENU_PORTAL_SLUG)
except Menu.DoesNotExist:
# creating portal menu if does not exist
portal_menu = Menu.objects.create(**attrs)
for lang_code, lang_text in settings.LANGUAGES:
setattr(portal_menu, 'name_%s' % lang_code, ugettext('portal menu'))
portal_menu.save()
def active_plugin_with_deps(plugin_dir):
""" active plugins with its dependences """
from merengue.pluggable.utils import install_plugin
registered_plugin = register_plugin(plugin_dir)
plugin = registered_plugin.get_registry_item()
for dep in getattr(plugin, 'required_plugins', []):
active_plugin_with_deps(dep)
registered_plugin.installed = True
registered_plugin.active = True
registered_plugin.save()
install_plugin(registered_plugin)
post_migrate.connect(active_default_plugins)
开发者ID:creativify,项目名称:merengueproj,代码行数:30,代码来源:__init__.py
示例17: _
_('Event Added'),
_('An event has been added'))
notification.create_notice_type(
'event_edited',
_('Event Edited'),
_('An event has been edited'))
notification.create_notice_type(
'event_deleted',
_('Event Deleted'),
_('An event has been deleted'))
notification.create_notice_type(
'event_registration_confirmation',
_('Event Registration Confirmation'),
_('The email you receive confirming your registration'))
notification.create_notice_type(
'event_registration_cancelled',
_('Event Registration Cancelled'),
_('Notify administrators that someone has cancelled their event registration'))
notification.create_notice_type(
'event_registration_end_recap',
_('Recap of end of event registration'),
_('Notify administrators that registration for the event has ended.'))
post_syncdb.connect(create_notice_types, sender=notification)
post_migrate.connect(create_notice_types, sender=notification)
开发者ID:githubber,项目名称:tendenci,代码行数:30,代码来源:__init__.py
示例18: map
from operator import methodcaller
from django.core.management import call_command
from south.signals import post_migrate
from south import migration
# Get a list of all the apps that use migrations.
APPS_TO_WAIT_FOR = map(methodcaller('app_label'), migration.all_migrations())
def load_static_data(app, **kwargs):
global APPS_TO_WAIT_FOR
APPS_TO_WAIT_FOR.remove(app)
if len(APPS_TO_WAIT_FOR) == 0:
print "Loading static fixtures..."
call_command('loaddata', 'groups')
post_migrate.connect(load_static_data)
开发者ID:jinkt,项目名称:BorIS,代码行数:23,代码来源:load_static_migrations.py
示例19: create_admin_group
def create_admin_group(app, **kwargs):
"""\
Create a basic admin group with permissions for managing basic autotest
objects.
"""
print "Creatin/updating Basic admin group"
admin_group, created = auth.models.Group.objects.get_or_create(
name=BASIC_ADMIN)
admin_group.save() # must save before adding permissions
PermissionModel = auth.models.Permission
have_permissions = list(admin_group.permissions.all())
for model_name in ('host', 'label', 'test', 'aclgroup', 'profiler',
'atomicgroup'):
for permission_type in ('add', 'change', 'delete'):
codename = permission_type + '_' + model_name
permissions = list(PermissionModel.objects.filter(
codename=codename))
if len(permissions) == 0:
print ' No permission ' + codename
continue
for permission in permissions:
if permission not in have_permissions:
print ' Adding permission ' + codename
admin_group.permissions.add(permission)
if created:
print 'Created group "%s"' % BASIC_ADMIN
else:
print 'Group "%s" already exists' % BASIC_ADMIN
post_migrate.connect(create_admin_group)
开发者ID:HMTech,项目名称:autotest,代码行数:30,代码来源:management.py
示例20: object_listener
from django.contrib.contenttypes.models import ContentType
from south.signals import post_migrate
from .models import SignalProcessor
def object_listener(sender, **kwargs):
if sender is SignalProcessor or kwargs.get('raw', False):
return
action = 'D' if not 'created' in kwargs else 'C' if kwargs[
'created'] else 'U'
try:
ct = ContentType.objects.get_for_model(sender)
SignalProcessor(app_name=ct.app_label,
model_name=ct.model,
action=action,
object_pk=kwargs['instance'].pk).save()
except DatabaseError:
pass
pass
def load_fixtures(sender, **kwargs):
from django.core.management import call_command
call_command("loaddata", "initial_data.json")
post_save.connect(object_listener)
post_delete.connect(object_listener)
post_migrate.connect(load_fixtures)
开发者ID:Anc813,项目名称:cctest,代码行数:30,代码来源:listeners.py
注:本文中的south.signals.post_migrate.connect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论