def wrapper(self, request, *args, **kwargs):
     try:
         response = {
             "success": True,
             "data": func(self, request, *args, **kwargs)
         }
     except GargoyleException as exc:
         response = {
             "success": False,
             "data": exc.message
         }
     except Switch.DoesNotExist:
         response = {
             "success": False,
             "data": "Switch cannot be found"
         }
     except ValidationError as e:
         response = {
             "success": False,
             "data": u','.join(map(six.text_type, e.messages)),
         }
     except Exception:
         if settings.DEBUG:
             import traceback
             traceback.print_exc()
         raise
     return HttpResponse(dumps(response), content_type="application/json")
Exemple #2
0
 def wrapper(self, request, *args, **kwargs):
     try:
         response = {
             "success": True,
             "data": func(self, request, *args, **kwargs),
         }
     except GargoyleException as exc:
         response = {
             "success": False,
             "data": exc.message,
         }
     except Switch.DoesNotExist:
         response = {
             "success": False,
             "data": "Switch cannot be found",
         }
     except ValidationError as e:
         response = {
             "success": False,
             "data": u','.join(map(six.text_type, e.messages)),
         }
     except Exception:
         if settings.DEBUG:
             import traceback
             traceback.print_exc()
         raise
     return HttpResponse(dumps(response), content_type="application/json")
Exemple #3
0
            }
        except GargoyleException, exc:
            response = {"success": False, "data": exc.message}
        except Switch.DoesNotExist:
            response = {"success": False, "data": "Switch cannot be found"}
        except ValidationError, e:
            response = {
                "success": False,
                "data": u','.join(map(unicode, e.messages)),
            }
        except Exception:
            if settings.DEBUG:
                import traceback
                traceback.print_exc()
            raise
        return HttpResponse(dumps(response), content_type="application/json")

    wrapper = wraps(func)(wrapper)
    return wrapper


class GargoyleModule(nexus.NexusModule):
    home_url = 'index'
    name = 'gargoyle'

    def get_title(self):
        return 'Gargoyle'

    def get_urls(self):
        try:
            from django.conf.urls import patterns, url
        except Switch.DoesNotExist:
            response = {
                "success": False,
                "data": "Switch cannot be found"
            }
        except ValidationError, e:
            response = {
                "success": False,
                "data": u','.join(map(unicode, e.messages)),
            }
        except Exception:
            if settings.DEBUG:
                import traceback
                traceback.print_exc()
            raise
        return HttpResponse(dumps(response), mimetype="application/json")
    wrapper = wraps(func)(wrapper)
    return wrapper


class GargoyleModule(nexus.NexusModule):
    home_url = 'index'
    name = 'gargoyle'

    def get_title(self):
        return 'Gargoyle'

    def get_urls(self):
        from django.conf.urls.defaults import patterns, url

        urlpatterns = patterns('',
        except Switch.DoesNotExist:
            response = {
                "success": False,
                "data": "Switch cannot be found"
            }
        except ValidationError, e:
            response = {
                "success": False,
                "data": u','.join(map(unicode, e.messages)),
            }
        except Exception:
            if settings.DEBUG:
                import traceback
                traceback.print_exc()
            raise
        return HttpResponse(dumps(response), content_type="application/json")
    wrapper = wraps(func)(wrapper)
    return wrapper


class GargoyleModule(nexus.NexusModule):
    home_url = 'index'
    name = 'gargoyle'

    def get_title(self):
        return 'Gargoyle'

    def get_urls(self):
        try:
            from django.conf.urls import patterns, url
        except ImportError:  # Django<=1.4
Exemple #6
0
        except Switch.DoesNotExist:
            response = {
                "success": False,
                "data": "Switch cannot be found"
            }
        except ValidationError, e:
            response = {
                "success": False,
                "data": u','.join(map(unicode, e.messages)),
            }
        except Exception:
            if settings.DEBUG:
                import traceback
                traceback.print_exc()
            raise
        return HttpResponse(dumps(response), mimetype="application/json")
    wrapper = wraps(func)(wrapper)
    return wrapper


class GargoyleModule(nexus.NexusModule):
    home_url = 'index'
    name = 'gargoyle'

    def get_title(self):
        return 'Gargoyle'

    def get_urls(self):
        from django.conf.urls.defaults import patterns, url

        urlpatterns = patterns('',