File: cookbook.rst

package info (click to toggle)
python-restless 2.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 608 kB
  • sloc: python: 2,124; makefile: 148
file content (28 lines) | stat: -rw-r--r-- 736 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
.. _cookbook:

========
Cookbook
========

This is a place for community-contributed patterns & ideas for extending
Restless.


Authentication
==============

If your framework has the concept of a logged-in user (like Django), you can
do something like::

    class MyResource(DjangoResource):
        def is_authenticated(self):
            return self.request.user.is_authenticated()

If you need a more fine graned authentication you could check your current endpoint and do something like that::

    class MyResource(DjangoResource):
        def is_authenticated(self):
            if self.endpoint in ('update', 'create'):
                return self.request.user.is_authenticated()
            else:
                return True