Beispiel #1
0
    def __init__(self, config = {}):
        """
        __DatabasePage__

        A page with a database connection (a WMCore.Database.DBFormatter) held
        in self.dbi. Look at the DBFormatter class for other handy helper
        methods, such as getBinds and formatDict.

        The DBFormatter class was originally intended to be extensively
        sub-classed, such that it's subclasses followed the DAO pattern. For web
        tools we do not generally do this, and you will normally access the
        database interface directly:

        binds = {'id': 123}
        sql = "select * from table where id = :id"
        result = self.dbi.processData(sql, binds)
        return self.formatDict(result)

        Although following the DAO pattern is still possible and encouraged
        where appropriate. However, if you want to use the DAO pattern it may be
        better to *not* expose the DAO classes and have a normal DatabasePage
        exposed that passes the database connection to all the DAO's.
        """
        TemplatedPage.__init__(self, config)
        dbConfig = ConfigDBMap(config)
        conn = DBFactory(self, dbConfig.getDBUrl(), dbConfig.getOption()).connect()
        DBFormatter.__init__(self, self, conn)
        myThread = threading.currentThread()
        myThread.transaction = Transaction(conn)
        myThread.transaction.commit()
        return
Beispiel #2
0
    def __init__(self, config):
        TemplatedPage.__init__(self, config)
        dbs = config.section_('dbs')
        phedex = config.section_('phedex')
        dbsconfig = {'dbs':dbs.url, 'dbsinst':dbs.instance,
                  'dbsparams':dbs.params, 'phedex':phedex.url}
        self.dbs = DBS(dbsconfig)
        self.securityApi    = ""
        self.fmConfig       = config.section_('fmws')
        self.verbose        = self.fmConfig.verbose
        self.day_transfer   = self.fmConfig.day_transfer
        self.max_transfer   = self.fmConfig.max_transfer
        self.file_manager   = config.section_('file_manager')
        self.transfer_dir   = self.file_manager.base_directory
        self.download_dir   = self.fmConfig.download_area
        self.fmgr = FileManager()
        self.fmgr.configure(fm_config(config))
        self.voms_timer     = 0
        self.userDict       = {}
        self.userDictPerDay = {}
        self.url            = "/filemover"

        # prevent users from partial retrieval requests
        cherrypy.response.headers['Accept-Ranges'] = 'none'

        # internal settings
        self.base   = '' # defines base path for HREF in templates
        self.imgdir = '%s/%s' % (__file__.rsplit('/', 1)[0], 'images')
        if  not os.path.isdir(self.imgdir):
            self.imgdir = os.environ['FM_IMAGESPATH']
        self.cssdir = '%s/%s' % (__file__.rsplit('/', 1)[0], 'css')
        if  not os.path.isdir(self.cssdir):
            self.cssdir = os.environ['FM_CSSPATH']
        self.jsdir  = '%s/%s' % (__file__.rsplit('/', 1)[0], 'js')
        if  not os.path.isdir(self.jsdir):
            self.jsdir = os.environ['FM_JSPATH']
        if  not os.environ.has_key('YUI_ROOT'):
            msg = 'YUI_ROOT is not set'
            raise Exception(msg)
        self.yuidir = os.environ['YUI_ROOT']

        # To be filled at run time
        self.cssmap = {}
        self.jsmap  = {}
        self.imgmap = {}
        self.yuimap = {}
        self.cache  = {}

        # Update CherryPy configuration
        mime_types  = ['text/css']
        mime_types += ['application/javascript', 'text/javascript',
                       'application/x-javascript', 'text/x-javascript']
        cherryconf.update({'tools.encode.on': True, 
                           'tools.gzip.on': True,
                           'tools.gzip.mime_types': mime_types,
                           'tools.etags.on' : False,
                          })
    def __init__(self, config):
        self.supporttypes = {'application/xml': self.xml,
                   'application/atom+xml': self.atom,
                   'text/json': self.json,
                   'text/x-json': self.json,
                   'application/json': self.json,
                   'text/html': self.to_string,
                   'text/plain': self.to_string,
                   '*/*': self.to_string}

        TemplatedPage.__init__(self, config)
Beispiel #4
0
    def __init__(self, config):
        self.supporttypes = {'application/xml': self.xml,
                   'application/atom+xml': self.atom,
                   'text/json': self.json,
                   'text/x-json': self.json,
                   'application/json': self.json,
                   'text/html': self.to_string,
                   'text/plain': self.to_string,
                   '*/*': self.to_string}

        TemplatedPage.__init__(self, config)
Beispiel #5
0
 def __init__(self, config):
     TemplatedPage.__init__(self, config)
     Controllers.__init__(self, config)
Beispiel #6
0
 def __init__(self, config = {}):
     TemplatedPage.__init__(self, config)
     self.yuiregistry = YUIRegistry(config.yui)
     self.yuiroot = self.yuiregistry.register('YUIRoot')
     self.dialog()
Beispiel #7
0
 def __init__(self, config):
     TemplatedPage.__init__(self, config)
     Controllers.__init__(self, config)