예제 #1
0
파일: dojo_base.py 프로젝트: unbit/genropy
    def init(self, **kwargs):
        self.dojo_static_handler = self.page.site.getStatic('dojo')
        dojo_theme = getattr(
            self.page, 'dojo_theme',
            None) or self.page.site.config['dojo?theme'] or 'tundra'
        self._theme = dojo_theme
        self.dojo_version = self.page.dojo_version
        self.dojo_release = None
        if boolean(self.page.dojo_source):
            dojofolder = 'dojo_src'
            if not os.path.exists(
                    self.dojo_static_handler.path(self.dojo_version,
                                                  dojofolder)):
                dojofolder = 'dojo'

    #elif not boolean(self.page.isDeveloper()):
    #    dojofolder = 'dojo_release'
    #    self.dojo_release= True
    #    if not os.path.exists(self.dojo_static_handler.path(self.dojo_version, dojofolder)):
    #        dojofolder = 'dojo'
    #        self.dojo_release= False
        else:
            dojofolder = 'dojo'
        dojolib = self.dojo_static_handler.url(self.dojo_version, dojofolder,
                                               'dojo', 'dojo.js')
        self.dojofolder = dojofolder
        self.dojolib = dojolib
        self.djConfig = "parseOnLoad: false, isDebug: %s, locale: '%s' ,noFirebugLite:true" % (
            self.page.isDeveloper() and 'true'
            or 'false', self.page.locale.lower())
예제 #2
0
 def init(self, **kwargs):
     self.dojo_static_handler = self.page.site.getStatic('dojo')
     dojo_theme = getattr(self.page, 'dojo_theme', None) or self.page.site.config['dojo?theme'] or 'tundra'
     self._theme = dojo_theme
     self.dojo_version = self.page.dojo_version
     if boolean(self.page.dojo_source):
         dojofolder = 'dojo_src'
         if not os.path.exists(self.dojo_static_handler.path(self.dojo_version, dojofolder)):
             dojofolder = 'dojo'
     else:
         dojofolder = 'dojo'
     dojolib = self.dojo_static_handler.url(self.dojo_version, dojofolder, 'dojo', 'dojo.js')
     self.dojolib = dojolib
     self.djConfig = "parseOnLoad: false, isDebug: %s, locale: '%s' ,noFirebugLite:true" % (
     self.page.isDeveloper() and 'true' or 'false', self.page.locale)
예제 #3
0
 def __init__(self, script_path, site_name=None, _config=None, _gnrconfig=None, counter=None, noclean=None,
              options=None):
     global GNRSITE
     GNRSITE = self
     counter = int(counter or '0')
     self._currentPages = {}
     abs_script_path = os.path.abspath(script_path)
     if os.path.isfile(abs_script_path):
         self.site_path = os.path.dirname(abs_script_path)
     else:
         self.site_path = PathResolver().site_name_to_path(script_path)
     self.site_name = site_name or os.path.basename(self.site_path)
     if _gnrconfig:
         self.gnr_config = _gnrconfig
     else:
         self.gnr_config = self.load_gnr_config()
         self.set_environment()
         
     if _config:
         self.config = _config
     else:
         self.config = self.load_site_config()
         
     self.default_uri = self.config['wsgi?home_uri'] or '/'
     if self.default_uri[-1] != '/':
         self.default_uri += '/'
     self.mainpackage = self.config['wsgi?mainpackage']
     self.default_page = self.config['wsgi?default_page']
     self.allConnectionsFolder = os.path.join(self.site_path, 'data', '_connections')
     self.allUsersFolder = os.path.join(self.site_path, 'data', '_users')
     
     self.homepage = self.config['wsgi?homepage'] or self.default_uri + 'index'
     self.indexpage = self.config['wsgi?homepage'] or '/index'
     self._guest_counter = 0
     if not self.homepage.startswith('/'):
         self.homepage = '%s%s' % (self.default_uri, self.homepage)
     self.secret = self.config['wsgi?secret'] or 'supersecret'
     self.config['secret'] = self.secret
     self.debug = options.debug if options else boolean(self.config['wsgi?debug'])
     self.cache_max_age = self.config['wsgi?cache_max_age'] or 2592000
     self.statics = StaticHandlerManager(self)
     self.statics.addAllStatics()
     
     self.gnrapp = self.build_gnrapp()
     self.wsgiapp = self.build_wsgiapp()
     self.db = self.gnrapp.db
     self.dbstores = self.db.dbstores
     self.resource_loader = ResourceLoader(self)
     self.pages_dir = os.path.join(self.site_path, 'pages')
     self.site_static_dir = self.config['resources?site'] or '.'
     if self.site_static_dir and not os.path.isabs(self.site_static_dir):
         self.site_static_dir = os.path.normpath(os.path.join(self.site_path, self.site_static_dir))
     self.find_gnrjs_and_dojo()
     self.page_factory_lock = RLock()
     self.webtools = self.resource_loader.find_webtools()
     self.services = ServiceHandlerManager(self)
     self.print_handler = self.addService(PrintHandler, service_name='print')
     self.mail_handler = self.addService(MailHandler, service_name='mail')
     self.addSiteServices()
     self.register = SiteRegister(self)
     if counter == 0 and self.debug:
         self.onInited(clean=not noclean)