Quickly making the Application read only

40 views
Skip to first unread message

Drazen D. Babic

unread,
Jul 27, 2022, 2:57:27 AM7/27/22
to Jam.py Users Mailing List
Hi, 

in the app folder create ro.html and modify jam/server_clases.py
.
.
    def apply_changes(self, data, safe, file_name=None):
        result = None
        changes, params = data
        file_name = 'ro.html'
        if os.path.exists(file_name):
            self.abort(u'This is a demo version with limited functionality. \
                You are not allowed to write changes to the database. \
                The full-featured version is located in the demo folder of the Jam.py package.')

        else:

            if not params:
                params = {}
            delta = self.delta(changes)
            if self.task.on_apply:
                result = self.task.on_apply(self, delta, params)
            if result is None and self.on_apply:
                result = self.on_apply(self, delta, params)
            if result is None:
                result = self.apply_delta(delta, safe)
            return result
.
.
Now the app is read only. Remove ro.html, and it is not read only.
No need to restart the app.
This is useful for example for restricting updates after 5pm :)

I hope the new Jam will have similar by default (for builder.html too).

D.

Dean D. Babic

unread,
Jun 28, 2024, 3:09:37 AMJun 28
to Jam.py Users Mailing List
For V7,
file items.py add:

    def apply_changes(self, data, safe, connection=None):
        result = None
        result_data = None

        file_name = 'ro.html'
        if os.path.exists(file_name):
            self.abort(u'This is a demo version with limited functionality. \
                You are not allowed to write changes to the database.')
        else:
....


Fabio Lenzarini

unread,
Jun 28, 2024, 8:52:29 AMJun 28
to Dean D. Babic, Jam.py Users Mailing List
nice to know, thanks

--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/34b14ef2-c0d8-4394-96a6-4f5d9f109d0en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages