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 pickle
|
||||||
import json
|
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.db.utils import DatabaseError
|
||||||
#from django.utils import simplejson
|
#from django.utils import simplejson
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
@@ -10,7 +17,7 @@ from django.db import models
|
|||||||
from history.models import HistoryType, History
|
from history.models import HistoryType, History
|
||||||
from history.runtime_data import history_types_dict
|
from history.runtime_data import history_types_dict
|
||||||
|
|
||||||
|
@transaction.commit_manually
|
||||||
def register_history_type(history_type_dict):
|
def register_history_type(history_type_dict):
|
||||||
namespace = history_type_dict['namespace']
|
namespace = history_type_dict['namespace']
|
||||||
name = history_type_dict['name']
|
name = history_type_dict['name']
|
||||||
@@ -29,8 +36,14 @@ def register_history_type(history_type_dict):
|
|||||||
'expressions': history_type_dict.get('expressions', []),
|
'expressions': history_type_dict.get('expressions', []),
|
||||||
}
|
}
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
#Special case for ./manage.py syncdb
|
transaction.rollback()
|
||||||
pass
|
# 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 create_history(history_type_dict, source_object=None, data=None):
|
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_lazy as _
|
||||||
from django.utils.translation import ugettext
|
from django.utils.translation import ugettext
|
||||||
from django.db.utils import DatabaseError
|
from django.db.utils import DatabaseError
|
||||||
@@ -65,14 +72,22 @@ register_tool(all_document_ocr_cleanup, namespace='ocr', title=_(u'OCR'))
|
|||||||
#Menus
|
#Menus
|
||||||
register_top_menu('ocr', link={'text': _('OCR'), 'famfam': 'hourglass', 'view': 'queue_document_list'}, children_path_regex=[r'^ocr/'])
|
register_top_menu('ocr', link={'text': _('OCR'), 'famfam': 'hourglass', 'view': 'queue_document_list'}, children_path_regex=[r'^ocr/'])
|
||||||
|
|
||||||
try:
|
@transaction.commit_manually
|
||||||
|
def create_default_queue():
|
||||||
|
try:
|
||||||
default_queue, created = DocumentQueue.objects.get_or_create(name='default')
|
default_queue, created = DocumentQueue.objects.get_or_create(name='default')
|
||||||
if created:
|
if created:
|
||||||
default_queue.label = ugettext(u'Default')
|
default_queue.label = ugettext(u'Default')
|
||||||
default_queue.save()
|
default_queue.save()
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
#syncdb
|
transaction.rollback()
|
||||||
pass
|
# 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):
|
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)
|
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)
|
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.db.utils import DatabaseError
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.utils.translation import ugettext
|
from django.utils.translation import ugettext
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.db import transaction
|
|
||||||
|
|
||||||
from permissions import PERMISSION_ROLE_VIEW, PERMISSION_ROLE_EDIT, \
|
from permissions import PERMISSION_ROLE_VIEW, PERMISSION_ROLE_EDIT, \
|
||||||
PERMISSION_ROLE_CREATE, PERMISSION_ROLE_DELETE, \
|
PERMISSION_ROLE_CREATE, PERMISSION_ROLE_DELETE, \
|
||||||
@@ -29,7 +35,11 @@ def register_permission(permission):
|
|||||||
permission_obj.save()
|
permission_obj.save()
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
transaction.rollback()
|
transaction.rollback()
|
||||||
#Special case for ./manage.py syncdb
|
# 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:
|
else:
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user