コード例 #1
0
ファイル: __init__.py プロジェクト: ajumell/django-helpers
def register(data_table):
    if isinstance(data_table, DataTable):
        raise Exception("DataTable class is required not instance.")

    if not issubclass(data_table, DataTable):
        raise Exception("A Sub class of DataTable is required.")

    if not hasattr(data_table, 'table_id'):
        name = str(time.time())
        name = name.replace('.', '')
    else:
        name = getattr(data_table, 'table_id')

    if not name.startswith(url_prefix):
        name = url_prefix + name

    setattr(data_table, 'table_id', name)
    data_table = data_table()
    tables[name] = data_table
    reg = "%s/" % name
    extra_url_parameters = data_table.url_search_parameters
    if extra_url_parameters is not None:
        for parameter in extra_url_parameters:
            reg += create_reg(parameter)
    reg += "$"

    pattern = url(r"%s" % reg, get_data, name=name, kwargs={
        "name": name
    })

    urlpatterns.append(pattern)
    return data_table
コード例 #2
0
ファイル: apps_helper.py プロジェクト: gamal-carto/cartoview
def register_app_urls(app_name):
    from urls import  urlpatterns
    urlpatterns.append(app_url(app_name))
    import_app_rest(app_name)
    #rest_api.register_app_urls(app_name)
    from django.contrib import admin
    admin.autodiscover()

    print 'app urls registerd.'
コード例 #3
0
def register_app_urls(app_name):
    from urls import urlpatterns
    urlpatterns.append(app_url(app_name))
    import_app_rest(app_name)
    # rest_api.register_app_urls(app_name)
    from django.contrib import admin
    admin.autodiscover()

    print 'app urls registerd.'
コード例 #4
0
ファイル: models.py プロジェクト: palankai/pacsee
def api_autodiscover(**kwargs):
    import imp
    from django.conf import settings
    from django.utils import importlib

    for app in settings.INSTALLED_APPS:
        
        try:                                                                                                                          
            app_path = importlib.import_module(app).__path__                                                                          
        except AttributeError:                                                                                                        
            continue 
        
        try:                                                                                                                          
            imp.find_module('api', app_path)                                                                               
        except ImportError:                                                                                                           
            continue                                                                                                                  
        module = importlib.import_module("%s.api" % app)
        module_name = getattr(module, "API_MODULE_NAME", app)

    for pattern, method, kwargs in conf.urls:
        urlpatterns.append(url(pattern, method, kwargs=kwargs))
コード例 #5
0
ファイル: __init__.py プロジェクト: ajumell/django-helpers
def register(autocomplete_class):
    if isinstance(autocomplete_class, AutoComplete):
        raise Exception("AutoComplete class is required not instance.")

    if not hasattr(autocomplete_class, "name"):
        name = str(time.time())
        name = name.replace(".", "")
    else:
        name = getattr(autocomplete_class, "name")

    if not name.startswith(url_prefix):
        name = url_prefix + name
    setattr(autocomplete_class, "name", name)

    lookups[name] = autocomplete_class
    reg = "%s/" % name
    extra_url_parameters = autocomplete_class.url_search_parameters
    if extra_url_parameters is not None:
        for parameter in extra_url_parameters:
            reg += create_reg(parameter)
    reg += "$"

    pattern = url(r"%s" % reg, autocomplete_lookup, name=name, kwargs={"lookup": name})
    urlpatterns.append(pattern)