dabo Commit
Revision 3194
Date: 2007-06-21 20:22:09 -0700 (Thu, 21 Jun 2007)
Author: Dj
Trac: http://svn.dabodev.com/trac/dabo/changeset/3194
Changed:
U trunk/dabo/__init__.py
U trunk/dabo/dApp.py
U trunk/dabo/dEvents.py
U trunk/dabo/dObject.py
U trunk/dabo/dPref.py
U trunk/dabo/db/dBackend.py
U trunk/dabo/db/dConnectInfo.py
U trunk/dabo/db/dCursorMixin.py
U trunk/dabo/db/dDataSet.py
U trunk/dabo/db/dbFirebird.py
U trunk/dabo/lib/EasyDialogBuilder.py
U trunk/dabo/lib/datanav/Page.py
U trunk/dabo/lib/eventMixin.py
U trunk/dabo/lib/logger.py
U trunk/dabo/ui/__init__.py
U trunk/dabo/ui/dDataControlMixinBase.py
U trunk/dabo/ui/uitk/__init__.py
U trunk/dabo/ui/uitk/dFormMixin.py
U trunk/dabo/ui/uitk/dPemMixin.py
U trunk/dabo/ui/uitk/uiApp.py
U trunk/dabo/ui/uiwx/__init__.py
U trunk/dabo/ui/uiwx/dComboBox.py
U trunk/dabo/ui/uiwx/dControlItemMixin.py
U trunk/dabo/ui/uiwx/dDataControlMixin.py
U trunk/dabo/ui/uiwx/dDateTextBox.py
U trunk/dabo/ui/uiwx/dDockForm.py
U trunk/dabo/ui/uiwx/dEditor.py
U trunk/dabo/ui/uiwx/dFoldPanelBar.py
U trunk/dabo/ui/uiwx/dFont.py
U trunk/dabo/ui/uiwx/dForm.py
U trunk/dabo/ui/uiwx/dFormMixin.py
U trunk/dabo/ui/uiwx/dGrid.py
U trunk/dabo/ui/uiwx/dGridSizer.py
U trunk/dabo/ui/uiwx/dImage.py
U trunk/dabo/ui/uiwx/dListControl.py
U trunk/dabo/ui/uiwx/dPemMixin.py
U trunk/dabo/ui/uiwx/dRadioList.py
U trunk/dabo/ui/uiwx/dSizerMixin.py
U trunk/dabo/ui/uiwx/masked/maskededit.py
U trunk/dabo/ui/uiwx/uiApp.py
Log:
Modified the Log class to contain levels (Database Activity, Debug, Info,
Error, Exception, Critical), as well as be accessed directly by
dabo.logInfo("msg") or dabo.logError("msg") or dabo.logDBActivity("msg").
All of the dabo.logXXX methods also accept a second bool argument, which if
True, will output the message to the console reguardless of the logLevel
Added two new methods addLogLevel and delLogLevel, which accept a single
argument, and will add or remove that log type from the log level.
new method addCustomType will allow people to add their own log types to the
logging system.
Diff:
Modified: trunk/dabo/__init__.py
===================================================================
--- trunk/dabo/__init__.py 2007-06-21 20:39:18 UTC (rev 3193)
+++ trunk/dabo/__init__.py 2007-06-22 03:22:09 UTC (rev 3194)
@@ -3,18 +3,18 @@
Dabo is for developing multi-platform database business applications -
you know, applications that need to connect to a database server (MySQL,
-Oracle, MS-SQL, whatever), get recordsets of data based on criteria
-set by the user, provide easy ways to edit and commit changes to the
+Oracle, MS-SQL, whatever), get recordsets of data based on criteria
+set by the user, provide easy ways to edit and commit changes to the
data, and to report on the data.
-For basic, easy use that hopefully satisfies 80% of your needs, you
+For basic, easy use that hopefully satisfies 80% of your needs, you
simply create/edit data definition files that Dabo uses to dynamically
create things like menus, edit forms, data browsing grids, etc.
So, the basic idea is that you have a functional, working, albeit basic
-application up and running very quickly, and you can then spend time
-getting all the fancy bells and whistles implemented. Keep things as
-simple as possible though, while still fulfilling your customer's
+application up and running very quickly, and you can then spend time
+getting all the fancy bells and whistles implemented. Keep things as
+simple as possible though, while still fulfilling your customer's
specifications. Simplicity is the better part of elegance.
Beyond the wizards and xml definition files, Dabo exposes a nice
@@ -35,8 +35,8 @@
The Dabo framework will have to be distributed to your client's machine(s),
along with your project-specific data definitions and (if applicable), your
-subclasses of the Dabo classes and additional Python scripts, if any. There
-are ways to do runtime deployment via installers that take the complexity
+subclasses of the Dabo classes and additional Python scripts, if any. There
+are ways to do runtime deployment via installers that take the complexity
out of this, but that is outside the scope of Dabo itself, and you'll use
a different method for each target platform.
@@ -48,32 +48,32 @@
nature of Dabo's design, it is possible to use just the
db layer, or the db layer in conjunction with the biz
layer, with no ui at all.)
-
- + SQLite3: this is used internally for managing preferences, as
+
+ + SQLite3: this is used internally for managing preferences, as
well as for cursor management.
-
- + pysqlite2: The Python dbapi module for SQLite. (Not needed in
+
+ + pysqlite2: The Python dbapi module for SQLite. (Not needed in
Python 2.5 and higher)
+ Windows 98SE or higher
+ Macintosh OSX 10.2 or higher (*much* nicer in Tiger - 10.4)
+ Linux 2.4 with X11 running and Gtk2
- + Access to some sort of database server, along with the
+ + Access to some sort of database server, along with the
appropriate Python driver(s) installed. For example, for
MySQL you'll need to have the MySQL client libraries
installed, as well as the MySQLDb Python module. (Dabo
does not use ODBC: it connects directly using the Python
DB API coupled with the individual database drivers. This
is, at the same time, less flexible, tougher to get started
- with, but more capable, more multi-platform, and better
+ with, but more capable, more multi-platform, and better
performing, than ODBC is.) (we recommend starting with MySQL
installed, because all of the demo code has the best support
for MySQL).
How you get started is pretty much up to you. Look at the code in the
separate dabodemo project. Run the AppWizard in the separate daboide
-project. Hand-edit the data definition files and Python code that the
+project. Hand-edit the data definition files and Python code that the
AppWizard generates for you.
For some quick eye-candy, once you've installed Dabo using the standard
@@ -97,7 +97,7 @@
print tb.Value
-Have fun in your exploration of Dabo.
+Have fun in your exploration of Dabo.
"""
import sys
@@ -115,7 +115,7 @@
SQLite: http://www.sqlite.org/download.html
pysqlite2: http://initd.org/tracker/pysqlite
-"""
+"""
sys.exit(msg)
# dApp will change the following values upon its __init__:
@@ -124,17 +124,29 @@
# Instantiate the logger object, which will send messages to user-overridable
# locations. Do this before any other imports.
from dabo.lib.logger import Log
-infoLog = Log()
-infoLog.Caption = "Dabo Info Log"
-infoLog.LogObject = sys.stdout
-errorLog = Log()
-errorLog.Caption = "Dabo Error Log"
-errorLog.LogObject = sys.stderr
-# This log is set to None by default. It must be manually activated
+log = Log()
+log.LogObject = sys.stdout
+logDebug = log.logDebug
+logInfo = log.logInfo
+logError = log.logError
+logException = log.logException
+logCritical = log.logCritical
+logDBActivity = log.logDBActivity
+addLogLevel = log.addLogLevel
+delLogLevel = log.delLogLevel
+
+
+#infoLog = Log()
+#infoLog.Caption = "Dabo Info Log"
+#infoLog.LogObject = sys.stdout
+#errorLog = Log()
+#errorLog.Caption = "Dabo Error Log"
+#errorLog.LogObject = sys.stderr
+# This log is set to None by default. It must be manually activated
# via the Application object.
-dbActivityLog = Log()
-dbActivityLog.Caption = "Database Activity Log"
-dbActivityLog.LogObject = None
+#dbActivityLog = Log()
+#dbActivityLog.Caption = "Database Activity Log"
+#dbActivityLog.LogObject = None
# Import global settings (do this first, as other imports may rely on it):
from settings import *
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py 2007-06-21 20:39:18 UTC (rev 3193)
+++ trunk/dabo/dApp.py 2007-06-22 03:22:09 UTC (rev 3194)
@@ -27,8 +27,8 @@
def add(self, objRef):
"""Add the object reference to the collection."""
self.append(objRef)
-
+
def remove(self, objRef):
"""Delete the object reference from the collection."""
try:
@@ -41,7 +41,7 @@
class TempFileHolder(object):
- """Utility class to get temporary file names and to make sure they are
+ """Utility class to get temporary file names and to make sure they are
deleted when the Python session ends.
"""
def __init__(self):
@@ -50,8 +50,8 @@
def __del__(self):
self._eraseTempFiles()
-
-
+
+
def _eraseTempFiles(self):
# Try to erase all temp files created during life.
# Need to re-import the os module here for some reason.
@@ -69,10 +69,10 @@
except:
# In these rare cases, Python has already 'gone away',
so just bail
pass
-
-
+
+
def release(self):
- self._eraseTempFiles()
+ self._eraseTempFiles()
def append(self, f):
@@ -116,13 +116,13 @@
Normally, dApp gets instantiated from the client app's main Python
script,
and lives through the life of the application.
- -- set up an empty data connections object which holds
- -- connectInfo objects connected to pretty names. If there
+ -- set up an empty data connections object which holds
+ -- connectInfo objects connected to pretty names. If there
-- is a file named 'default.cnxml' present, it will import the
-- connection definitions contained in that. If no file of that
-- name exists, it will import any .cnxml file it finds. If
there
-- are no such files, it will then revert to the old behavior
- -- of importing a file in the current directory called
+ -- of importing a file in the current directory called
-- 'dbConnectionDefs.py', which contains connection
-- definitions in python code format instead of XML.
@@ -132,8 +132,8 @@
-- decide which ui to use (wx) and gets that ball rolling
- -- look for a MainForm in an expected place, otherwise use
default dabo
- -- dMainForm, and instantiate that.
+ -- look for a MainForm in an expected place, otherwise use
default dabo
+ -- dMainForm, and instantiate that.
-- maintain a forms collection and provide interfaces for
-- opening dForms, closing them, and iterating through them.
@@ -145,11 +145,11 @@
"""
_call_beforeInit, _call_afterInit, _call_initProperties = False, False,
True
# Behaviors which are normal in the framework may need to
- # be modified when run as the Designer. This flag will
+ # be modified when run as the Designer. This flag will
# distinguish between the two states.
isDesigner = False
-
+
def __init__(self, selfStart=False, properties=None, *args, **kwargs):
self._uiAlreadySet = False
dabo.dAppRef = self
@@ -162,7 +162,7 @@
self.splashImage = self._extractKey(kwargs, "splashImage", img)
self.splashMaskColor = self._extractKey(kwargs,
"splashMaskColor", None)
self.splashTimeout = self._extractKey(kwargs, "splashTimeout",
5000)
-
+
super(dApp, self).__init__(properties, *args, **kwargs)
# egl: added the option of keeping the main form hidden
# initially. The default behavior is for it to be shown, as
usual.
@@ -178,7 +178,7 @@
self.getTempFile = self._tempFileHolder.getTempFile
# List of form classes to open on App Startup
- self.formsToOpen = []
+ self.formsToOpen = []
# Form to open if no forms were passed as a parameter
self.default_form = None
@@ -191,19 +191,19 @@
self._afterInit()
self.autoBindEvents()
-
+
def __del__(self):
"""Make sure that temp files are removed"""
self._tempFileHolder.release()
-
+
def setup(self, initUI=True):
"""Set up the application object."""
# dabo is going to want to import various things from the Home
Directory
if self.HomeDirectory not in sys.path:
sys.path.append(self.HomeDirectory)
-
+
def initAppInfo(item, default):
if not self.getAppInfo(item):
self.setAppInfo(item, default)
@@ -214,7 +214,7 @@
initAppInfo("vendorName", "")
self._initDB()
-
+
if initUI:
self._initUI()
if self.UI is not None:
@@ -232,8 +232,8 @@
def startupForms(self):
- """Open one or more of the defined forms. The default one is
specified
- in .default_form. If form names were passed on the command
line,
+ """Open one or more of the defined forms. The default one is
specified
+ in .default_form. If form names were passed on the command line,
they will be opened instead of the default one as long as they
exist.
"""
form_names = [class_name[3:] for class_name in dir(self.ui) if
class_name[:3] == "Frm"]
@@ -248,46 +248,46 @@
frm(self.MainForm).show()
def initUIApp(self):
- """Callback from the initial app setup. Used to allow the
+ """Callback from the initial app setup. Used to allow the
splash screen, if any, to be shown quickly.
"""
self.uiApp.setup()
-
-
+
+
def start(self):
"""Start the application event loop."""
if not self._wasSetup:
# Convenience; if you don't need to customize setup(),
just
# call start()
self.setup()
-
+
if (not self.SecurityManager or not
self.SecurityManager.RequireAppLogin
or self.SecurityManager.login()):
-
+
userName = self.getUserCaption()
if userName:
userName = " (%s)" % userName
else:
userName = ""
-
+
self._retrieveMRUs()
self.uiApp.start(self)
self.finish()
-
-
+
+
def finish(self):
"""Called when the application event loop has ended."""
self._persistMRU()
self.uiApp.finish()
self.closeConnections()
self._tempFileHolder.release()
- dabo.infoLog.write(_("Application finished."))
+ dabo.logInfo(_("Application finished."))
def getLoginInfo(self, message=None):
"""Return the user/password to dSecurityManager.login().
- The default is to display the standard login dialog, and return
the
+ The default is to display the standard login dialog, and return
the
user/password as entered by the user, but subclasses can
override to get
the information from whereever is appropriate.
@@ -299,18 +299,18 @@
ld.show()
user, password = ld.user, ld.password
return user, password
-
-
+
+
def _persistMRU(self):
"""Persist any MRU lists to disk."""
base = "MRU.%s" % self.getAppInfo("appName")
- self.deleteAllUserSettings(base)
+ self.deleteAllUserSettings(base)
for cap in self._persistentMRUs.keys():
mruList = self.uiApp.getMRUListForMenu(cap)
setName = ".".join((base, cap))
self.setUserSetting(setName, mruList)
-
-
+
+
def _retrieveMRUs(self):
"""Retrieve any saved MRU lists."""
base = "MRU.%s" % self.getAppInfo("appName")
@@ -320,8 +320,8 @@
# Should be a list of items. Add 'em in reverse
order
for itm in itms:
self.uiApp.addToMRU(cap, itm, fcn)
-
+
def getAppInfo(self, item):
"""Look up the item, and return the value."""
try:
@@ -338,13 +338,13 @@
def getUserSettingKeys(self, spec):
"""Return a list of all keys underneath <spec> in the user
settings table.
-
+
For example, if spec is "appWizard.dbDefaults", and there are
userSettings entries for:
appWizard.dbDefaults.pkm.Host
appWizard.dbDefaults.pkm.User
appWizard.dbDefaults.egl.Host
-
+
The return value would be ["pkm", "egl"]
"""
usp = self.UserSettingProvider
@@ -366,8 +366,8 @@
usp = self.UserSettingProvider
if usp:
usp.setUserSetting(item, value)
-
-
+
+
def setUserSettings(self, setDict):
"""Convenience method for setting several settings with one
call. Pass a dict containing {settingName: settingValue} pairs.
@@ -375,22 +375,22 @@
usp = self.UserSettingProvider
if usp:
usp.setUserSettings(setDict)
-
-
+
+
def deleteUserSetting(self, item):
"""Removes the given item from the user settings file."""
usp = self.UserSettingProvider
if usp:
usp.deleteUserSetting(item)
-
-
+
+
def deleteAllUserSettings(self, spec):
"""Deletes all settings that begin with the supplied spec."""
usp = self.UserSettingProvider
if usp:
usp.deleteAllUserSettings(spec)
-
-
+
+
def getUserCaption(self):
""" Return the full name of the currently logged-on user."""
if self.SecurityManager:
@@ -429,24 +429,24 @@
# These two methods pass encryption/decryption requests
# to the Crypto object
def encrypt(self, val):
- """Return the encrypted string value. The request is passed
+ """Return the encrypted string value. The request is passed
to the Crypto object for processing.
"""
return self.Crypto.encrypt(val)
-
+
def decrypt(self, val):
- """Return decrypted string value. The request is passed to
+ """Return decrypted string value. The request is passed to
the Crypto object for processing.
"""
return self.Crypto.decrypt(val)
-
+
def getCharset(self):
"""Returns one of 'unicode' or 'ascii'."""
return self.uiApp.charset
-
-
+
+
def _initProperties(self):
""" Initialize the public properties of the app object."""
self.uiType = None # ("wx", "qt", "curses", "http", etc.)
@@ -466,9 +466,9 @@
self._appInfo = {}
super(dApp, self)._initProperties()
-
+
def _initDB(self):
- """Set the available connection definitions for use by the app.
+ """Set the available connection definitions for use by the app.
First read in all .cnxml files. If no such XML definition files
exist,
check for a python code definition file named
'dbConnectionDefs.py'.
@@ -484,7 +484,7 @@
connDefs.update(cn)
for kk in cn.keys():
self.dbConnectionNameToFiles[kk] = f
-
+
# Import any python code connection definitions (the "old" way).
try:
import dbConnectionDefs
@@ -494,21 +494,21 @@
self.dbConnectionNameToFiles[kk] =
os.abspath("dbConnectionDefs.py")
except:
pass
-
- # For each connection definition, add an entry to
- # self.dbConnectionDefs that contains a key on the
+
+ # For each connection definition, add an entry to
+ # self.dbConnectionDefs that contains a key on the
# name, and a value of a dConnectInfo object.
for k,v in connDefs.items():
ci = dabo.db.dConnectInfo()
ci.setConnInfo(v)
self.dbConnectionDefs[k] = ci
- dabo.infoLog.write(_("%s database connection definition(s)
loaded.")
+ dabo.logInfo(_("%s database connection definition(s) loaded.")
% (len(self.dbConnectionDefs)))
def _initUI(self):
- """ Set the user-interface library for the application. Ignored
+ """ Set the user-interface library for the application. Ignored
if the UI was already explicitly set by user code.
"""
if self.UI is None and not self._uiAlreadySet:
@@ -518,7 +518,7 @@
self.UI = "wx"
else:
# Custom app code or the dabo.ui module already set
this: don't touch
- dabo.infoLog.write(_("User interface already set to
'%s', so dApp didn't touch it.")
+ dabo.logInfo(_("User interface already set to '%s', so
dApp didn't touch it.")
% self.UI)
@@ -538,13 +538,13 @@
except KeyError:
ret = None
return ret
-
-
+
+
def getConnectionNames(self):
"""Returns a list of all defined connection names"""
return self.dbConnectionDefs.keys()
-
-
+
+
def closeConnections(self):
"""Cleanup as the app is exiting."""
for conn in self.dbConnections:
@@ -552,8 +552,8 @@
conn.close()
except:
pass
-
-
+
+
def addConnectInfo(self, ci, name=None):
if name is None:
try:
@@ -563,8 +563,8 @@
name = "[EMAIL PROTECTED]" % (ci.User, ci.Host)
self.dbConnectionDefs[name] = ci
self.dbConnectionNameToFiles[name] = None
-
+
def addConnectFile(self, connFile):
"""Accepts a cnxml file path, and reads in the connections
defined in it, adding them to self.dbConnectionDefs.
@@ -582,20 +582,20 @@
break
if os.path.exists(connFile):
connDefs = importConnections(connFile)
- # For each connection definition, add an entry to
- # self.dbConnectionDefs that contains a key on the
+ # For each connection definition, add an entry to
+ # self.dbConnectionDefs that contains a key on the
# name, and a value of a dConnectInfo object.
for k,v in connDefs.items():
ci = dabo.db.dConnectInfo()
ci.setConnInfo(v)
self.dbConnectionDefs[k] = ci
self.dbConnectionNameToFiles[k] = connFile
-
+
def showCommandWindow(self, context=None):
"""Shows a command window with a full Python interpreter.
This is great for debugging during development, but you should
turn off
- app.ShowCommandWindowMenu in production, perhaps leaving
backdoor
+ app.ShowCommandWindowMenu in production, perhaps leaving
backdoor
access to this function.
The context argument tells dShell what object becomes 'self'.
If not
@@ -656,14 +656,14 @@
self.uiApp.addToMRU(menu, prmpt, bindfunc, *args, **kwargs)
def onMenuOpenMRU(self, menu):
self.uiApp.onMenuOpenMRU(menu)
- ############################
-
-
+ ############################
+
+
def copyToClipboard(self, txt):
"""Place the passed text onto the clipboard."""
self.uiApp.copyToClipboard(txt)
-
+
def onHelpAbout(self, evt):
about = self.AboutFormClass
if about is None:
@@ -677,20 +677,20 @@
frm = None
dlg = about(frm)
dlg.show()
-
-
+
+
def addToAbout(self):
"""Adds additional app-specific information to the About form.
This is just a stub method; override in subclasses if needed."""
pass
-
-
+
+
def clearActiveForm(self, frm):
"""Called by the form when it is deactivated."""
if frm is self.ActiveForm:
self.uiApp.ActiveForm = None
-
+
def _getAboutFormClass(self):
return getattr(self, "_aboutFormClass", None)
@@ -703,14 +703,14 @@
return self.uiApp.ActiveForm
else:
return None
-
+
def _setActiveForm(self, frm):
if hasattr(self, "uiApp") and self.uiApp is not None:
self.uiApp._setActiveForm(frm)
else:
- dabo.errorLog.write(_("Can't set ActiveForm: no
uiApp."))
-
+ dabo.logError(_("Can't set ActiveForm: no uiApp."))
+
def _getBasePrefKey(self):
try:
ret = self._basePrefKey
@@ -725,7 +725,7 @@
ret = self.MainForm.BasePrefKey
except: pass
if not ret:
- dabo.infoLog.write(_("WARNING: No BasePrefKey has been
set for this application."))
+ dabo.logInfo(_("WARNING: No BasePrefKey has been set
for this application."))
try:
f = inspect.stack()[-1][1]
pth = os.path.abspath(f)
@@ -760,7 +760,7 @@
try:
f = open(val, "a")
except:
- dabo.errorLog.write(_("Could not open file:
'%s'") % val)
+ dabo.logError(_("Could not open file: '%s'") %
val)
return
else:
f = val
@@ -769,18 +769,18 @@
def _getDrawSizerOutlines(self):
return self.uiApp.DrawSizerOutlines
-
+
def _setDrawSizerOutlines(self, val):
self.uiApp.DrawSizerOutlines = val
-
+
def _getEncoding(self):
ret = locale.getlocale()[1]
if ret is None:
ret = dabo.defaultEncoding
return ret
-
+
def _getHomeDirectory(self):
try:
hd = self._homeDirectory
@@ -801,9 +801,9 @@
# mangle HomeDirectory to not be the py2exe
library.zip file,
# but the containing directory (the directory
where the exe lives)
hd = os.path.split(hd)[0]
- self._homeDirectory = hd
+ self._homeDirectory = hd
return hd
-
+
def _setHomeDirectory(self, val):
if os.path.exists(val):
self._homeDirectory = os.path.abspath(val)
@@ -817,7 +817,7 @@
def _setIcon(self, val):
self._icon = val
-
+
def _getMainForm(self):
try:
frm = self._mainForm
@@ -825,12 +825,12 @@
frm = None
self._mainForm = None
return frm
-
+
def _setMainForm(self, val):
self.uiApp.setMainForm(val)
self._mainForm = val
-
+
def _getMainFormClass(self):
try:
cls = self._mainFormClass
@@ -838,11 +838,11 @@
cls = dabo.ui.dFormMain
self._mainFormClass = cls
return cls
-
+
def _setMainFormClass(self, val):
self._mainFormClass = val
-
-
+
+
def _getNoneDisp(self):
v = self._noneDisplay = getattr(self, "_noneDisplay", _("< None
>"))
return v
@@ -850,8 +850,8 @@
def _setNoneDisp(self, val):
assert isinstance(val, basestring)
self._noneDisplay = val
-
+
def _getPlatform(self):
try:
uiApp = self.uiApp
@@ -868,20 +868,20 @@
return self._searchDelay
except AttributeError:
## I've found that a value of 300 isn't too fast nor
too slow:
- # egl: 2006-11-16 - based on feedback from others, I'm
+ # egl: 2006-11-16 - based on feedback from others, I'm
# lengthening this to 500 ms.
return 500
-
+
def _setSearchDelay(self, value):
- self._searchDelay = int(value)
+ self._searchDelay = int(value)
-
+
def _getSecurityManager(self):
try:
return self._securityManager
except AttributeError:
return None
-
+
def _setSecurityManager(self, value):
if isinstance(value, dSecurityManager.dSecurityManager):
if self.SecurityManager:
@@ -889,52 +889,52 @@
self._securityManager = value
else:
raise TypeError, _("SecurityManager must descend from
dSecurityManager.")
-
-
+
+
def _getShowCommandWindowMenu(self):
try:
v = self._showCommandWindowMenu
except AttributeError:
v = self._showCommandWindowMenu = True
return v
-
+
def _setShowCommandWindowMenu(self, val):
self._showCommandWindowMenu = bool(val)
-
+
def _getShowSizerLinesMenu(self):
try:
v = self._showSizerLinesMenu
except AttributeError:
v = self._showSizerLinesMenu = True
return v
-
+
def _setShowSizerLinesMenu(self, val):
self._showSizerLinesMenu = bool(val)
-
+
def _getUI(self):
try:
return dabo.ui.getUIType()
except AttributeError:
return None
-
+
def _setUI(self, uiType):
# Load the appropriate ui module. dabo.ui will now contain
# the classes of that library, wx for instance.
if self.UI is None:
if uiType is None:
self._uiAlreadySet = True
- dabo.infoLog.write(_("User interface set set to
None."))
+ dabo.logInfo(_("User interface set set to
None."))
elif dabo.ui.loadUI(uiType):
self._uiAlreadySet = True
- dabo.infoLog.write(_("User interface set to
'%s' by dApp.") % uiType)
+ dabo.logInfo(_("User interface set to '%s' by
dApp.") % uiType)
else:
- dabo.infoLog.write(_("Tried to set UI to '%s',
but it failed.") % uiType)
+ dabo.logInfo(_("Tried to set UI to '%s', but it
failed.") % uiType)
else:
raise RuntimeError, _("The UI cannot be reset once
assigned.")
-
+
def _getUserSettingProvider(self):
try:
ret = self._userSettingProvider
@@ -945,7 +945,7 @@
else:
ret = self._userSettingProvider = None
return ret
-
+
def _setUserSettingProvider(self, val):
self._userSettingProvider = val
@@ -965,36 +965,36 @@
AboutFormClass = property(_getAboutFormClass, _setAboutFormClass, None,
_("Specifies the form class to use for the
application's About screen."))
- ActiveForm = property(_getActiveForm, _setActiveForm, None,
+ ActiveForm = property(_getActiveForm, _setActiveForm, None,
_("Returns the form that currently has focus, or None.
(dForm)" ) )
-
+
BasePrefKey = property(_getBasePrefKey, _setBasePrefKey, None,
_("""Base key used when saving/restoring preferences.
This differs
- from the default definition of this property in that if
it is empty, it
+ from the default definition of this property in that if
it is empty, it
will return the ActiveForm's BasePrefKey or the
MainForm's BasePrefKey
in that order. (str)"""))
-
- Crypto = property(_getCrypto, _setCrypto, None,
+
+ Crypto = property(_getCrypto, _setCrypto, None,
_("Reference to the object that provides cryptographic
services. (varies)" ) )
-
+
DatabaseActivityLog = property(_getDatabaseActivityLog,
_setDatabaseActivityLog, None,
- _("""Path to the file (or file-like object) to be used
for logging all database
+ _("""Path to the file (or file-like object) to be used
for logging all database
activity. Default=None, which means no log is kept.
(file or str)"""))
-
+
DrawSizerOutlines = property(_getDrawSizerOutlines,
_setDrawSizerOutlines, None,
_("Determines if sizer outlines are drawn on the
ActiveForm. (bool)"))
-
+
Encoding = property(_getEncoding, None, None,
_("Name of encoding to use for unicode (str)") )
-
+
HomeDirectory = property(_getHomeDirectory, _setHomeDirectory, None,
_("""Specifies the application's home directory.
(string)
The HomeDirectory is the top-level directory for your
application files,
- the directory where your main script lives. You never
know what the
+ the directory where your main script lives. You never
know what the
current directory will be on a given system, but
HomeDirectory will always
get you to your files."""))
-
+
Icon = property(_getIcon, _setIcon, None,
_("""Specifies the icon to use on all forms and dialogs
by default.
@@ -1007,7 +1007,7 @@
MainForm = property(_getMainForm, _setMainForm, None,
_("""The object reference to the main form of the
application, or None.
- The MainForm gets instantiated automatically during
application setup,
+ The MainForm gets instantiated automatically during
application setup,
based on the value of MainFormClass. If you want to
swap in your own
MainForm instance, do it after setup() but before
start(), as in:
@@ -1016,12 +1016,12 @@
>>> app.setup()
>>> app.MainForm = myMainFormInstance
>>> app.start()"""))
-
+
MainFormClass = property(_getMainFormClass, _setMainFormClass, None,
_("""Specifies the class to instantiate for the main
form. Can be a
class reference, or the path to a .cdxml file.
- Defaults to the dFormMain base class. Set to None if
you don't want a
+ Defaults to the dFormMain base class. Set to None if
you don't want a
main form, or set to your own main form class. Do this
before calling
dApp.start(), as in:
@@ -1030,64 +1030,64 @@
>>> app.MainFormClass = MyMainFormClass
>>> app.start()
(dForm) """))
-
- NoneDisplay = property(_getNoneDisp, _setNoneDisp, None,
+
+ NoneDisplay = property(_getNoneDisp, _setNoneDisp, None,
_("Text to display for null (None) values. (str)") )
-
+
Platform = property(_getPlatform, None, None,
- _("""Returns the platform we are running on. This will
be
+ _("""Returns the platform we are running on. This will
be
one of 'Mac', 'Win' or 'GTK'. (str)""") )
SearchDelay = property(_getSearchDelay, _setSearchDelay, None,
_("""Specifies the delay before incrementeal searching
begins. (int)
As the user types, the search string is
modified. If the time between
- keystrokes exceeds SearchDelay (milliseconds),
the search will run and
+ keystrokes exceeds SearchDelay (milliseconds),
the search will run and
the search string will be cleared.
The value set here in the Application object
will become the default for
all objects that provide incremental searching
application-wide.""") )
-
- SecurityManager = property(_getSecurityManager, _setSecurityManager,
None,
- _("""Specifies the Security Manager, if any.
- You must subclass dSecurityManager, overriding the
appropriate hooks
- and properties, and then set dApp.SecurityManager to an
instance of your
- subclass. There is no security manager by default - you
explicitly set
+ SecurityManager = property(_getSecurityManager, _setSecurityManager,
None,
+ _("""Specifies the Security Manager, if any.
+
+ You must subclass dSecurityManager, overriding the
appropriate hooks
+ and properties, and then set dApp.SecurityManager to an
instance of your
+ subclass. There is no security manager by default - you
explicitly set
this to use Dabo security.""") )
ShowCommandWindowMenu = property(_getShowCommandWindowMenu,
- _setShowCommandWindowMenu, None,
+ _setShowCommandWindowMenu, None,
_("""Specifies whether the command window option is
shown in the menu.
If True (the default), there will be a File|Command
Window option
- available in the base menu. If False, your code can
still start the
+ available in the base menu. If False, your code can
still start the
command window by calling app.showCommandWindow()
directly.""") )
ShowSizerLinesMenu = property(_getShowSizerLinesMenu,
- _setShowSizerLinesMenu, None,
+ _setShowSizerLinesMenu, None,
_("""Specifies whether the "Show Sizer Lines" option is
shown in the menu.
If True (the default), there will be a View|Show Sizer
Lines option
available in the base menu.""") )
- UI = property(_getUI, _setUI, None,
+ UI = property(_getUI, _setUI, None,
_("""Specifies the user interface to load, or None.
(str)
This is the user interface library, such as 'wx' or
'tk'. Note that
'wx' is the only supported user interface library at
this point."""))
- UserSettingProvider = property(_getUserSettingProvider,
+ UserSettingProvider = property(_getUserSettingProvider,
_setUserSettingProvider, None,
_("""Specifies the reference to the object providing
user preference persistence.
-
+
The default UserSettingProvider will save user
preferences inside the .dabo
directory inside the user's home directory."""))
UserSettingProviderClass = property(_getUserSettingProviderClass,
_setUserSettingProviderClass, None,
_("""Specifies the class to use for user preference
persistence.
-
+
The default UserSettingProviderClass will save user
preferences inside the .dabo
directory inside the user's home directory, and will be
instantiated by Dabo
automatically."""))
Modified: trunk/dabo/dEvents.py
===================================================================
--- trunk/dabo/dEvents.py 2007-06-21 20:39:18 UTC (rev 3193)
+++ trunk/dabo/dEvents.py 2007-06-22 03:22:09 UTC (rev 3194)
@@ -8,56 +8,56 @@
class dEvent(dObject):
""" Base class for Dabo events.
-
- Event objects are instantiated in self.raiseEvent(), and passed to all
+
+ Event objects are instantiated in self.raiseEvent(), and passed to all
callbacks registered with self.bindEvent().
-
- User code can define custom events by simply subclassing Event and then
+
+ User code can define custom events by simply subclassing Event and then
using self.bindEvent() and self.raiseEvent() in your objects.
- """
+ """
def __init__(self, eventObject, uiEvent=None, eventData=None, *args,
**kwargs):
# Event objects get instantiated with every single event, so try
# to keep code to a minimum here.
#super(dEvent, self).__init__(*args, **kwargs)
-
+
self._eventObject = eventObject
self._uiEvent = uiEvent
self._args = args
self._kwargs = kwargs
self._continue = True
self._baseClass = dEvent
-
+
self._insertEventData()
if eventData:
self._eventData.update(eventData)
-
+
if dabo.eventLogging:
self._logEvent()
-
-
+
+
def appliesToClass(eventClass, objectClass):
""" Returns True if this event can be raised by the passed
class.
-
+
Stub: subclass events need to override with appropriate logic.
"""
return False
appliesToClass = classmethod(appliesToClass)
-
-
+
+
def stop(self):
"""Stop the event from being handled by other handlers.
-
+
This is an alternative to setting the Continue property to
False.
"""
self.Continue = False
-
-
+
+
def _insertEventData(self):
""" Place ui-specific stuff into the ui-agnostic EventData
dictionary."""
- eventData = {}
+ eventData = {}
nativeEvent = self._uiEvent
kwargs = self._kwargs
-
+
eventData["timestamp"] = time.localtime()
# Add any keyword args passed:
@@ -68,33 +68,33 @@
if nativeEvent is not None:
# Each UI lib should implement getEventData()
uiEventData = dabo.ui.getEventData(nativeEvent)
-
+
for key in uiEventData.keys():
eventData[key] = uiEventData[key]
-
- self._eventData = eventData
-
-
+
+ self._eventData = eventData
+
+
def _logEvent(self):
""" Log the event if the event object's LogEvents property is
set."""
eventName = self.__class__.__name__
-
+
try:
logEvents = self._eventObject._getLogEvents()
except AttributeError:
logEvents = []
noLogEvents = []
-
+
if len(logEvents) > 0 and logEvents[0].lower() == "all":
# If there are any events listed explicitly, those must
not be
# logged.
noLogEvents = logEvents[1:]
- if eventName not in noLogEvents:
+ if eventName not in noLogEvents:
for logEventName in logEvents:
if logEventName.lower() == "all" or
logEventName == eventName:
- dabo.infoLog.write("dEvent Fired: %s
%s" %
-
(self._eventObject.getAbsoluteName(),
+ dabo.logInfo("dEvent Fired: %s %s" %
+
(self._eventObject.getAbsoluteName(),
self.__class__.__name__,))
break
@@ -104,84 +104,84 @@
return self._eventData[att]
raise AttributeError, "%s.%s object has no attribute %s." % (
self.__class__.__module__, self.__class__.__name__, att)
-
-
+
+
def _getContinue(self):
return self._continue
-
+
def _setContinue(self, val):
self._continue = bool(val)
-
-
+
+
def _getEventObject(self):
return self._eventObject
-
+
def _setEventObject(self, obj):
self._eventObject = obj
-
-
+
+
def _getEventData(self):
return self._eventData
-
+
def _setEventData(self, dict):
self._eventData = dict
-
-
+
+
Continue = property(_getContinue, _setContinue, None,
- _("""Specifies whether the event is allowed to continue
+ _("""Specifies whether the event is allowed to continue
on to the next handler. (bool)"""))
-
- EventObject = property(_getEventObject, _setEventObject, None,
+
+ EventObject = property(_getEventObject, _setEventObject, None,
_("References the object that emitted the event.
(obj)"""))
-
+
EventData = property(_getEventData, _setEventData, None,
- _("""Dictionary of data name/value pairs associated
+ _("""Dictionary of data name/value pairs associated
with the event. (dict)"""))
-# Eventually deprecate Event
+# Eventually deprecate Event
Event=dEvent
class DataEvent(dEvent):
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, dabo.biz.dBizobj)
appliesToClass = classmethod(appliesToClass)
-
-
+
+
class EditorEvent(dEvent):
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, dabo.ui.dEditor)
appliesToClass = classmethod(appliesToClass)
-
+
class GridEvent(dEvent):
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, dabo.ui.dGrid)
appliesToClass = classmethod(appliesToClass)
-
+
class KeyEvent(dEvent):
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, (dabo.ui.dPemMixin, dabo.dApp))
appliesToClass = classmethod(appliesToClass)
-
-
+
+
class ListEvent(dEvent):
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, (dabo.ui.dListControl,
dabo.ui.dListBox))
appliesToClass = classmethod(appliesToClass)
-
+
class MenuEvent(dEvent):
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, (dabo.ui.dMenu,
dabo.ui.dMenuItem,
dabo.ui.dMenuBar))
appliesToClass = classmethod(appliesToClass)
-
+
class MouseEvent(dEvent):
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, dabo.ui.dPemMixin)
appliesToClass = classmethod(appliesToClass)
-
+
class SashEvent(dEvent):
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, dabo.ui.dSplitter)
@@ -206,23 +206,23 @@
return issubclass(objectClass, (dabo.dApp, dabo.ui.dForm,
dabo.ui.dFormMain, dabo.ui.dDialog))
appliesToClass = classmethod(appliesToClass)
-
+
class Close(dEvent):
"""Occurs when the user closes the form."""
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, (dabo.ui.dForm,
dabo.ui.dFormMain,
dabo.ui.dDialog))
appliesToClass = classmethod(appliesToClass)
-
-
(545793 bytes were truncated as it was too long for the email (max 40000
bytes.)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]