wiki:GSOCWebSetupImplementation

Version 9 (modified by anubhav, 11 years ago) ( diff )

--

WEB SETUP IMPLEMENTATION (Detail)

MODULES

Layout.py

Def setting():

These will be imported into the models so will run before the models and for the first time only The settings layout needs to be stored in here. The settings is a dict with keys as the:

“categary”.”field_id”

Like:-

 Settings = {"databse.db_type" : {"nice_name" :T("Database"), 
                                  "description":T("Database Type: "), 
                                  "input_type":"select", 
                                  "options":['sqlite', 'sql', 'mysql'],
                                  "jquery_validation_requirements”: "required lettersonly"
                                 },
             #and similarly other options for language can be set
            } 
        

These are really useful for views as this provide the information regarding input type, the value to select from, the field name and the validation requirement. These layouts are mostly for the views. Some of these like port will also contain a validation field for the range of accepted values.

We will have to set the settings in accordance with modules/s3/s3cfg.py.

Def modules() :

These needs to store the names of the modules:-

modules = {
      "default":True,
      "admin":True,
      "gis":True,
}
#true meaning "on"

Here the “on” indicate that the default value of the module status is on.

In the modules the layout is not required, as they are stored when we run the modified form of 000_config in the models. The input types of these (name, Description, Access level) are quite fixed so they need not to be stored separately. Therefore not much help is required for the views to.

MODELS

1st_run.py (This will run before the modified version of 000_config)

Session variable : session.path_to_config

This will initialize a session variable that will help us get the status of the selector. If the session variable is “none” we can initialize it to “”, and later in the controller it can be set to the path of 000_config of that particular eden they want the to the web-setup to run on. This session variable will help us to get the path of the 000_config from the controllers.

Parsing 000_config.py

Once we get the path of 000_config we need to copy that file in the websetup models by the the name of modified_config.py so that it shall run after this file closes. Now open modified_config using os.path.join in the “w” mode and 000_config in the “r” mode. We need to read 000_config and This would result in the creation of 2 dicts one is deployment_settings and the other one is for the modules deployment_settings.modules .Now 6th and 7th steps will help us to maintain the dicts for modules that were turned off by commenting them.

---------------------------------------------------------------------------------------------------------------------------------------------------------

1.Remove the line containing “s3base.s3config(” from the starting of the file

 

2. Insert

“ from gluon.storage import Storage

from gluon.contrib.simplejson.ordered_dict import OrderedDict

deployment_settings = Storage( “   

before the first line where they find  “deployment_settings.” Without a “#”  in the 000_config.py           

3. And add “ ) ” Immediately before the import of storage and remove the import of storage from there

 

4. Add 4 spaces to each line between “Storage(“ and “)” even the commented ones

 

5. Make the following to the lines except the ones containing “#” before the use of “deployment_settings.” 

v  Wrap each word containing “deployment_settings.” with “”

v  Add a  “,”(coma) after the line

 

6. Check if the    

“<?module_name?> = Storage( \n” has a “#” in the same line then turn

module[module_name] ( variable in layout.py in modules )   off .

 

7.Remove “#” from there till the line you get “#),”

----------------------------------------------------------------------------------------------------------------------------------------------------------

Handling database conflicts

There should be a list that will keep a list of databse_name and database_types of 2 eden application cannot be same at same time therefore a list of database types and databse names needs to be made

  • For this we will first have to generate a list paths .We can search for “Copyright: 2010 (c) Sahana Software Foundation” in all the LICENSE files of applications.

Then we will have to search in the list of paths for specific keywords like “deployment_setting.database.database” This can be done using regex command in grep

If  path(variable) is in the list of paths containing: 
    Command_line = “grep ” +  “deployment_setting.database.database” + “path”
    Line = subprocess.Popen(command_line); 

Now search the file for deployment_settings.database.db_type .These list will help in validating for the database values.

Note: See TracWiki for help on using the wiki.