コード例 #1
0
    def publishTraverse(self, request, name):
        if IAPIRequest.providedBy(request):
            if name == '' or name == 'folder_listing' or name == 'front-page':
                return ApiOverview(self.context, self.request)

            klassname = underscore_to_camelcase(name)
            mod = __import__('plone.app.angularjs.api.api',
                             fromlist=[klassname])
            try:
                klass = getattr(mod, klassname)
                return klass(self.context, self.request)
            except AttributeError:
                return json.dumps({
                    'code':
                    '404',
                    'message':
                    "API method '%s' not found." % name,
                })

        is_front_page = request.URL.endswith('front-page')
        no_front_page = \
            request.URL.endswith('folder_listing') or \
            request.URL.endswith('folder_contents')
        if is_front_page or no_front_page:
            # stop traversing
            request['TraversalRequestNameStack'] = []
            # return angular app view
            return AngularAppRootView(self.context, self.request)()
        return super(AngularAppPortalRootTraverser,
                     self).publishTraverse(request, name)
コード例 #2
0
    def publishTraverse(self, request, name):
        if IAPIRequest.providedBy(request):
            if name == '' or name == 'folder_listing' or name == 'front-page':
                return ApiOverview(self.context, self.request)

            klassname = underscore_to_camelcase(name)
            mod = __import__(
                'plone.app.angularjs.api.api',
                fromlist=[klassname]
            )
            try:
                klass = getattr(mod, klassname)
                return klass(self.context, self.request)
            except AttributeError:
                return json.dumps({
                    'code': '404',
                    'message': "API method '%s' not found." % name,
                })

        is_front_page = request.URL.endswith('front-page')
        no_front_page = \
            request.URL.endswith('folder_listing') or \
            request.URL.endswith('folder_contents')
        if is_front_page or no_front_page:
            # stop traversing
            request['TraversalRequestNameStack'] = []
            # return angular app view
            return AngularAppRootView(self.context, self.request)()
        return super(AngularAppPortalRootTraverser, self).publishTraverse(
            request,
            name
        )
コード例 #3
0
 def test_two_simple_terms(self):
     self.assertEqual(underscore_to_camelcase('lorem_ipsum'), 'LoremIpsum')
コード例 #4
0
 def test_simple_term(self):
     self.assertEqual(underscore_to_camelcase('lorem'), 'Lorem')
コード例 #5
0
 def test_empty(self):
     self.assertEqual(underscore_to_camelcase(''), '')
コード例 #6
0
 def test_two_simple_terms(self):
     self.assertEqual(underscore_to_camelcase('lorem_ipsum'), 'LoremIpsum')
コード例 #7
0
 def test_simple_term(self):
     self.assertEqual(underscore_to_camelcase('lorem'), 'Lorem')
コード例 #8
0
 def test_empty(self):
     self.assertEqual(underscore_to_camelcase(''), '')