Exemple #1
0
 def process_core(self, request):
     # Display the menu
     if request.has_key('menu'):
         return CoreDisplay().menu(mod.ModuleHome().get_menu())
     # Display the introduction page
     if request.has_key('introduction'):
         return CoreDisplay().default()
     xml = CoreDisplay().menu(mod.ModuleHome().get_menu())
     xml += CoreDisplay().default()
     return xml
Exemple #2
0
 def default(self):
     status = mod.ModuleHome().module_status(config['workflow']['default'])
     Common().add_to_log(
         "2", "Application",
         "Module: " + config['workflow']['default'] + " Status: " + status)
     if status == "active":
         modx = __import__(config['workflow']['default'])
         xml = modx.Main().process_request()
         return xml
Exemple #3
0
    def _process_modules(self):
        response = ''
        for k, v in self.doc['module'].iteritems():
            if k == 'core':
                response += core.Core().process_core(v)
            else:
                status = mod.ModuleHome().module_status(k)
                core.Common().add_to_log("2", "Application",
                                         "Module: " + k + " Status: " + status)
                if status == "active":
                    modx = __import__(k)
                    response += modx.Main().process_request(v)

        return response
Exemple #4
0
 def process_request(self, request):
     xml = ''
     if request.has_key('modules'):
         modules = mod.ModuleHome().get_all_modules()
         installed = mod.ModuleHome().get_available_modules()
         xml += AdminDisplay().modules(modules, installed)
     if request.has_key('view_module'):
         module_name = request['view_module']['action']
         module = mod.ModuleHome().get_module(module_name)
         xml += AdminDisplay().view_module(module)
     if request.has_key('install_module'):
         module_name = request['install_module']['action']
         module = mod.ModuleHome().get_module(module_name)
         module['status'] = 'active'
         mod.ModuleHome().new_module(module)
         xml += AdminDisplay().view_module(module)
     if request.has_key('users'):
         userlist = users.UserHome().get_users()
         xml += AdminDisplay().users(userlist)
     if request.has_key('view_module'):
         module_name = request['view_module']['action']
         module = mod.ModuleHome().get_module(module_name)
         xml += AdminDisplay().view_module(module)
     return xml
Exemple #5
0
    def process_request(self, request=None):
        xml = ''
        if request == None or request.has_key('sources'):
            #List data sources
            modules = mod.ModuleHome().get_modules_by_type('Data Source')
            objects = {}
            try:
                for module in modules:
                    current_objects = Catalogue().get_objects_by_module(
                        module['module_id'])
                    objects[module['name']] = current_objects
                    ###??? - run getCount for each object###
                xml += CatalogueDisplay().sources(objects, modules)
            except TypeError:
                pass
        try:
            if request.has_key('consolidation'):
                pass
            if request.has_key('targets'):
                pass
            if request.has_key('deletesource'):
                CatalogueHome().delete(request['deletesource']['action'])
            if request.has_key('dd_viewrecord'):
                object = request['dd_viewrecord']['action'].split()
                record = CatalogueHome().get_object(object[0], object[1],
                                                    object[2], object[3])
                xml += CatalogueDisplay().viewrecord(record, object[0],
                                                     object[1], object[2])
            if request.has_key('dd_editrecord'):
                object = request['dd_editrecord']['column_id'].split()
                values = CatalogueHome().get_object(object[0], object[1],
                                                    object[2], object[3])
                values['human_name'] = request['dd_editrecord']['colhname']
                values['description'] = request['dd_editrecord']['coldesc']
                values['data_type'] = request['dd_editrecord']['coltype']
                values['key_type'] = request['dd_editrecord']['colkey']
                values['example'] = request['dd_editrecord']['colex']
                CatalogueHome().synchronise(values)
            if request.has_key('datadictionary'):
                #display the data dictionary for the object
                cathome = CatalogueHome()
                obj = request['datadictionary']['action']
                object = cathome.get_object(obj)
                databases = cathome.get_objects_by_parent(obj)
                rows = {}
                #Build the data dictionary list to pass to the XML generator
                #Iterate through all databases in the object. Usually only one
                for database in databases:
                    db = database['database_id']
                    tables = cathome.get_objects_by_parent(obj, db)
                    rows[db] = {}
                    #Iterate through all tables in the database
                    for table in tables:
                        tab = table['table_id']
                        ###TODO: COUNT ROWS###
                        columns = cathome.get_objects_by_parent(obj, db, tab)
                        rows[db][tab] = {}
                        #Iterate through all columns in the table
                        try:
                            for column in columns:
                                col = column['column_id']
                                rows[db][tab][col] = column
                        except TypeError:
                            pass
                xml += CatalogueDisplay().datadictionary(
                    rows, object['type'], obj)
            if request.has_key('addnewsource'):
                if request['addnewsource'].has_key('aname'):
                    #Save the new catalogue object
                    moduleHome = mod.ModuleHome()
                    module = moduleHome.get_module(
                        request['addnewsource']['action'])
                    cat = {}
                    cat['name'] = request['addnewsource']['aname']
                    cat['module_id'] = request['addnewsource']['action']
                    cat['type'] = module['subtype']
                    object = CatalogueHome().new_object(
                        cat, 'object_object_id_seq')
                    #Display the main source list.
                    module = moduleHome.runModule(
                        request['addnewsource']['action'])
                    module.createSource(request['addnewsource'], object)

                elif request['addnewsource']['action'] != '':
                    #Display the new object form
                    module = mod.ModuleHome().runModule(
                        request['addnewsource']['action'])
                    params = module.sourceParams()
                    name = module.name
                    xml += CatalogueDisplay().newsource(
                        params, request['addnewsource']['action'], name)
            if request.has_key('editsource'):
                cathome = CatalogueHome()
                obj = request['editsource']['action']
                object = cathome.get_object(obj)
                databases = cathome.get_objects_by_parent(obj)
                if request['editsource'].has_key('aname'):
                    #Save the new catalogue object
                    moduleHome = mod.ModuleHome()
                    module = moduleHome.get_module(
                        request['editsource']['action'])
                    cat = {}
                    cat['name'] = request['editsource']['aname']
                    cat['module_id'] = request['editsource']['action']
                    cat['type'] = module['subtype']
                    object = CatalogueHome().new_object(
                        cat, 'object_object_id_seq')
                    #Display the main source list.
                    module = moduleHome.runModule(
                        request['editsource']['action'])
                    module.createSource(request['editsource'], object)

                else:
                    #Display the new object form
                    module = mod.ModuleHome().runModule(object['module_id'])
                    params = module.sourceParams()
                    name = module.name
                    xml += CatalogueDisplay().editsource(
                        params, databases, request['editsource']['action'],
                        name)
        except AttributeError:
            pass
        return xml