comparison src/server/session_iface.py @ 995:f88325b56a6a

server: dynamic pages first draft: /!\ new dependency: autobahn This patch introduce server part of dynamic pages. Dynamic pages use websockets to establish constant connection with a Libervia page, allowing to receive real time data or update it. The feature is activated by specifying "dynamic = true" in the page. Once activated, page can implement "on_data" method which will be called when data are sent by the page. To send data the other way, the page can use request.sendData. The new "registerSignal" method allows to use an "on_signal" method to be called each time given signal is received, with automatic (and optional) filtering on profile. New renderPartial and renderAndUpdate method allow to append new HTML elements to the dynamic page.
author Goffi <goffi@goffi.org>
date Wed, 03 Jan 2018 01:10:12 +0100
parents fd4eae654182
children f2170536ba23
comparison
equal deleted inserted replaced
994:b92b06f023cb 995:f88325b56a6a
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 from zope.interface import Interface, Attribute, implements 19 from zope.interface import Interface, Attribute, implements
20 from sat.tools.common import data_objects 20 from sat.tools.common import data_objects
21 from libervia.server.constants import Const as C
22 import os.path
21 import shortuuid 23 import shortuuid
22 24
23 FLAGS_KEY = '_flags' 25 FLAGS_KEY = '_flags'
24 26
25 class ISATSession(Interface): 27 class ISATSession(Interface):
37 self.jid = None 39 self.jid = None
38 self.uuid = unicode(shortuuid.uuid()) 40 self.uuid = unicode(shortuuid.uuid())
39 self.identities = data_objects.Identities() 41 self.identities = data_objects.Identities()
40 self.csrf_token = unicode(shortuuid.uuid()) 42 self.csrf_token = unicode(shortuuid.uuid())
41 self.pages_data = {} # used to keep data accross reloads (key is page instance) 43 self.pages_data = {} # used to keep data accross reloads (key is page instance)
44
45 @property
46 def cache_dir(self):
47 return os.path.join(u'/', C.CACHE_DIR, self.uuid) + u'/'
42 48
43 def getPageData(self, page, key): 49 def getPageData(self, page, key):
44 """get session data for a page 50 """get session data for a page
45 51
46 @param page(LiberviaPage): instance of the page 52 @param page(LiberviaPage): instance of the page