web/webconfig.py
changeset 5467 57372dbfd114
parent 5466 b5af2ac0c43c
child 5473 ee87c5352e63
equal deleted inserted replaced
5466:b5af2ac0c43c 5467:57372dbfd114
   300         if baseurl and baseurl[-1] != '/':
   300         if baseurl and baseurl[-1] != '/':
   301             baseurl += '/'
   301             baseurl += '/'
   302         if not self.repairing:
   302         if not self.repairing:
   303             self.global_set_option('base-url', baseurl)
   303             self.global_set_option('base-url', baseurl)
   304         httpsurl = self['https-url']
   304         httpsurl = self['https-url']
   305         if httpsurl and httpsurl[-1] != '/':
   305         if httpsurl:
   306             httpsurl += '/'
   306             if httpsurl[-1] != '/':
   307             if not self.repairing:
   307                 httpsurl += '/'
   308                 self.global_set_option('https-url', httpsurl)
   308                 if not self.repairing:
       
   309                     self.global_set_option('https-url', httpsurl)
       
   310             if self.debugmode:
       
   311                 self.https_datadir_url = httpsurl + 'data/'
       
   312             else:
       
   313                 self.https_datadir_url = httpsurl + 'data%s/' % self.instance_md5_version()
   309         if self.debugmode:
   314         if self.debugmode:
   310             self.datadir_url = baseurl + 'data/'
   315             self.datadir_url = baseurl + 'data/'
   311         else:
   316         else:
   312             self.datadir_url = baseurl + 'data%s/' % self.instance_md5_version()
   317             self.datadir_url = baseurl + 'data%s/' % self.instance_md5_version()
   313 
   318 
   316         from cubicweb.web.propertysheet import PropertySheet
   321         from cubicweb.web.propertysheet import PropertySheet
   317         self.uiprops = PropertySheet(
   322         self.uiprops = PropertySheet(
   318             join(self.appdatahome, 'uicache'),
   323             join(self.appdatahome, 'uicache'),
   319             data=lambda x: self.datadir_url + x,
   324             data=lambda x: self.datadir_url + x,
   320             datadir_url=self.datadir_url[:-1])
   325             datadir_url=self.datadir_url[:-1])
       
   326         self._init_uiprops(self.uiprops)
       
   327         if self['https-url']:
       
   328             self.https_uiprops = PropertySheet(
       
   329                 join(self.appdatahome, 'uicache'),
       
   330                 data=lambda x: self.https_datadir_url + x,
       
   331                 datadir_url=self.https_datadir_url[:-1])
       
   332             self._init_uiprops(self.https_uiprops)
       
   333 
       
   334     def _init_uiprops(self, uiprops):
   321         libuiprops = join(self.shared_dir(), 'data', 'uiprops.py')
   335         libuiprops = join(self.shared_dir(), 'data', 'uiprops.py')
   322         self.uiprops.load(libuiprops)
   336         uiprops.load(libuiprops)
   323         for path in reversed([self.apphome] + self.cubes_path()):
   337         for path in reversed([self.apphome] + self.cubes_path()):
   324             self._load_ui_properties(path)
   338             self._load_ui_properties_file(uiprops, path)
   325         self._load_ui_properties(self.apphome)
   339         self._load_ui_properties_file(uiprops, self.apphome)
   326 
   340 
   327     def _load_ui_properties(self, path):
   341     def _load_ui_properties_file(self, uiprops, path):
   328         resourcesfile = join(path, 'data', 'external_resources')
   342         resourcesfile = join(path, 'data', 'external_resources')
   329         if exists(resourcesfile):
   343         if exists(resourcesfile):
   330             warn('[3.9] %s file is deprecated, use an uiprops.py file'
   344             warn('[3.9] %s file is deprecated, use an uiprops.py file'
   331                  % resourcesfile, DeprecationWarning)
   345                  % resourcesfile, DeprecationWarning)
       
   346             datadir_url = uiprops.context['datadir_url']
   332             for rid, val in read_config(resourcesfile).iteritems():
   347             for rid, val in read_config(resourcesfile).iteritems():
   333                 if rid in ('STYLESHEETS', 'STYLESHEETS_PRINT',
   348                 if rid in ('STYLESHEETS', 'STYLESHEETS_PRINT',
   334                            'IE_STYLESHEETS', 'JAVASCRIPTS'):
   349                            'IE_STYLESHEETS', 'JAVASCRIPTS'):
   335                     val = [w.strip().replace('DATADIR/', self.datadir_url)
   350                     val = [w.strip().replace('DATADIR', datadir_url)
   336                            for w in val.split(',') if w.strip()]
   351                            for w in val.split(',') if w.strip()]
   337                     if rid == 'IE_STYLESHEETS':
   352                     if rid == 'IE_STYLESHEETS':
   338                         rid = 'STYLESHEETS_IE'
   353                         rid = 'STYLESHEETS_IE'
   339                 else:
   354                 else:
   340                     val = val.strip().replace('DATADIR/', self.datadir_url)
   355                     val = val.strip().replace('DATADIR', datadir_url)
   341                 self.uiprops[rid] = val
   356                 uiprops[rid] = val
   342         uipropsfile = join(path, 'uiprops.py')
   357         uipropsfile = join(path, 'uiprops.py')
   343         if exists(uipropsfile):
   358         if exists(uipropsfile):
   344             self.debug('loading %s', uipropsfile)
   359             self.debug('loading %s', uipropsfile)
   345             self.uiprops.load(uipropsfile)
   360             uiprops.load(uipropsfile)
   346 
   361 
   347     # static files handling ###################################################
   362     # static files handling ###################################################
   348 
   363 
   349     @property
   364     @property
   350     def static_directory(self):
   365     def static_directory(self):