Mercurial > libervia-web
diff src/server/server.py @ 985:64826e69f365
pages: cache mechanism, first draft:
a cache mechanism has been implemented to retrieve pages with a complexe rendering and/or calling expensive methods (e.g. network calls).
For now it's is done only for Pubsub and with service profile (i.e. profile used when user is not logged in).
When a LiberviaPage use cache, node is subscribed, and as long as no event is received (even can be item update, item retraction, or node deletion), the cached page is returned.
This is a first draft, it is planed to handle in the future logged users (which can be tricky as we must not let (un)subscribed node if user is not willing to), multi-nodes pages (e.g.: item + comments) and cache for page not depending on pubsub (e.g. chat).
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 19 Nov 2017 17:18:14 +0100 |
parents | f0fc28b3bd1e |
children | 6daa59d44ee2 |
line wrap: on
line diff
--- a/src/server/server.py Fri Nov 17 12:10:56 2017 +0100 +++ b/src/server/server.py Sun Nov 19 17:18:14 2017 +0100 @@ -53,6 +53,7 @@ import libervia from libervia.server.pages import LiberviaPage from libervia.server.utils import quote +from functools import partial try: import OpenSSL @@ -1393,6 +1394,7 @@ self.signal_handler = SignalHandler(self) self.sessions = {} # key = session value = user self.prof_connected = set() # Profiles connected + self.ns_map = {} # map of short name to namespaces ## bridge ## try: @@ -1402,11 +1404,20 @@ sys.exit(1) self.bridge.bridgeConnect(callback=self._bridgeCb, errback=self._bridgeEb) + def _namespacesGetCb(self, ns_map): + self.ns_map = ns_map + + def _namespacesGetEb(self, failure_): + log.error(_(u"Can't get namespaces map: {msg}").format(msg=failure_)) + def backendReady(self, dummy): self.root = root = LiberviaRootResource(self.options, self.html_dir) _register = Register(self) _upload_radiocol = UploadManagerRadioCol(self) _upload_avatar = UploadManagerAvatar(self) + d = self.bridgeCall('namespacesGet') + d.addCallback(self._namespacesGetCb) + d.addErrback(self._namespacesGetEb) self.signal_handler.plugRegister(_register) self.bridge.register_signal("connected", self.signal_handler.connected) self.bridge.register_signal("disconnected", self.signal_handler.disconnected) @@ -1442,6 +1453,7 @@ self.putChild(C.THEMES_URL, ProtectedFile(self.themes_dir)) LiberviaPage.importPages(self) + self.bridge.register_signal("psEventRaw", partial(LiberviaPage.onNodeEvent, self), "plugin") # media dirs # FIXME: get rid of dirname and "/" in C.XXX_DIR