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)
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 )
def test_two_simple_terms(self): self.assertEqual(underscore_to_camelcase('lorem_ipsum'), 'LoremIpsum')
def test_simple_term(self): self.assertEqual(underscore_to_camelcase('lorem'), 'Lorem')
def test_empty(self): self.assertEqual(underscore_to_camelcase(''), '')