Added special case handling for DjangoZoom, which executes collectstatic
management command before executing syncdb first to create the db structure. Handles issue #10
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import pickle
|
||||
import json
|
||||
|
||||
try:
|
||||
from psycopg2 import OperationalError
|
||||
except ImportError:
|
||||
class OperationalError(Exception):
|
||||
pass
|
||||
|
||||
from django.db import transaction
|
||||
from django.db.utils import DatabaseError
|
||||
#from django.utils import simplejson
|
||||
from django.core import serializers
|
||||
@@ -10,7 +17,7 @@ from django.db import models
|
||||
from history.models import HistoryType, History
|
||||
from history.runtime_data import history_types_dict
|
||||
|
||||
|
||||
@transaction.commit_manually
|
||||
def register_history_type(history_type_dict):
|
||||
namespace = history_type_dict['namespace']
|
||||
name = history_type_dict['name']
|
||||
@@ -29,8 +36,14 @@ def register_history_type(history_type_dict):
|
||||
'expressions': history_type_dict.get('expressions', []),
|
||||
}
|
||||
except DatabaseError:
|
||||
transaction.rollback()
|
||||
# Special case for ./manage.py syncdb
|
||||
pass
|
||||
except OperationalError:
|
||||
transaction.rollback()
|
||||
# Special for DjangoZoom, which executes collectstatic media
|
||||
# doing syncdb and creating the database tables
|
||||
else:
|
||||
transaction.commit()
|
||||
|
||||
|
||||
def create_history(history_type_dict, source_object=None, data=None):
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
try:
|
||||
from psycopg2 import OperationalError
|
||||
except ImportError:
|
||||
class OperationalError(Exception):
|
||||
pass
|
||||
|
||||
from django.db import transaction
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext
|
||||
from django.db.utils import DatabaseError
|
||||
@@ -65,14 +72,22 @@ register_tool(all_document_ocr_cleanup, namespace='ocr', title=_(u'OCR'))
|
||||
#Menus
|
||||
register_top_menu('ocr', link={'text': _('OCR'), 'famfam': 'hourglass', 'view': 'queue_document_list'}, children_path_regex=[r'^ocr/'])
|
||||
|
||||
@transaction.commit_manually
|
||||
def create_default_queue():
|
||||
try:
|
||||
default_queue, created = DocumentQueue.objects.get_or_create(name='default')
|
||||
if created:
|
||||
default_queue.label = ugettext(u'Default')
|
||||
default_queue.save()
|
||||
except DatabaseError:
|
||||
#syncdb
|
||||
pass
|
||||
transaction.rollback()
|
||||
# Special case for ./manage.py syncdb
|
||||
except OperationalError:
|
||||
transaction.rollback()
|
||||
# Special for DjangoZoom, which executes collectstatic media
|
||||
# doing syncdb and creating the database tables
|
||||
else:
|
||||
transaction.commit()
|
||||
|
||||
|
||||
def document_post_save(sender, instance, **kwargs):
|
||||
@@ -82,4 +97,6 @@ def document_post_save(sender, instance, **kwargs):
|
||||
|
||||
post_save.connect(document_post_save, sender=Document)
|
||||
|
||||
create_default_queue()
|
||||
|
||||
register_interval_job('task_process_document_queues', _(u'Checks the OCR queue for pending documents.'), task_process_document_queues, seconds=QUEUE_PROCESSING_INTERVAL)
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
try:
|
||||
from psycopg2 import OperationalError
|
||||
except ImportError:
|
||||
class OperationalError(Exception):
|
||||
pass
|
||||
|
||||
from django.db import transaction
|
||||
from django.db.utils import DatabaseError
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import ugettext
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.db import transaction
|
||||
|
||||
from permissions import PERMISSION_ROLE_VIEW, PERMISSION_ROLE_EDIT, \
|
||||
PERMISSION_ROLE_CREATE, PERMISSION_ROLE_DELETE, \
|
||||
@@ -30,6 +36,10 @@ def register_permission(permission):
|
||||
except DatabaseError:
|
||||
transaction.rollback()
|
||||
# Special case for ./manage.py syncdb
|
||||
except OperationalError:
|
||||
transaction.rollback()
|
||||
# Special for DjangoZoom, which executes collectstatic media
|
||||
# doing syncdb and creating the database tables
|
||||
else:
|
||||
transaction.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user