Changeset 3360
- Timestamp:
- 09/12/07 07:07:17 (1 year ago)
- Files:
-
- trunk/dabo/__init__.py (modified) (4 diffs)
- trunk/dabo/dApp.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/__init__.py
r3348 r3360 164 164 165 165 166 # Define the standard Dabo subdirectory stucture for apps. 167 def _getAppDirectoryNames(): 168 return ("biz", "db", "ui", "resources", "reports") 169 170 166 171 # Method to create a standard Dabo directory structure layout 167 172 def makeDaboDirectories(homedir=None): 168 """If homedir is passe s, the directories will be created off of that173 """If homedir is passed, the directories will be created off of that 169 174 directory. Otherwise, it is assumed that they should be created 170 175 in the current directory location. … … 173 178 if homedir is not None: 174 179 os.chdir(homedir) 175 for d in ("biz", "db", "ui", "resources", "reports"):180 for d in _getAppDirectoryNames(): 176 181 if not os.path.exists(d): 177 182 os.mkdir(d) … … 185 190 currLoc = os.getcwd() 186 191 if homedir is not None: 192 if not os.path.exists(homedir): 193 os.makedirs(homedir) 187 194 os.chdir(homedir) 188 195 makeDaboDirectories() … … 190 197 # -*- coding: utf-8 -*- 191 198 import dabo 199 dabo.ui.loadUI("wx") 192 200 193 201 app = dabo.dApp() 202 203 # IMPORTANT! Change app.MainFormClass value to the name 204 # of the form class that you want to run when your 205 # application starts up. 206 app.MainFormClass = dabo.ui.dFormMain 207 194 208 app.start() 195 209 """) 210 211 template = """#!/usr/bin/env python 212 # -*- coding: utf-8 -*- 213 ###### 214 # In order for Dabo to 'see' classes in your %(dd)s directory, add an 215 # import statement here for each class. E.g., if you have a file named 216 # 'MyClasses.py' in this directory, and it defines two classes named 'FirstClass' 217 # and 'SecondClass', add these lines: 218 # 219 # from MyClass import FirstClass 220 # from MyClass import SecondClass 221 # 222 # Now you can refer to these classes as: self.Application.%(dd)s.FirstClass and 223 # self.Application.%(dd)s.SecondClass 224 ###### 225 226 """ 227 for dd in dabo._getAppDirectoryNames(): 228 fname = "%s/__init__.py" % dd 229 txt = template % locals() 230 open(fname, "w").write(txt) 196 231 os.chmod("main.py", 0744) 197 232 os.chdir(currLoc) 198 trunk/dabo/dApp.py
r3333 r3360 14 14 import dabo.ui 15 15 import dabo.db 16 import dLocalize17 16 from dabo.dLocalize import _ 18 17 from dabo.lib.connParser import importConnections 19 from dabo import dLocalize 20 import dSecurityManager 18 from dabo import dSecurityManager 21 19 from dabo.lib.SimpleCrypt import SimpleCrypt 22 20 from dabo.dObject import dObject 23 import dUserSettingProvider21 from dabo import dUserSettingProvider 24 22 25 23 … … 236 234 dLocalize.setLanguage(lang, charset) 237 235 236 self._initModuleNames() 238 237 self._initDB() 239 238 … … 599 598 connDefs = {} 600 599 601 # Import any .cnxml files in HomeDir and/or HomeDir/db: 602 for dbDir in (os.path.join(self.HomeDirectory, "db"), self.HomeDirectory): 600 # Import any .cnxml files in the following locations: 601 # HomeDir 602 # HomeDir/db 603 # HomeDir/data 604 # os.getcwd() 605 # os.getcwd()/db 606 # os.getcwd()/data 607 hd = self.HomeDirectory 608 cwd = os.getcwd() 609 dbDirs = (hd, os.path.join(hd, "db"), os.path.join(hd, "data"), 610 cwd, os.path.join(cwd, "db"), os.path.join(cwd, "data")) 611 for dbDir in dbDirs: 603 612 if os.path.exists(dbDir) and os.path.isdir(dbDir): 604 613 files = glob.glob(os.path.join(dbDir, "*.cnxml")) … … 629 638 dabo.infoLog.write(_("%s database connection definition(s) loaded.") 630 639 % (len(self.dbConnectionDefs))) 640 641 642 def _initModuleNames(self): 643 """Import the common application-level module names into attributes 644 of this application object, so that the app code can easily reference them. 645 Example: f there is a 'biz' directory that can be imported, other objects in 646 the system can reference bizobjs using the 'self.Application.biz' syntax 647 """ 648 for dd in ("biz", "db", "ui", "resources", "reports"): 649 try: 650 self.__setattr__(dd, __import__(dd, level=0)) 651 except: 652 self.__setattr__(dd, None) 631 653 632 654
