Exemplo n.º 1
0
def get_applications(request, response):
    """Return the list of applications and the dataconnection URLs for them.
    """
    root = reverse('slumber.views.get_applications')
    if request.GET.has_key('model'):
        appname, modelname = request.GET['model'].split('.')
        for app in applications():
            if app.name.endswith(appname) and app.models.has_key(modelname):
                return HttpResponseRedirect(root + app.models[modelname].path)
        return HttpResponseNotFound()
    response['apps'] = dict([(app.name, root + app.path + '/')
        for app in applications()])
Exemplo n.º 2
0
def get_applications(request, response):
    """Return the list of applications and the dataconnection URLs for them.
    """
    root = reverse('slumber.views.get_applications')
    if request.GET.has_key('model'):
        appname, modelname = request.GET['model'].split('.')
        for app in applications():
            if app.name.endswith(appname) and app.models.has_key(modelname):
                return HttpResponseRedirect(root + app.models[modelname].path)
        return HttpResponseNotFound()
    response['apps'] = dict([(app.name, root + app.path + '/')
                             for app in applications()])
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
from django.conf import settings
from django.conf.urls.defaults import patterns

from slumber.http import view_handler
from slumber.meta import applications


urls = {'^$': 'slumber.views.get_applications'}

for app in applications():
    urls['^(%s)/$' % app.path] = 'slumber.views.get_models'
    for model in app.models.values():
        urls['^(%s)/(%s)/$' % (app.path, model.name)] = 'slumber.views.get_model'
        for op in model.operations():
            urls['^(%s)/(%s)/%s/%s$' % (app.path, model.name, op.name, op.regex)] \
                = view_handler(op.operation)

urlpatterns = patterns('', *urls.items())