Package omeroweb :: Module settings
[hide private]
[frames] | no frames]

Source Code for Module omeroweb.settings

  1  #!/usr/bin/env python 
  2  # -*- coding: utf-8 -*- 
  3  #  
  4  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #  
  5  # #                Django settings for OMERO.web project.               # #  
  6  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
  7  #  
  8  #  
  9  # Copyright (c) 2008 University of Dundee.  
 10  #  
 11  # This program is free software: you can redistribute it and/or modify 
 12  # it under the terms of the GNU Affero General Public License as 
 13  # published by the Free Software Foundation, either version 3 of the 
 14  # License, or (at your option) any later version. 
 15  #  
 16  # This program is distributed in the hope that it will be useful, 
 17  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 18  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 19  # GNU Affero General Public License for more details. 
 20  #  
 21  # You should have received a copy of the GNU Affero General Public License 
 22  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 23  #  
 24  # Author: Aleksandra Tarkowska <A(dot)Tarkowska(at)dundee(dot)ac(dot)uk>, 2008. 
 25  #  
 26  # Version: 1.0 
 27  # 
 28   
 29  import os.path 
 30  import sys 
 31  import datetime 
 32  import logging 
 33  import omero 
 34  import omero.config 
 35  import omero.clients 
 36  import tempfile 
 37  import re 
 38   
 39  from django.utils import simplejson as json 
 40  from portalocker import LockException 
 41   
 42  logger = logging.getLogger(__name__) 
 43   
 44  # LOGS 
 45  # NEVER DEPLOY a site into production with DEBUG turned on. 
 46  # Debuging mode. 
 47  # A boolean that turns on/off debug mode. 
 48  # handler404 and handler500 works only when False 
 49  if os.environ.has_key('OMERO_HOME'): 
 50      OMERO_HOME =os.environ.get('OMERO_HOME')  
 51  else: 
 52      OMERO_HOME = os.path.join(os.path.dirname(__file__), '..', '..', '..') 
 53      OMERO_HOME = os.path.normpath(OMERO_HOME) 
 54   
 55  INSIGHT_JARS = os.path.join(OMERO_HOME, "lib", "insight").replace('\\','/') 
 56  WEBSTART = False 
 57  if os.path.isdir(INSIGHT_JARS): 
 58      WEBSTART = True 
 59   
 60  # Logging 
 61  LOGDIR = os.path.join(OMERO_HOME, 'var', 'log').replace('\\','/') 
 62   
 63  if not os.path.isdir(LOGDIR): 
 64      try: 
 65          os.makedirs(LOGDIR) 
 66      except Exception, x: 
 67          exctype, value = sys.exc_info()[:2] 
 68          raise exctype, value 
 69   
 70  # DEBUG: Never deploy a site into production with DEBUG turned on. 
 71  # Logging levels: logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR logging.CRITICAL 
 72  # FORMAT: 2010-01-01 00:00:00,000 INFO  [omeroweb.webadmin.webadmin_utils        ] (proc.1308 ) getGuestConnection:20 Open connection is not available 
 73   
 74  LOGGING = { 
 75      'version': 1, 
 76      'disable_existing_loggers': True, 
 77      'formatters': { 
 78          'standard': { 
 79              'format': '%(asctime)s %(levelname)5.5s [%(name)40.40s] (proc.%(process)5.5d) %(funcName)s:%(lineno)d %(message)s' 
 80          }, 
 81      }, 
 82      'handlers': { 
 83          'default': { 
 84              'level':'DEBUG', 
 85              'class':'logging.handlers.RotatingFileHandler', 
 86              'filename': os.path.join(LOGDIR, 'OMEROweb.log').replace('\\','/'), 
 87              'maxBytes': 1024*1024*5, # 5 MB 
 88              'backupCount': 5, 
 89              'formatter':'standard', 
 90          },   
 91          'request_handler': { 
 92              'level':'DEBUG', 
 93              'class':'logging.handlers.RotatingFileHandler', 
 94              'filename': os.path.join(LOGDIR, 'OMEROweb_request.log').replace('\\','/'), 
 95              'maxBytes': 1024*1024*5, # 5 MB 
 96              'backupCount': 5, 
 97              'formatter':'standard', 
 98          }, 
 99          'null': { 
100              'level':'DEBUG', 
101              'class':'django.utils.log.NullHandler', 
102          }, 
103          'console':{ 
104              'level':'DEBUG', 
105              'class':'logging.StreamHandler', 
106              'formatter': 'standard' 
107          }, 
108      }, 
109      'loggers': { 
110          'django.request': { # Stop SQL debug from logging to main logger 
111              'handlers': ['request_handler'], 
112              'level': 'DEBUG', 
113              'propagate': False 
114          }, 
115          'django': { 
116              'handlers': ['null'], 
117              'level': 'DEBUG', 
118              'propagate': True 
119          }, 
120          '': { 
121              'handlers': ['default'], 
122              'level': 'DEBUG', 
123              'propagate': True 
124          } 
125      } 
126  } 
127   
128  # Load custom settings from etc/grid/config.xml 
129  # Tue  2 Nov 2010 11:03:18 GMT -- ticket:3228 
130  from omero.util.concurrency import get_event 
131  CONFIG_XML = os.path.join(OMERO_HOME, 'etc', 'grid', 'config.xml') 
132  count = 10 
133  event = get_event("websettings") 
134   
135  while True: 
136      try: 
137          CONFIG_XML = omero.config.ConfigXml(CONFIG_XML) 
138          CUSTOM_SETTINGS = CONFIG_XML.as_map() 
139          CONFIG_XML.close() 
140          break 
141      except LockException: 
142          #logger.error("Exception while loading configuration retrying...", exc_info=True) 
143          exctype, value = sys.exc_info()[:2] 
144          count -= 1 
145          if not count: 
146              raise exctype, value 
147          else: 
148              event.wait(1) # Wait a total of 10 seconds 
149      except: 
150          #logger.error("Exception while loading configuration...", exc_info=True) 
151          exctype, value = sys.exc_info()[:2] 
152          raise exctype, value 
153   
154  del event 
155  del count 
156  del get_event 
157   
158  FASTCGI = "fastcgi" 
159  FASTCGITCP = "fastcgi-tcp" 
160  FASTCGI_TYPES = (FASTCGI, FASTCGITCP) 
161  DEVELOPMENT = "development" 
162  DEFAULT_SERVER_TYPE = FASTCGITCP 
163  ALL_SERVER_TYPES = (FASTCGITCP, FASTCGI, DEVELOPMENT) 
164   
165  DEFAULT_SESSION_ENGINE = 'django.contrib.sessions.backends.file' 
166  SESSION_ENGINE_VALUES = ('django.contrib.sessions.backends.db', 
167                           'django.contrib.sessions.backends.file', 
168                           'django.contrib.sessions.backends.cache', 
169                           'django.contrib.sessions.backends.cached_db') 
170   
171 -def parse_boolean(s):
172 s = s.strip().lower() 173 if s in ('true', '1', 't'): 174 return True 175 return False
176
177 -def parse_paths(s):
178 return [os.path.normpath(path) for path in json.loads(s)]
179
180 -def check_server_type(s):
181 if s not in ALL_SERVER_TYPES: 182 raise ValueError("Unknown server type: %s. Valid values are: %s" % (s, ALL_SERVER_TYPES)) 183 return s
184
185 -def check_session_engine(s):
186 if s not in SESSION_ENGINE_VALUES: 187 raise ValueError("Unknown session engine: %s. Valid values are: %s" % (s, SESSION_ENGINE_VALUES)) 188 return s
189
190 -def identity(x):
191 return x
192
193 -def remove_slash(s):
194 if s is not None and len(s) > 0: 195 if s.endswith("/"): 196 s = s[:-1] 197 return s
198
199 -class LeaveUnset(Exception):
200 pass
201
202 -def leave_none_unset(s):
203 if s is None: 204 raise LeaveUnset() 205 return s
206
207 -def leave_none_unset_int(s):
208 s = leave_none_unset(s) 209 if s is not None: 210 return int(s)
211 212 CUSTOM_SETTINGS_MAPPINGS = { 213 "omero.web.apps": ["ADDITIONAL_APPS", '[]', json.loads], 214 "omero.web.public.enabled": ["PUBLIC_ENABLED", "false", parse_boolean], 215 "omero.web.public.url_filter": ["PUBLIC_URL_FILTER", r'^/(?!webadmin)', re.compile], 216 "omero.web.public.server_id": ["PUBLIC_SERVER_ID", 1, int], 217 "omero.web.public.user": ["PUBLIC_USER", None, leave_none_unset], 218 "omero.web.public.password": ["PUBLIC_PASSWORD", None, leave_none_unset], 219 "omero.web.public.cache.enabled": ["PUBLIC_CACHE_ENABLED", "false", parse_boolean], 220 "omero.web.public.cache.key": ["PUBLIC_CACHE_KEY", "omero.web.public.cache.key", str], 221 "omero.web.public.cache.timeout": ["PUBLIC_CACHE_TIMEOUT", 60 * 60 * 24, int], 222 "omero.web.databases": ["DATABASES", '{}', json.loads], 223 "omero.web.admins": ["ADMINS", '[]', json.loads], 224 "omero.web.application_server": ["APPLICATION_SERVER", DEFAULT_SERVER_TYPE, check_server_type], 225 "omero.web.application_server.host": ["APPLICATION_SERVER_HOST", "0.0.0.0", str], 226 "omero.web.application_server.port": ["APPLICATION_SERVER_PORT", "4080", str], 227 "omero.web.application_server.max_requests": ["APPLICATION_SERVER_MAX_REQUESTS", 400, int], 228 "omero.web.ping_interval": ["PING_INTERVAL", 60000, int], 229 "omero.web.force_script_name": ["FORCE_SCRIPT_NAME", None, leave_none_unset], 230 "omero.web.static_url": ["STATIC_URL", "/static/", str], 231 "omero.web.staticfile_dirs": ["STATICFILES_DIRS", '[]', json.loads], 232 "omero.web.index_template": ["INDEX_TEMPLATE", None, identity], 233 "omero.web.caches": ["CACHES", '{}', json.loads], 234 "omero.web.webgateway_cache": ["WEBGATEWAY_CACHE", None, leave_none_unset], 235 "omero.web.session_engine": ["SESSION_ENGINE", DEFAULT_SESSION_ENGINE, check_session_engine], 236 "omero.web.debug": ["DEBUG", "false", parse_boolean], 237 "omero.upgrades.url": ["UPGRADES_URL", "http://upgrade.openmicroscopy.org.uk/", str], 238 "omero.web.email_host": ["EMAIL_HOST", None, identity], 239 "omero.web.email_host_password": ["EMAIL_HOST_PASSWORD", None, identity], 240 "omero.web.email_host_user": ["EMAIL_HOST_USER", None, identity], 241 "omero.web.email_port": ["EMAIL_PORT", None, identity], 242 "omero.web.email_subject_prefix": ["EMAIL_SUBJECT_PREFIX", "[OMERO.web] ", str], 243 "omero.web.email_use_tls": ["EMAIL_USE_TLS", "false", parse_boolean], 244 "omero.web.logdir": ["LOGDIR", LOGDIR, str], 245 "omero.web.login_view": ["LOGIN_VIEW", "weblogin", str], 246 "omero.web.send_broken_link_emails": ["SEND_BROKEN_LINK_EMAILS", "true", parse_boolean], 247 "omero.web.server_email": ["SERVER_EMAIL", None, identity], 248 "omero.web.server_list": ["SERVER_LIST", '[["localhost", 4064, "omero"]]', json.loads], 249 # Configuration options for the viewer. -1: zoom in fully, 0: zoom out fully, unset: zoom to fit window 250 "omero.web.viewer.initial_zoom_level": ["VIEWER_INITIAL_ZOOM_LEVEL", None, leave_none_unset_int], 251 # the following parameters configure when to show/hide the 'Volume viewer' icon in the Image metadata panel 252 "omero.web.open_astex_max_side": ["OPEN_ASTEX_MAX_SIDE", 400, int], 253 "omero.web.open_astex_min_side": ["OPEN_ASTEX_MIN_SIDE", 20, int], 254 "omero.web.open_astex_max_voxels": ["OPEN_ASTEX_MAX_VOXELS", 27000000, int], # 300 x 300 x 300 255 "omero.web.scripts_to_ignore": ["SCRIPTS_TO_IGNORE", '["/omero/figure_scripts/Movie_Figure.py", '\ 256 '"/omero/figure_scripts/Split_View_Figure.py", "/omero/figure_scripts/Thumbnail_Figure.py", '\ 257 '"/omero/figure_scripts/ROI_Split_Figure.py", "/omero/export_scripts/Make_Movie.py",'\ 258 '"/omero/setup_scripts/FLIM_initialise.py", "/omero/import_scripts/Populate_ROI.py"]', parse_paths], 259 260 # Add links to the top header: links are ['Link Text', 'link'], where the url is reverse("link") OR simply 'link' (for external urls) 261 "omero.web.ui.top_links": ["TOP_LINKS", '[]', json.loads], # E.g. '[["Webtest", "webtest_index"]]' 262 263 # Add plugins to the right-hand & center panels: plugins are ['Label', 'include.js', 'div_id']. The javascript loads data into $('#div_id'). 264 "omero.web.ui.right_plugins": ["RIGHT_PLUGINS", '[["Acquisition", "webclient/data/includes/right_plugin.acquisition.js.html", "metadata_tab"],'\ 265 #'["ROIs", "webtest/webclient_plugins/right_plugin.rois.js.html", "image_roi_tab"],'\ 266 '["Preview", "webclient/data/includes/right_plugin.preview.js.html", "preview_tab"]]', json.loads], 267 268 # E.g. Center plugin: ["Channel overlay", "webtest/webclient_plugins/center_plugin.overlay.js.html", "channel_overlay_panel"] 269 "omero.web.ui.center_plugins": ["CENTER_PLUGINS", '['\ 270 #'["Split View", "webclient/data/includes/center_plugin.splitview.js.html", "split_view_panel"],'\ 271 ']' 272 , json.loads], 273 274 # sharing no longer use this variable. replaced by request.build_absolute_uri 275 # after testing this line should be removed. 276 # "omero.web.application_host": ["APPLICATION_HOST", None, remove_slash], 277 278 # WEBSTART 279 "omero.web.webstart_jar": ["WEBSTART_JAR", "omero.insight.jar", str], 280 "omero.web.webstart_icon": ["WEBSTART_ICON", "webstart/img/icon-omero-insight.png", str], 281 "omero.web.webstart_heap": ["WEBSTART_HEAP", "1024m", str], 282 "omero.web.webstart_host": ["WEBSTART_HOST", "localhost", str], 283 "omero.web.webstart_port": ["WEBSTART_PORT", "4064", str], 284 "omero.web.webstart_class": ["WEBSTART_CLASS", "org.openmicroscopy.shoola.Main", str], 285 "omero.web.webstart_title": ["WEBSTART_TITLE", "OMERO.insight", str], 286 "omero.web.webstart_vendor": ["WEBSTART_VENDOR", "The Open Microscopy Environment", str], 287 "omero.web.webstart_homepage": ["WEBSTART_HOMEPAGE", "http://www.openmicroscopy.org", str], 288 "omero.web.nanoxml_jar": ["NANOXML_JAR", "nanoxml.jar", str], 289 } 290
291 -def process_custom_settings(module):
292 logging.info('Processing custom settings for module %s' % module.__name__) 293 for key, values in getattr(module, 'CUSTOM_SETTINGS_MAPPINGS', {}).items(): 294 # Django may import settings.py more than once, see: 295 # http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html 296 # In that case, the custom settings have already been processed. 297 if len(values) == 4: 298 continue 299 300 global_name, default_value, mapping = values 301 302 try: 303 global_value = CUSTOM_SETTINGS[key] 304 values.append(False) 305 except KeyError: 306 global_value = default_value 307 values.append(True) 308 309 try: 310 setattr(module, global_name, mapping(global_value)) 311 except ValueError: 312 raise ValueError("Invalid %s JSON: %r" % (global_name, global_value)) 313 except LeaveUnset: 314 pass
315 316 process_custom_settings(sys.modules[__name__]) 317 318 319 if not DEBUG: 320 LOGGING['loggers']['django.request']['level'] = 'INFO' 321 LOGGING['loggers']['django']['level'] = 'INFO' 322 LOGGING['loggers']['']['level'] = 'INFO' 323 324 # TEMPLATE_DEBUG: A boolean that turns on/off template debug mode. If this is True, the fancy 325 # error page will display a detailed report for any TemplateSyntaxError. This report contains 326 # the relevant snippet of the template, with the appropriate line highlighted. 327 # Note that Django only displays fancy error pages if DEBUG is True, alternatively error 328 # is handled by: 329 # handler404 = "omeroweb.feedback.views.handler404" 330 # handler500 = "omeroweb.feedback.views.handler500" 331 TEMPLATE_DEBUG = DEBUG 332
333 -def report_settings(module):
334 from django.views.debug import cleanse_setting 335 custom_settings_mappings = getattr(module, 'CUSTOM_SETTINGS_MAPPINGS', {}) 336 for key in sorted(custom_settings_mappings): 337 values = custom_settings_mappings[key] 338 global_name, default_value, mapping, using_default = values 339 source = using_default and "default" or key 340 global_value = getattr(module, global_name, None) 341 if global_name.isupper(): 342 logger.debug("%s = %r (source:%s)", global_name, cleanse_setting(global_name, global_value), source)
343 344 report_settings(sys.modules[__name__]) 345 346 SITE_ID = 1 347 348 # Local time zone for this installation. Choices can be found here: 349 # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE 350 # although not all variations may be possible on all operating systems. 351 # If running in a Windows environment this must be set to the same as your 352 # system time zone. 353 TIME_ZONE = 'Europe/London' 354 FIRST_DAY_OF_WEEK = 0 # 0-Monday, ... 6-Sunday 355 356 # LANGUAGE_CODE: A string representing the language code for this installation. This should be 357 # in standard language format. For example, U.S. English is "en-us". 358 LANGUAGE_CODE = 'en-gb' 359 360 # SECRET_KEY: A secret key for this particular Django installation. Used to provide a seed 361 # in secret-key hashing algorithms. Set this to a random string -- the longer, the better. 362 # django-admin.py startproject creates one automatically. 363 # Make this unique, and don't share it with anybody. 364 SECRET_KEY = '@@k%g#7=%4b6ib7yr1tloma&g0s2nni6ljf!m0h&x9c712c7yj' 365 366 # USE_I18N: A boolean that specifies whether Django's internationalization system should be enabled. 367 # This provides an easy way to turn it off, for performance. If this is set to False, Django will 368 # make some optimizations so as not to load the internationalization machinery. 369 USE_I18N = True 370 371 # MIDDLEWARE_CLASSES: A tuple of middleware classes to use. 372 # See https://docs.djangoproject.com/en/1.3/topics/http/middleware/. 373 MIDDLEWARE_CLASSES = ( 374 'django.middleware.common.CommonMiddleware', 375 'django.contrib.sessions.middleware.SessionMiddleware', 376 #'django.middleware.csrf.CsrfViewMiddleware', 377 'django.contrib.messages.middleware.MessageMiddleware', 378 ) 379 380 381 # ROOT_URLCONF: A string representing the full Python import path to your root URLconf. 382 # For example: "mydjangoapps.urls". Can be overridden on a per-request basis by setting 383 # the attribute urlconf on the incoming HttpRequest object. 384 ROOT_URLCONF = 'omeroweb.urls' 385 386 # STATICFILES_FINDERS: The list of finder backends that know how to find static files 387 # in various locations. The default will find files stored in the STATICFILES_DIRS setting 388 # (using django.contrib.staticfiles.finders.FileSystemFinder) and in a static subdirectory 389 # of each app (using django.contrib.staticfiles.finders.AppDirectoriesFinder) 390 STATICFILES_FINDERS = ( 391 "django.contrib.staticfiles.finders.FileSystemFinder", 392 "django.contrib.staticfiles.finders.AppDirectoriesFinder" 393 ) 394 395 # STATIC_URL: URL to use when referring to static files located in STATIC_ROOT. 396 # Example: "/site_media/static/" or "http://static.example.com/". 397 # If not None, this will be used as the base path for media definitions and the staticfiles 398 # app. It must end in a slash if set to a non-empty value. 399 # This var is configurable by omero.web.static_url STATIC_URL = '/static/' 400 401 # STATIC_ROOT: The absolute path to the directory where collectstatic will collect static 402 # files for deployment. If the staticfiles contrib app is enabled (default) the collectstatic 403 # management command will collect static files into this directory. 404 STATIC_ROOT = os.path.join(os.path.dirname(__file__), 'static').replace('\\','/') 405 406 # STATICFILES_DIRS: This setting defines the additional locations the staticfiles app will 407 # traverse if the FileSystemFinder finder is enabled, e.g. if you use the collectstatic or 408 # findstatic management command or use the static file serving view. 409 if WEBSTART: 410 STATICFILES_DIRS += (("webstart/jars", INSIGHT_JARS),) 411 412 # TEMPLATE_CONTEXT_PROCESSORS: A tuple of callables that are used to populate the context 413 # in RequestContext. These callables take a request object as their argument and return 414 # a dictionary of items to be merged into the context. 415 TEMPLATE_CONTEXT_PROCESSORS = ( 416 "django.core.context_processors.debug", 417 "django.core.context_processors.i18n", 418 "django.core.context_processors.media", 419 "django.core.context_processors.static", 420 "django.contrib.messages.context_processors.messages" 421 ) 422 423 # TEMPLATE_LOADERS: A tuple of template loader classes, specified as strings. Each Loader class 424 # knows how to import templates from a particular source. Optionally, a tuple can be used 425 # instead of a string. The first item in the tuple should be the Loader's module, subsequent items 426 # are passed to the Loader during initialization. 427 TEMPLATE_LOADERS = ( 428 'django.template.loaders.filesystem.Loader', 429 'django.template.loaders.app_directories.Loader', 430 ) 431 432 # TEMPLATE_DIRS: List of locations of the template source files, in search order. Note that these 433 # paths should use Unix-style forward slashes, even on Windows. 434 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". Always use 435 # forward slashes, even on Windows. Don't forget to use absolute paths, not relative paths. 436 # TEMPLATE_DIRS = () 437 438 # INSTALLED_APPS: A tuple of strings designating all applications that are enabled in this Django 439 # installation. Each string should be a full Python path to a Python package that contains 440 # a Django application, as created by django-admin.py startapp. 441 INSTALLED_APPS = ( 442 'django.contrib.staticfiles', 443 'django.contrib.markup', 444 'django.contrib.auth', 445 'django.contrib.contenttypes', 446 'django.contrib.sessions', 447 'django.contrib.sites', 448 'omeroweb.feedback', 449 'omeroweb.webadmin', 450 'omeroweb.webclient', 451 'omeroweb.webgateway', 452 'omeroweb.webtest', 453 'omeroweb.webredirect', 454 'omeroweb.webstart', 455 456 ) 457 458 # ADDITONAL_APPS: We import any settings.py from apps. This allows them to modify settings. 459 # We're also processing any CUSTOM_SETTINGS_MAPPINGS defined there. 460 for app in ADDITIONAL_APPS: 461 # Previously the app was added to INSTALLED_APPS as 'omeroweb.app', which 462 # then required the app to reside within or be symlinked from within 463 # omeroweb, instead of just having to be somewhere on the python path. 464 # To allow apps to just be on the path, but keep it backwards compatible, 465 # try to import as omeroweb.app, if it works, keep that in INSTALLED_APPS, 466 # otherwise add it to INSTALLED_APPS just with its own name. 467 try: 468 __import__('omeroweb.%s' % app) 469 INSTALLED_APPS += ('omeroweb.%s' % app,) 470 except ImportError: 471 INSTALLED_APPS += (app,) 472 try: 473 logger.debug('Attempting to import additional app settings for app: %s' % app) 474 module = __import__('%s.settings' % app) 475 process_custom_settings(module.settings) 476 report_settings(module.settings) 477 except ImportError: 478 logger.debug("Couldn't import settings from app: %s" % app) 479 480 logger.debug('INSTALLED_APPS=%s' % [INSTALLED_APPS]) 481 482 483 # FEEDBACK_URL: Used in feedback.sendfeedback.SendFeedback class in order to submit 484 # error or comment messages to http://qa.openmicroscopy.org.uk. 485 FEEDBACK_URL = "qa.openmicroscopy.org.uk:80" 486 487 # IGNORABLE_404_STARTS: 488 # Default: ('/cgi-bin/', '/_vti_bin', '/_vti_inf') 489 # IGNORABLE_404_ENDS: 490 # Default: ('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico', '.php') 491 492 # SESSION_FILE_PATH: If you're using file-based session storage, this sets the directory in which Django 493 # will store session data. When the default value (None) is used, Django will use the standard temporary 494 # directory for the system. 495 SESSION_FILE_PATH = tempfile.gettempdir() 496 497 # SESSION_EXPIRE_AT_BROWSER_CLOSE: Whether to expire the session when the user closes his or her browser. 498 SESSION_EXPIRE_AT_BROWSER_CLOSE = True # False 499 500 # SESSION_COOKIE_AGE: The age of session cookies, in seconds. See How to use sessions. 501 SESSION_COOKIE_AGE = 86400 # 1 day in sec (86400) 502 503 # FILE_UPLOAD_TEMP_DIR: The directory to store data temporarily while uploading files. 504 FILE_UPLOAD_TEMP_DIR = tempfile.gettempdir() 505 506 # # FILE_UPLOAD_MAX_MEMORY_SIZE: The maximum size (in bytes) that an upload will be before it gets streamed 507 # to the file system. 508 FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440 #default 2621440 (i.e. 2.5 MB). 509 510 # DEFAULT_IMG: Used in webclient.webclient_gateway.OmeroWebGateway.defaultThumbnail in order to load default 511 # image while thumbnail can't be retrieved from the server. 512 DEFAULT_IMG = os.path.join(os.path.dirname(__file__), 'webgateway', 'static', 'webgateway', 'img', 'image128.png').replace('\\','/') 513 514 # # DEFAULT_USER: Used in webclient.webclient_gateway.OmeroWebGateway.getExperimenterDefaultPhoto in order to load default 515 # avatar while experimenter photo can't be retrieved from the server. 516 DEFAULT_USER = os.path.join(os.path.dirname(__file__), 'webgateway', 'static', 'webgateway', 'img', 'personal32.png').replace('\\','/') 517 518 # MANAGERS: A tuple in the same format as ADMINS that specifies who should get broken-link notifications when 519 # SEND_BROKEN_LINK_EMAILS=True. 520 MANAGERS = ADMINS 521 522 # PAGE: Used in varous locations where large number of data is retrieved from the server. 523 try: 524 PAGE 525 except: 526 PAGE = 200 527 528 EMAIL_TEMPLATES = { 529 'create_share': { 530 'html_content':'<p>Hi,</p><p>I would like to share some of my data with you.<br/>Please find it on the <a href="%s?server=%i">%s?server=%i</a>.</p><p>%s</p>', 531 'text_content':'Hi, I would like to share some of my data with you. Please find it on the %s?server=%i. /n %s' 532 }, 533 'add_member_to_share': { 534 'html_content':'<p>Hi,</p><p>I would like to share some of my data with you.<br/>Please find it on the <a href="%s?server=%i">%s?server=%i</a>.</p><p>%s</p>', 535 'text_content':'Hi, I would like to share some of my data with you. Please find it on the %s?server=%i. /n %s' 536 }, 537 'remove_member_from_share': { 538 'html_content':'<p>You were removed from the share <a href="%s?server=%i">%s?server=%i</a>. This share is no longer available for you.</p>', 539 'text_content':'You were removed from the share %s?server=%i. This share is no longer available for you.' 540 }, 541 'add_comment_to_share': { 542 'html_content':'<p>New comment is available on share <a href="%s?server=%i">%s?server=%i</a>.</p>', 543 'text_content':'New comment is available on share %s?server=%i.' 544 } 545 } 546 547 # Load server list and freeze 548 from connector import Server
549 -def load_server_list():
550 for s in SERVER_LIST: 551 server = (len(s) > 2) and unicode(s[2]) or None 552 Server(host=unicode(s[0]), port=int(s[1]), server=server) 553 Server.freeze()
554 load_server_list() 555