| 1 | | = Reducing Redundant Code in s3cfg.py and 000_config = |
| 2 | | |
| 3 | | There has to be a file that will run before s3cfg or even 000_config . |
| 4 | | So it can be used in init only if |
| 5 | | there is no 000_config in the models(i.e for the first time) |
| 6 | | |
| 7 | | == Initialy in s3cfg2.py == |
| 8 | | |
| 9 | | {{{ |
| 10 | | #!python |
| 11 | | class S3Config(Storage): |
| 12 | | |
| 13 | | """ |
| 14 | | Deployment Settings Helper Class |
| 15 | | |
| 16 | | """ |
| 17 | | |
| 18 | | def __init__(self, T): |
| 19 | | self.auth = Storage() |
| 20 | | self.base = Storage() |
| 21 | | self.database = Storage() |
| 22 | | self.gis = Storage() |
| 23 | | self.mail = Storage() |
| 24 | | self.twitter = Storage() |
| 25 | | self.L10n = Storage() |
| 26 | | self.osm = Storage() |
| 27 | | self.security = Storage() |
| 28 | | self.ui = Storage() |
| 29 | | self.T = T |
| 30 | | |
| 31 | | }}} |
| 32 | | |
| 33 | | == Code in the New file == |
| 34 | | |
| 35 | | Dict of Settings:- |
| 36 | | .Algo :- |
| 37 | | |
| 38 | | {{{ |
| 39 | | Settings = {"databse.db_type" : {"nice_name" :T("Database"), |
| 40 | | "description":T("Database Type: "), |
| 41 | | "input_type":"select", |
| 42 | | "options":['sqlite', 'sql', 'mysql'], |
| 43 | | "jquery_validation_requirements”: "required lettersonly" |
| 44 | | }, |
| 45 | | #and similarly other options for language can be set |
| 46 | | } |
| 47 | | }}} |
| 48 | | |
| 49 | | for creating s3cfg.py |
| 50 | | |
| 51 | | .Algo:- |
| 52 | | {{{ |
| 53 | | }}} |