def sync_library(token=None, content_type_to_sync=None): """ Synchronizes the ACE library with the local content. """ from djax.models import ContentSyncLock if ContentSyncLock.objects.all().exists(): return False if not token: token = uuid.uuid4().hex lock = ContentSyncLock.objects.create(token=token) # ensure registry loaded build_registry() if content_type_to_sync: log.info("Pushing %s content to ACE library." % content_type_to_sync) try: content_type = content_registry[content_type_to_sync] sync_library_to_content_type(content_type_to_sync) except KeyError: log.error("%s is not in the content registry." % content_type_to_sync) else: for content_type in content_registry.keys(): log.info("Pushing %s content to ACE library." % content_type) sync_library_to_content_type(content_type) lock.delete() return True
def sync_content(token=None, content_type_to_sync=None): """ Synchronizes the local models with Axilent content. """ from djax.models import ContentSyncLock if ContentSyncLock.objects.all().exists(): return False # already sync locked if not token: token = uuid.uuid4().hex lock = ContentSyncLock.objects.create(token=token) # ensure content registry loaded build_registry() if content_type_to_sync: log.info("Syncing %s." % content_type_to_sync) try: content_type = content_registry[content_type_to_sync] sync_content_type(content_type_to_sync) except KeyError: log.error("%s is not in the content registry." % content_type_to_sync) else: for content_type in content_registry.keys(): sync_content_type(content_type) lock.delete() return True # sync occured