Exemple #1
0
def check_settings():
    def fail(msg):
        raise Exception(u'Error in settings: {}'.format(msg))
    from metashare.settings import DJANGO_BASE, DJANGO_URL
    if DJANGO_URL.endswith('/'):
        fail('DJANGO_URL must not end in a slash')
    if not (DJANGO_BASE.endswith('/') or DJANGO_BASE == ''):
        fail('DJANGO_BASE must end in a slash or be the empty string')
    # from base, remove the trailing slash:
    base_path = DJANGO_BASE[:-1]
    # From url, remove the protocol if present:
    url_path = '://' in DJANGO_URL and DJANGO_URL[DJANGO_URL.find('://')+3:] or DJANGO_URL
    # and then the host/port:
    url_path = '/' in url_path and url_path[url_path.find('/')+1:] or ''
    if base_path != url_path:
        fail(u"Based on DJANGO_URL '{}', expected DJANGO_BASE '{}/', but was '{}'".format(DJANGO_URL, url_path, DJANGO_BASE))
Exemple #2
0
def check_settings():
    def fail(msg):
        raise Exception(u'Error in settings: {}'.format(msg))

    from metashare.settings import DJANGO_BASE, DJANGO_URL
    if DJANGO_URL.endswith('/'):
        fail('DJANGO_URL must not end in a slash')
    if not (DJANGO_BASE.endswith('/') or DJANGO_BASE == ''):
        fail('DJANGO_BASE must end in a slash or be the empty string')
    # from base, remove the trailing slash:
    base_path = DJANGO_BASE[:-1]
    # From url, remove the protocol if present:
    url_path = '://' in DJANGO_URL and DJANGO_URL[DJANGO_URL.find('://') +
                                                  3:] or DJANGO_URL
    # and then the host/port:
    url_path = '/' in url_path and url_path[url_path.find('/') + 1:] or ''
    if base_path != url_path:
        fail(
            u"Based on DJANGO_URL '{}', expected DJANGO_BASE '{}/', but was '{}'"
            .format(DJANGO_URL, url_path, DJANGO_BASE))
Exemple #3
0
def set_site_from_django_url(app, created_models, verbosity, **kwargs):
    '''
    Make sure that the first site object matches the DJANGO_URL setting.
    '''
    from metashare.settings import DJANGO_URL
    url_host = '://' in DJANGO_URL and DJANGO_URL[DJANGO_URL.find('://')+3:] or DJANGO_URL
    url_host = '/' in url_host and url_host[:url_host.find('/')] or ''
    from django.contrib.sites.models import Site
    site = Site.objects.get(pk=1)
    if site.domain != url_host:
        site.domain = url_host
        site.save()
Exemple #4
0
def check_settings():
    def fail(msg):
        raise Exception(u'Error in settings: {}'.format(msg))

    from metashare.settings import DJANGO_BASE, DJANGO_URL
    if DJANGO_URL.endswith('/'):
        fail('DJANGO_URL must not end in a slash')
    if not (DJANGO_BASE.endswith('/') or DJANGO_BASE == ''):
        fail('DJANGO_BASE must end in a slash or be the empty string')
    # from base, remove the trailing slash:
    base_path = DJANGO_BASE[:-1]
    # From url, remove the protocol if present:
    url_path = '://' in DJANGO_URL and DJANGO_URL[DJANGO_URL.find('://') +
                                                  3:] or DJANGO_URL
    # and then the host/port:
    url_path = '/' in url_path and url_path[url_path.find('/') + 1:] or ''
    if base_path != url_path:
        fail(
            u"Based on DJANGO_URL '{}', expected DJANGO_BASE '{}/', but was '{}'"
            .format(DJANGO_URL, url_path, DJANGO_BASE))


# def objectify_xmlfile(_file):
#     from metashare.settings import ROOT_PATH
#     from lxml import objectify
#     try:
#         _f = open("{}/../metashare/processing/{}".format(ROOT_PATH, _file))
#     except Exception, exc:
#         try:
#             _f = open("{}/../misc/tools/processingChains/{}".format(ROOT_PATH, _file))
#         except Exception, exc:
#             raise exc
#     _objectified_xml = objectify.parse(_f)
#     _f.close()
#     return _objectified_xml
#
#
# objectified_xml = objectify_xmlfile('annotationLevels.xml')
# services_chains_xml = objectify_xmlfile('processingChains.xml')
# processing_services_xml = objectify_xmlfile('processingServices.xml')
Exemple #5
0
def set_site_from_django_url(app, created_models, verbosity, **kwargs):
    '''
    Make sure that the first site object matches the DJANGO_URL setting.
    '''
    from metashare.settings import DJANGO_URL
    url_host = '://' in DJANGO_URL and DJANGO_URL[DJANGO_URL.find('://') +
                                                  3:] or DJANGO_URL
    url_host = '/' in url_host and url_host[:url_host.find('/')] or url_host
    from django.contrib.sites.models import Site
    site = Site.objects.get(pk=1)
    if site.domain != url_host:
        site.domain = url_host
        site.name = 'META-SHARE'
        site.save()