Mercurial > libervia-web
annotate libervia/server/classes.py @ 1251:a1606e2a92eb
server: fixed watching a directory which is already watched:
Twisted file watched is not adding a callback to a watched path when there is already one,
but this can happens often in Libervia, as a whole site is recusively watched in dev mode,
and tasks may want to add other watchers.
To work around this, the new `_checkCallback` will recursively check that callback has
been indeed added to the requested path.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 29 Apr 2020 14:54:33 +0200 |
parents | f511f8fbbf8a |
children | e628724530ec |
rev | line source |
---|---|
1239 | 1 #!/usr/bin/env python3 |
2 | |
1185
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
1237 | 5 # Copyright (C) 2011-2020 Jérôme Poisson <goffi@goffi.org> |
1185
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 """Useful genertic classes used in Libervia""" |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from collections import namedtuple |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 |
7d6c0e5d5f34
server: moved generic classes definitions (only WebsocketMeta for now) to new "classes" module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 WebsocketMeta = namedtuple("WebsocketMeta", ("url", "token", "debug")) |
1186
352865f4a268
server: added a generic way to have notification messages in pages
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
26 Notification = namedtuple("Notification", ("message", "level")) |