def __change( self, setup = None, group = None ): if not setup: setup = self.getUserSetup() if not group: group = self.getUserGroup() or 'anon' url = [ Conf.rootURL().strip( "/" ), "s:%s" % setup, "g:%s" % group ] self.redirect( "/%s" % "/".join( url ) )
def __change(self, setup=None, group=None): if not setup: setup = self.getUserSetup() if not group: group = self.getUserGroup() or 'anon' url = [Conf.rootURL().strip("/"), "s:%s" % setup, "g:%s" % group] self.redirect("/%s" % "/".join(url))
def web_index(self): # Render base template data = self.getSessionData() url_state = "" if self.request.arguments.has_key("url_state") and len(self.request.arguments["url_state"][0]) > 0: url_state = self.request.arguments["url_state"][0] view_name = Conf.getTheme() if self.request.arguments.has_key("view") and len(self.request.arguments["view"][0]) > 0: view_name = self.request.arguments["view"][0] theme_name = "ext-all-gray" if self.request.arguments.has_key("theme") and len(self.request.arguments["theme"][0]) > 0: if self.request.arguments["theme"][0]=="Neptune": theme_name = "ext-all-neptune" if self.request.arguments["theme"][0]=="Classic": theme_name = "ext-all" open_app = "" if self.request.arguments.has_key("open_app") and len(self.request.arguments["open_app"][0]) > 0: open_app = self.request.arguments["open_app"][0].strip() level = str(gLogger.getLevel()).lower() self.render( "root.tpl", base_url = data[ 'baseURL' ], _dev = Conf.devMode(), ext_version = data[ 'extVersion' ], url_state = url_state, extensions = data[ 'extensions' ], credentials = data[ 'user' ], title = Conf.getTitle(), theme = theme_name, root_url = Conf.rootURL(), view = view_name, open_app = open_app, debug_level= level)
def getData(self): DN = self.__disetConfig.getDN() group = self.__disetConfig.getGroup() credDict = self.__getCredDict(DN, group) data = { 'menu': self.__getGroupMenu(credDict, group), 'user': credDict, 'validGroups': [], 'setup': self.__disetConfig.getSetup() or gConfig.getValue("/DIRAC/Setup", ""), 'validSetups': gConfig.getSections("/DIRAC/Setups")['Value'], 'extensions': self.__extensions, 'extVersion': self.getExtJSVersion() } if 'properties' in credDict: credDict.pop('properties') #Add valid groups if known if DN: result = Registry.getGroupsForDN(DN) if result['OK']: data['validGroups'] = result['Value'] #Calculate baseURL baseURL = [ Conf.rootURL().strip("/"), "s:%s" % data['setup'], "g:%s" % credDict.get('group', 'anon') ] data['baseURL'] = "/%s" % "/".join(baseURL) return data
def web_index(self): # Render base template data = self.getSessionData() url_state = "" if self.request.arguments.has_key("url_state") and len( self.request.arguments["url_state"][0]) > 0: url_state = xss_filter(self.request.arguments["url_state"][0]) view_name = Conf.getTheme() if self.request.arguments.has_key("view") and len( self.request.arguments["view"][0]) > 0: view_name = xss_filter(self.request.arguments["view"][0]) theme_name = "ext-all-gray" if self.request.arguments.has_key("theme") and len( self.request.arguments["theme"][0]) > 0: if self.request.arguments["theme"][0] == "Neptune": theme_name = "ext-all-neptune" if self.request.arguments["theme"][0] == "Classic": theme_name = "ext-all" open_app = "" if self.request.arguments.has_key("open_app") and len( self.request.arguments["open_app"][0]) > 0: open_app = xss_filter( self.request.arguments["open_app"][0].strip()) icon = data['baseURL'] + Conf.getIcon() background = data['baseURL'] + Conf.getBackgroud() logo = data['baseURL'] + Conf.getLogo() welcomeFile = Conf.getWelcome() welcome = '' if welcomeFile: try: with open(welcomeFile, 'r') as f: welcome = f.read().replace('\n', '') except: gLogger.warn('Welcome page not found here: %s' % welcomeFile) level = str(gLogger.getLevel()).lower() self.render("root.tpl", iconUrl=icon, base_url=data['baseURL'], _dev=Conf.devMode(), ext_version=data['extVersion'], url_state=url_state, extensions=data['extensions'], credentials=data['user'], title=Conf.getTitle(), theme=theme_name, root_url=Conf.rootURL(), view=view_name, open_app=open_app, debug_level=level, welcome=welcome, backgroundImage=background, logo=logo)
def run(self): """ Start web servers """ bu = Conf.rootURL().strip("/") urls = [] for proto, port in self.__servers: urls.append("%s://0.0.0.0:%s/%s/" % (proto, port, bu)) self.log.always("Listening on %s" % " and ".join(urls)) tornado.autoreload.add_reload_hook(self.__reloadAppCB) tornado.ioloop.IOLoop.instance().start()
def __change(self, setup=None, group=None): if not setup: setup = self.getUserSetup() if not group: group = self.getUserGroup() or 'anon' qs = False if 'Referer' in self.request.headers: o = urlparse.urlparse(self.request.headers['Referer']) qs = '?%s' % o.query url = [Conf.rootURL().strip("/"), "s:%s" % setup, "g:%s" % group] self.redirect("/%s%s" % ("/".join(url), qs))
def __change( self, setup = None, group = None ): if not setup: setup = self.getUserSetup() if not group: group = self.getUserGroup() or 'anon' qs = False if 'Referer' in self.request.headers: o = urlparse.urlparse( self.request.headers[ 'Referer' ] ) qs = '?%s' % o.query url = [ Conf.rootURL().strip( "/" ), "s:%s" % setup, "g:%s" % group ] self.redirect( "/%s%s" % ( "/".join( url ), qs ) )
def get( self, setup, group, route ): if self.__action == "addSlash": self.redirect( "%s/" % self.request.uri, permanent = True ) elif self.__action == "sendToRoot": dest = "/" rootURL = Conf.rootURL() if rootURL: dest += "%s/" % rootURL.strip( "/" ) if setup and group: dest += "s:%s/g:%s/" % ( setup, group ) self.redirect( dest )
def get(self, setup, group, route): if self.__action == "addSlash": self.redirect("%s/" % self.request.uri, permanent=True) elif self.__action == "sendToRoot": dest = "/" rootURL = Conf.rootURL() if rootURL: dest += "%s/" % rootURL.strip("/") if setup and group: dest += "s:%s/g:%s/" % (setup, group) self.redirect(dest)
def run( self ): """ Start web servers """ bu = Conf.rootURL().strip( "/" ) urls = [] for proto, port in self.__servers: urls.append("%s://0.0.0.0:%s/%s/" % ( proto, port, bu ) ) self.log.always( "Listening on %s" % " and ".join( urls ) ) tornado.autoreload.add_reload_hook( self.__reloadAppCB ) tornado.ioloop.IOLoop.instance().start()
def get(self, setup, group, route): if self.__action == "addSlash": o = urlparse.urlparse(self.request.uri) proto = self.request.protocol if 'X-Scheme' in self.request.headers: proto = self.request.headers['X-Scheme'] nurl = "%s://%s%s/" % (proto, self.request.host, o.path) if o.query: nurl = "%s?%s" % (nurl, o.query) self.redirect(nurl, permanent=True) elif self.__action == "sendToRoot": dest = "/" rootURL = Conf.rootURL() if rootURL: dest += "%s/" % rootURL.strip("/") if setup and group: dest += "s:%s/g:%s/" % (setup, group) self.redirect(dest)
def get( self, setup, group, route ): if self.__action == "addSlash": o = urlparse.urlparse( self.request.uri ) proto = self.request.protocol if 'X-Scheme' in self.request.headers: proto = self.request.headers[ 'X-Scheme' ] nurl = "%s://%s%s/" % ( proto, self.request.host, o.path ) if o.query: nurl = "%s?%s" % ( nurl, o.query ) self.redirect( nurl, permanent = True ) elif self.__action == "sendToRoot": dest = "/" rootURL = Conf.rootURL() if rootURL: dest += "%s/" % rootURL.strip( "/" ) if setup and group: dest += "s:%s/g:%s/" % ( setup, group ) self.redirect( dest )
def web_index(self): # Render base template data = self.getSessionData() url_state = "" if self.request.arguments.has_key("url_state") and len(self.request.arguments["url_state"][0]) > 0: url_state = xss_filter( self.request.arguments["url_state"][0] ) view_name = Conf.getTheme() if self.request.arguments.has_key("view") and len(self.request.arguments["view"][0]) > 0: view_name = xss_filter( self.request.arguments["view"][0] ) theme_name = "ext-all-gray" if self.request.arguments.has_key("theme") and len(self.request.arguments["theme"][0]) > 0: if self.request.arguments["theme"][0]=="Neptune": theme_name = "ext-all-neptune" if self.request.arguments["theme"][0]=="Classic": theme_name = "ext-all" open_app = "" if self.request.arguments.has_key("open_app") and len(self.request.arguments["open_app"][0]) > 0: open_app = xss_filter( self.request.arguments["open_app"][0].strip() ) icon = data[ 'baseURL' ] + Conf.getIcon() background = data[ 'baseURL' ] + Conf.getBackgroud() logo = data[ 'baseURL' ] + Conf.getLogo() welcomeFile = Conf.getWelcome() welcome = '' if welcomeFile: try: with open(welcomeFile, 'r') as f: welcome = f.read().replace('\n', '') except: gLogger.warn('Welcome page not found here: %s' % welcomeFile) level = str(gLogger.getLevel()).lower() self.render( "root.tpl", iconUrl=icon, base_url = data[ 'baseURL' ], _dev = Conf.devMode(), ext_version = data[ 'extVersion' ], url_state = url_state, extensions = data[ 'extensions' ], credentials = data[ 'user' ], title = Conf.getTitle(), theme = theme_name, root_url = Conf.rootURL(), view = view_name, open_app = open_app, debug_level = level, welcome = welcome, backgroundImage = background, logo = logo )
def getData( self ): data = { 'menu' : self.__getGroupMenu(), 'user' : self.__credDict, 'validGroups' : [], 'setup' : self.__setup, 'validSetups' : gConfig.getSections( "/DIRAC/Setups" )[ 'Value' ], 'extensions' : self.__extensions, 'extVersion' : self.getExtJSVersion() } #Add valid groups if known DN = self.__credDict.get( "DN", "" ) if DN: result = Registry.getGroupsForDN( DN ) if result[ 'OK' ]: data[ 'validGroups' ] = result[ 'Value' ] #Calculate baseURL baseURL = [ Conf.rootURL().strip( "/" ), "s:%s" % data[ 'setup' ], "g:%s" % self.__credDict.get( 'group', '' ) ] data[ 'baseURL' ] = "/%s" % "/".join( baseURL ) return data
def web_index(self): # Render base template data = self.getSessionData() url_state = "" if self.request.arguments.has_key("url_state") and len(self.request.arguments["url_state"][0]) > 0: url_state = self.request.arguments["url_state"][0] view_name = "desktop" if self.request.arguments.has_key("view") and len(self.request.arguments["view"][0]) > 0: view_name = self.request.arguments["view"][0] theme_name = "ext-all-gray" if self.request.arguments.has_key("theme") and len(self.request.arguments["theme"][0]) > 0: if self.request.arguments["theme"][0] == "Neptune": theme_name = "ext-all-neptune" if self.request.arguments["theme"][0] == "Classic": theme_name = "ext-all" open_app = "" if self.request.arguments.has_key("open_app") and len(self.request.arguments["open_app"][0]) > 0: open_app = self.request.arguments["open_app"][0].strip() self.render( "root.tpl", base_url=data["baseURL"], _dev=Conf.devMode(), ext_version=data["extVersion"], url_state=url_state, extensions=data["extensions"], credentials=data["user"], title=Conf.getTitle(), theme=theme_name, root_url=Conf.rootURL(), view=view_name, open_app=open_app, )
def getData(self): data = { 'menu': self.__getGroupMenu(), 'user': self.__credDict, 'validGroups': [], 'setup': self.__setup, 'validSetups': gConfig.getSections("/DIRAC/Setups")['Value'], 'extensions': self.__extensions, 'extVersion': self.getExtJSVersion() } #Add valid groups if known DN = self.__credDict.get("DN", "") if DN: result = Registry.getGroupsForDN(DN) if result['OK']: data['validGroups'] = result['Value'] #Calculate baseURL baseURL = [ Conf.rootURL().strip("/"), "s:%s" % data['setup'], "g:%s" % self.__credDict.get('group', '') ] data['baseURL'] = "/%s" % "/".join(baseURL) return data
def getData( self ): DN = self.__disetConfig.getDN() group = self.__disetConfig.getGroup() credDict = self.__getCredDict( DN, group ) data = { 'menu' : self.__getGroupMenu( credDict, group ), 'user' : credDict, 'validGroups' : [], 'setup' : self.__disetConfig.getSetup() or gConfig.getValue( "/DIRAC/Setup", "" ), 'validSetups' : gConfig.getSections( "/DIRAC/Setups" )[ 'Value' ], 'extensions' : self.__extensions, 'extVersion' : self.getExtJSVersion() } if 'properties' in credDict: credDict.pop( 'properties' ) #Add valid groups if known if DN: result = Registry.getGroupsForDN( DN ) if result[ 'OK' ]: data[ 'validGroups' ] = result[ 'Value' ] #Calculate baseURL baseURL = [ Conf.rootURL().strip( "/" ), "s:%s" % data[ 'setup' ], "g:%s" % credDict.get( 'group', 'anon' ) ] data[ 'baseURL' ] = "/%s" % "/".join( baseURL ) return data
def __init__( self ): self.__routes = Routes( Conf.rootURL() ) self.__servers = {} self.log = gLogger.getSubLogger( "Web" )
def __init__(self): self.__handlerMgr = HandlerMgr(Conf.rootURL()) self.__servers = {} self.log = gLogger.getSubLogger("Web")
def __init__( self ): self.__handlerMgr = HandlerMgr( Conf.rootURL() ) self.__servers = {} self.log = gLogger.getSubLogger( "Web" )