def test_get(self): cache.set('foo', 'bar', 60) cache.set('moof', 'baz', 1) no_cache = NoCache() self.assertEqual(no_cache.get('foo'), None) self.assertEqual(no_cache.get('moof'), None) self.assertEqual(no_cache.get(''), None)
def test_set(self): no_cache = NoCache() no_cache.set('foo', 'bar') no_cache.set('moof', 'baz', timeout=1) # Use the underlying cache system to verify. self.assertEqual(cache.get('foo'), None) self.assertEqual(cache.get('moof'), None)
class Meta: limit = 0 queryset = Location.objects.select_related('gadm').filter( loc_type__code="adm3") resource_name = 'adm3' allowed_methods = ['get'] cache = NoCache()
class Meta: queryset = Alert.objects.all() serializer = Serializer(formats=['json', 'jsonp']) if settings.DEBUG: cache = NoCache() else: cache = SimpleCache()
class ResourceOptions(object): """ A configuration class for ``Resource``. Provides sane defaults and the logic needed to augment these settings with the internal ``class Meta`` used on ``Resource`` subclasses. """ serializer = BaseSerializer() authentication = Authentication() authorization = Authorization() cache = NoCache() api_name = None resource_name = None alt_resource_name = None object_class = None queryset = None always_return_data = False collection_name = 'objects' detail_uri_name = 'pk' def __new__(cls, meta=None): overrides = {} # Handle overrides. if meta: for override_name in dir(meta): # No internals please. if not override_name.startswith('_'): overrides[override_name] = getattr(meta, override_name) if six.PY3: return object.__new__(type('ResourceOptions', (cls,), overrides)) else: return object.__new__(type(b'ResourceOptions', (cls,), overrides))
class Meta: queryset = Trib.objects.all() resource_name = 'user/timeline' ordering = ['trib_pub_date'] allowed_methods = ['get'] authorization = TimelineAuthorization() authentication = SessionAuthentication() cache = NoCache()
class Meta: queryset = UserProfile.objects.all() resource_name = 'user/profile' ordering = ['id'] allowed_methods = ['get', 'patch'] filtering = {'id': ALL_WITH_RELATIONS} authorization = UserProfileAuthorization() authentication = SessionAuthentication() cache = NoCache()
class Meta: queryset = User.objects.all() resource_name = 'user/details' ordering = ['id'] excludes = ['password', 'is_active', 'is_staff', 'is_superuser'] allowed_methods = ['get', 'patch'] filtering = {'id': ALL_WITH_RELATIONS} authorization = UserAuthorization() authentication = SessionAuthentication() cache = NoCache()
class Meta: queryset = Comment.objects.all() resource_name = 'tribs/comments' ordering = ['comment_pub_date'] allowed_methods = ['get', 'post', 'delete'] filtering = {'trib_id': ALL_WITH_RELATIONS} authorization = CommentAuthorization() authentication = SessionAuthentication() validation = CleanedDataFormValidation(form_class=CommentForm) cache = NoCache()
class Meta: queryset = Trib.objects.all() resource_name = 'user/tribs' ordering = ['trib_pub_date'] allowed_methods = ['get', 'post', 'delete'] filtering = {'author_id': ALL_WITH_RELATIONS} authorization = TribAuthorization() authentication = SessionAuthentication() validation = DocumentFormValidation(form_class=TribForm) cache = NoCache()
class Meta: queryset = UserEx.objects.all() resource_name = 'user' fields = ['email', 'facebook_name', 'picture', 'extras', 'read_from'] allowed_methods = ['get'] include_resource_uri = False authentication = MultiAuthentication(OAuth20Authentication(), SessionAuthentication(), FacebookAuthentication()) authorization = DjangoAuthorization() cache = NoCache()
class Meta: queryset = UserReads.objects.all() resource_name = 'account/read' resource_uri = False authentication = MultiAuthentication(OAuth20Authentication(), SessionAuthentication(), FacebookAuthentication()) authorization = DjangoAuthorization() cache = NoCache() filtering = { 'marked_at': ('gt', ), }
class Meta: queryset = Schedule.objects.all() resource_name = 'schedule' excludes = ['user'] allowed_methods = ['get', 'post', 'put', 'delete'] cache = NoCache() authorization = UserObjectOrFriendAuthorization() always_return_data = True limit = 0 max_limit = 0 filtering = { 'user': ALL_WITH_RELATIONS, 'semester': ALL_WITH_RELATIONS }
class Meta: queryset = UserStars.objects.all() resource_name = 'account/star' allowed_methods = ['get', 'post', 'patch', 'delete'] include_resource_uri = False excludes = ['id', 'star'] authentication = MultiAuthentication(OAuth20Authentication(), SessionAuthentication(), FacebookAuthentication()) authorization = DjangoAuthorization() cache = NoCache() filtering = { 'marked_at': ('gt', ), }
class ResourceOptions(object): """ A configuration class for ``Resource``. Provides sane defaults and the logic needed to augment these settings with the internal ``class Meta`` used on ``Resource`` subclasses. """ serializer = Serializer() authentication = Authentication() authorization = ReadOnlyAuthorization() cache = NoCache() throttle = BaseThrottle() validation = Validation() limit = getattr(settings, 'API_LIMIT_PER_PAGE', 20) route = None default_format = 'application/json' filtering = {} ordering = [] object_class = None queryset = None fields = [] excludes = [] include_resource_uri = True include_absolute_url = False # only applies to TOC resource resources = [] # only here for compatibility / deprecated api_name = None resource_name = '' def __new__(cls, meta=None): overrides = {} # Handle overrides. if meta: for override_name in dir(meta): # No internals please. if not override_name.startswith('_'): overrides[override_name] = getattr(meta, override_name) return object.__new__(type('ResourceOptions', (cls,), overrides))