id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,rd_points,sprint,story_priority 6342,Connection provider and decorators in webclient,atarkowska,atarkowska,"= Review = Due to the changes in #6387, Web should have one common strategy to create connection, keep it alive and retrieve in specific use cases. That is also related to decorators. Tickets - DRAFT ONLY!!! Examples of common functionality that exists (and could be moved to decorators) or that we might want to provide via decorators. - Error handling, connection & redirect or error if json. {{{ conn = None try: conn = kwargs[""conn""] except: logger.error(traceback.format_exc()) return handlerInternalError(""Connection is not available. Please contact your administrator."") }}} - Would be nice to allow 3rd party developers to specify templates. E.g. as in webgateway {{{ def full_viewer(request, iid, server_id=None, _conn=None, **kwargs): .... template = kwargs.get('template', ""webgateway/omero_image.html"") ...etc. }}} - Also we have this a lot {{{ t = template_loader.get_template(template) c = Context(request,context) logger.debug('TEMPLATE: '+template) return HttpResponse(t.render(c)) }}} {{{ # check menu menu = request.REQUEST.get(""menu"") if menu is not None: request.session['nav']['menu'] = menu else: menu = request.session['nav']['menu'] # check view view = request.REQUEST.get(""view"") if view is not None: request.session['nav']['view'] = view else: view = request.session['nav']['view'] }}} These lines (or equivalent) are needed in many views {{{ request.session['nav']['menu'] = menu # menu is 'usertags', 'userdata', 'search' etc. for main menu selection context['nav'] = request.session['nav'] }}} Due to various parameters added to the request in isUserConnected {{{ def sessionHelper(request): ... request.session['nav']={""blitz"": blitz, ""menu"": ""mydata"", ""view"": ""tree"", ""basket"": 0, ""experimenter"":None} def navHelper(request, conn): ... request.session['nav']['tab_links'] = links }}} = Existing Decorator Examples = * Python Decorator Library (http://wiki.python.org/moin/PythonDecoratorLibrary) * Beaker (http://beaker.groovie.org/caching.html#decorator-api) * !TurboGears {{{@validate(), @expose(), etc.}}} (http://turbogears.org/2.0/docs/modules/tgdecorators.html) * Pylons {{{@validate(), @jsonify(), etc.}}} (http://docs.pylonsproject.org/projects/pylons-webframework/en/latest/modules/decorators.html) = Shares & Sessions = Previous to 4.4, the creation of sessions for shares used the stored username/password to create a new session. Part of the refactoring described above will remove that stored username/password. However, it is not necessarily possible for a user to create a new session from an existing session (this is only allowed if the session is authenticated with a password). Nevertheless it is necessary to be able to activate a session for one user in one process without effecting the other processes that are currently using the same process. Josh and Chris have agreed that extending the `{""omero.group"":""1""}` functionality to also support shares should simplify things greatly. Each method invocation, regardless of group or session, can pass a share setting essentially activating that share for the duration of the method call. This will take place as a part of #3529.",story,closed,major,OMERO-4.4,Web,fixed,,jburel,,,