dabo Commit
Revision 6451
Date: 2011-02-19 11:36:07 -0800 (Sat, 19 Feb 2011)
Author: Werner
Trac: http://trac.dabodev.com/changeset/6451
Changed:
U trunk/dabo/__init__.py
U trunk/dabo/dApp.py
U trunk/dabo/dConstants.py
U trunk/dabo/dUserSettingProvider.py
U trunk/dabo/db/__init__.py
U trunk/dabo/db/dBackend.py
U trunk/dabo/db/dConnectInfo.py
U trunk/dabo/db/dConnection.py
U trunk/dabo/db/dCursorMixin.py
U trunk/dabo/db/dTable.py
U trunk/dabo/db/dbFirebird.py
U trunk/dabo/db/dbMsSQL.py
U trunk/dabo/db/dbPostgreSQL.py
U trunk/dabo/db/dbSQLite.py
U trunk/dabo/db/dbTemplate.py
U trunk/dabo/lib/EasyDialogBuilder.py
U trunk/dabo/lib/__init__.py
U trunk/dabo/lib/datanav/Bizobj.py
U trunk/dabo/lib/datanav/Form.py
U trunk/dabo/lib/datanav/Grid.py
U trunk/dabo/lib/datanav/Page.py
U trunk/dabo/lib/profilehooks.py
U trunk/dabo/lib/utils.py
U trunk/dabo/lib/uuid.py
U trunk/dabo/lib/xmltodict.py
Log:
- another batch of documentation string changes for Sphinx doc
Diff:
Modified: trunk/dabo/__init__.py
===================================================================
--- trunk/dabo/__init__.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/__init__.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
-"""Dabo: A Framework for developing data-driven business applications
+"""
+Dabo: A Framework for developing data-driven business applications
Dabo is for developing multi-platform database business applications -
you know, applications that need to connect to a database server (MySQL,
@@ -43,54 +44,50 @@
To run Dabo, and apps based on Dabo, you need:
+ Python 2.4 or higher (2.5 or higher recommended)
-
+ wxPython 2.8 or higher (2.8.8 or higher highly recommended)
- (only necessary for apps with a ui: because of the modular
- 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.)
-
- + pysqlite2: The Python dbapi module for SQLite. (Not needed in
- Python 2.5 and higher)
-
+ (only necessary for apps with a ui: because of the modular
+ 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.)
+ + 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
- 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
- performing, than ODBC is.) (we recommend starting with MySQL
- installed, because all of the demo code has the best support
- for MySQL).
+ 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
+ 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. Run DaboDemo.py which
is in demo/DaboDemo. Run AppWizard.py which is in ide/wizards.
Run ClassDesigner.py or ReportDesigner.py in the ide directory.
For some quick eye-candy, once you've installed Dabo using the standard
-'python setup.py install' method, do this from your Python interpreter:
+'python setup.py install' method, do this from your Python interpreter::
import dabo
dabo.dApp().start()
-press Ctrl+D and type the following into the command window that appears:
+press Ctrl+D and type the following into the command window that appears::
tb = dabo.ui.dTextBox(self)
-Notice the textbox in the upper left hand corner?
+Notice the textbox in the upper left hand corner? ::
tb.Value = "yippee!"
tb.FontBold = True
print tb.Value
Now, use the ui to change the value in the textbox, and switch back to
-the command window.
+the command window. ::
print tb.Value
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/dApp.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -126,10 +126,11 @@
class dApp(dObject):
- """The containing object for the entire application.
+ """
+ The containing object for the entire application.
All Dabo objects have an Application property which refers to the dApp
- instance. Instantiate your dApp object from your main script, like so:
+ instance. Instantiate your dApp object from your main script, like so::
>>> import dabo
>>> app = dabo.dApp
@@ -286,7 +287,8 @@
def resyncFiles(self):
- """ In the middle of an app's lifetime, files on the remote
server may
+ """
+ In the middle of an app's lifetime, files on the remote server
may
have been updated. This will ensure that the local copy is in
sync.
"""
rp = self._RemoteProxy
@@ -352,14 +354,16 @@
def afterSetup(self):
- """Hook method that is called after the app's setup code has
run, and the
+ """
+ Hook method that is called after the app's setup code has run,
and the
database, UI and module references have all been established.
"""
pass
def startupForms(self):
- """Open one or more of the defined forms. The default one is
specified
+ """
+ Open one or more of the defined forms. The default one is
specified
in self.DefaultForm. If form names were passed on the command
line,
they will be opened instead of the default one as long as they
exist.
"""
@@ -376,7 +380,8 @@
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()
@@ -399,7 +404,8 @@
def finish(self):
- """Called when the application event loop has ended. You may
also
+ """
+ Called when the application event loop has ended. You may also
call this explicitly to exit the application event loop.
"""
self.uiApp.exit()
@@ -413,14 +419,16 @@
def afterFinish(self):
- """Stub method. When this is called, the app has already
terminated, and you have
+ """
+ Stub method. When this is called, the app has already
terminated, and you have
one last chance to execute code by overriding this method.
"""
pass
def _setProjInfo(self):
- """Create a 2-tuple containing the project location and project
name, if any.
+ """
+ Create a 2-tuple containing the project location and project
name, if any.
The location is always the directory containing the initial
startup program; the
name is either None (default), or, if this is a Web Update-able
app, the
descriptive name.
@@ -443,7 +451,13 @@
def getLoginInfo(self, message=None):
- """Return a tuple of (user, password) to
dSecurityManager.login(). 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. You can
customize the default dialog by adding your own code to the loginDialogHook()
method, which will receive a reference to the login dialog.
+ """
+ Return a tuple of (user, password) to dSecurityManager.login().
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
+ where ever is appropriate. You can customize the default dialog
by adding
+ your own code to the loginDialogHook() method, which will
receive a
+ reference to the login dialog.
Return a tuple of (user, pass).
"""
@@ -511,7 +525,8 @@
def _resetWebUpdateCheck(self):
- """Sets the time that Web Update was last checked to the passed
value. Used
+ """
+ Sets the time that Web Update was last checked to the passed
value. Used
in cases where errors prevent an update from succeeding.
"""
if self._lastCheckInfo is None:
@@ -521,14 +536,16 @@
def checkForUpdates(self, evt=None):
- """Public interface to the web updates mechanism. Returns a
boolean
+ """
+ Public interface to the web updates mechanism. Returns a boolean
indicating whether the update was successful.
"""
return self.uiApp.checkForUpdates(force=True)
def _checkForUpdates(self, force=False):
- """This is the actual code that checks if a) we are using Web
Update; b) if we are
+ """
+ This is the actual code that checks if a) we are using Web
Update; b) if we are
due for a check; and then c) returns the status of the
available updates, if any.
"""
if not force:
@@ -600,7 +617,8 @@
def _updateFramework(self):
- """Get any changed files from the dabodev.com server, and
replace
+ """
+ Get any changed files from the dabodev.com server, and replace
the local copies with them."""
currVers = self._currentUpdateVersion()
fileurl = "%s/files/%s" % (dabo.webupdate_urlbase, currVers)
@@ -670,7 +688,8 @@
def _setWebUpdate(self, auto, interval=None):
- """Sets the web update settings for the entire framework. If
set to True, the
+ """
+ Sets the web update settings for the entire framework. If set
to True, the
interval is expected to be in minutes between checks.
"""
prf = self._frameworkPrefs
@@ -683,7 +702,8 @@
def getWebUpdateInfo(self):
- """Returns a 2-tuple that reflects the current settings for web
updates.
+ """
+ Returns a 2-tuple that reflects the current settings for web
updates.
The first position is a boolean that reflects whether
auto-checking is turned
on; the second is the update frequency in minutes.
"""
@@ -691,7 +711,8 @@
def urlFetch(self, pth, errorOnNotFound=False):
- """Fetches the specified resource from the internet using the
SourceURL value
+ """
+ Fetches the specified resource from the internet using the
SourceURL value
as the base for the resource URL. If a newer version is found,
the local copy
is updated with the retrieved resource. If the resource isn't
found, nothing
happens by default. If you want the error to be raised, pass
True for the
@@ -736,7 +757,8 @@
def updateFromSource(self, fileOrFiles):
- """This method takes either a single file path or a list of
paths, and if there
+ """
+ This method takes either a single file path or a list of paths,
and if there
is a SourceURL set, checks the source to see if there are newer
versions available,
and if so, downloads them.
"""
@@ -768,10 +790,12 @@
def getUserSettingKeys(self, spec):
- """Return a list of all keys underneath <spec> in the user
settings table.
+ """
+ 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
@@ -800,7 +824,8 @@
def setUserSettings(self, setDict):
- """Convenience method for setting several settings with one
+ """
+ Convenience method for setting several settings with one
call. Pass a dict containing {settingName: settingValue} pairs.
"""
usp = self.UserSettingProvider
@@ -823,7 +848,7 @@
def getUserCaption(self):
- """ Return the full name of the currently logged-on user."""
+ """Return the full name of the currently logged-on user."""
if self.SecurityManager:
return self.SecurityManager.UserCaption
else:
@@ -831,7 +856,8 @@
def str2Unicode(self, strVal):
- """Given a string, this method will try to return a properly
decoded
+ """
+ Given a string, this method will try to return a properly
decoded
unicode value. It will first try the default Encoding, and then
try the
more common encoding types.
"""
@@ -841,14 +867,16 @@
# 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)
@@ -860,7 +888,7 @@
def _initProperties(self):
- """ Initialize the public properties of the app object."""
+ """Initialize the public properties of the app object."""
self.uiType = None # ("wx", "qt", "curses", "http", etc.)
#self.uiModule = None
@@ -880,7 +908,8 @@
def _initDB(self, pth=None):
- """Set the available connection definitions for use by the app.
First, read in
+ """
+ Set the available connection definitions for use by the app.
First, read in
all .cnxml files in the specified directory, or the current
directory if none is
specified. If no such XML definition files exist, check for a
python code
definition file named 'dbConnectionDefs.py'.
@@ -931,7 +960,8 @@
def _initModuleNames(self):
- """Import the common application-level module names into
attributes
+ """
+ Import the common application-level module names into attributes
of this application object, so that the app code can easily
reference them.
Example: f there is a 'biz' directory that can be imported,
other objects in
the system can reference bizobjs using the
'self.Application.biz' syntax
@@ -965,7 +995,8 @@
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:
@@ -995,7 +1026,8 @@
def getConnectionByName(self, connName):
- """Given the name of a connection, returns the actual
+ """
+ Given the name of a connection, returns the actual
connection. Stores the connection so that multiple requests
for the same named connection will not open multiple
connections. If the name doesn't exist in self.dbConnectionDefs,
@@ -1037,7 +1069,8 @@
def addConnectFile(self, connFile):
- """Accepts a cnxml file path, and reads in the connections
+ """
+ Accepts a cnxml file path, and reads in the connections
defined in it, adding them to self.dbConnectionDefs. If the
file cannot be found, an exception is raised.
"""
@@ -1066,7 +1099,8 @@
def getStandardAppDirectory(self, dirname, start=None):
- """Return the path to one of the standard Dabo application
directories.
+ """
+ Return the path to one of the standard Dabo application
directories.
If a starting file path is provided, use that first. If not,
use the
HomeDirectory as the starting point.
"""
@@ -1094,7 +1128,8 @@
def getTransactionToken(self, biz):
- """Only one bizobj at a time can begin and end transactions per
connection.
+ """
+ Only one bizobj at a time can begin and end transactions per
connection.
This allows the bizobj to query the app for the 'token', which
is simply an
acknowledgement that there is no other transaction pending for
that connection.
If the bizobj gets the token, further requests for the token
from bizobjs using the
@@ -1110,7 +1145,8 @@
def hasTransactionToken(self, biz):
- """Returns True/False, depending on whether the specified
+ """
+ Returns True/False, depending on whether the specified
bizobj currently "holds" the transaction token.
"""
cn = biz._connection
@@ -1118,7 +1154,8 @@
def releaseTransactionToken(self, biz):
- """When a process that would normally close a transaction
happens, the
+ """
+ When a process that would normally close a transaction happens,
the
bizobj that is holding the transaction token for its connection
calls this
method to return the token. A check is run to ensure that the
releasing bizobj
is the one currently holding the token for its connection; if
it is, the item is
@@ -1130,7 +1167,8 @@
def setLanguage(self, lang, charset=None):
- """Allows you to change the language used for localization. If
the language
+ """
+ Allows you to change the language used for localization. If the
language
passed is not one for which there is a translation file, an
IOError exception
will be raised. You may optionally pass a character set to use.
"""
@@ -1139,7 +1177,8 @@
def showCommandWindow(self, context=None):
- """Shows a command window with a full Python interpreter.
+ """
+ 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
@@ -1152,7 +1191,8 @@
def toggleDebugWindow(self, context=None):
- """Shows/hodes a debug output window. It will
+ """
+ Shows/hodes a debug output window. It will
display the output of the debugging commands
from your program.
"""
@@ -1258,8 +1298,10 @@
def addToAbout(self):
- """Adds additional app-specific information to the About form.
- This is just a stub method; override in subclasses if needed."""
+ """
+ Adds additional app-specific information to the About form.
+ This is just a stub method; override in subclasses if needed.
+ """
pass
@@ -1737,13 +1779,15 @@
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:
+ MainForm instance, do it after setup() but before
start(), as in::
>>> import dabo
>>> app = dabo.dApp()
>>> app.setup()
>>> app.MainForm = myMainFormInstance
- >>> app.start()"""))
+ >>> app.start()
+
+ """))
MainFormClass = property(_getMainFormClass, _setMainFormClass, None,
_("""Specifies the class to instantiate for the main
form. Can be a
@@ -1751,13 +1795,14 @@
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:
+ dApp.start(), as in::
>>> import dabo
>>> app = dabo.dApp()
>>> app.MainFormClass = MyMainFormClass
>>> app.start()
- (dForm) """))
+
+ """))
NoneDisplay = property(_getNoneDisp, _setNoneDisp, None,
_("Text to display for null (None) values. (str)") )
@@ -1780,12 +1825,12 @@
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
- the search string will be cleared.
+ As the user types, the search string is modified. If
the time between
+ 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.""") )
+ 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.
Modified: trunk/dabo/dConstants.py
===================================================================
--- trunk/dabo/dConstants.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/dConstants.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-""" dConstants.py """
+"""dConstants.py"""
# Return values for most operations
# FILE_OK = 0
Modified: trunk/dabo/dUserSettingProvider.py
===================================================================
--- trunk/dabo/dUserSettingProvider.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/dUserSettingProvider.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -5,14 +5,17 @@
class dUserSettingProvider(dObject):
- """Class that manages saving and restoring user settings, such as form
+ """
+ Class that manages saving and restoring user settings, such as form
size and position.
"""
def getUserSettingKeys(self, spec):
- """Return a list of all keys underneath <spec>.
+ """
+ Return a list of all keys underneath <spec>.
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
@@ -23,7 +26,8 @@
def getUserSetting(self, item, default=None):
- """ Return the value of the user settings table that
+ """
+ Return the value of the user settings table that
corresponds to the preference key passed.
"""
prf = self.PreferenceManager
@@ -60,7 +64,8 @@
def deleteAllUserSettings(self, spec):
- """Given a spec, deletes all keys that match that spec.
+ """
+ Given a spec, deletes all keys that match that spec.
See the docs for getUserSettingKeys() for an explanation
on key matching.
"""
Modified: trunk/dabo/db/__init__.py
===================================================================
--- trunk/dabo/db/__init__.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/db/__init__.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
-""" dabo.db is the lowest tier, db access.
+"""
+dabo.db is the lowest tier, db access.
This is where the communication to and from the backend database happens, and
cursors get generated to be manipulated by the bizobj's in dabo.biz.
dabo.biz.dBiz is the entity that will interact with this dabo.db stuff, but you
can also work with dabo.db directly if you want. Perhaps you just want to read
-some rows from a backend database in a script. Here's an example of that:
+some rows from a backend database in a script. Here's an example of that::
from connectInfo import ConnectInfo
from dConnection import dConnection
@@ -62,7 +63,8 @@
return pythonTypes.get(pythonType, "?")
def getDataType(pythonType):
- """Given a python data type, returns the appropriate type for database
values.
+ """
+ Given a python data type, returns the appropriate type for database
values.
This is generally the same as the original, except when the value is
float and
the Decimal type is available.
"""
@@ -72,7 +74,8 @@
return ret
def connect(*args, **kwargs):
- """Convenience method: given connection info, return a dConnection
instance.
+ """
+ Convenience method: given connection info, return a dConnection
instance.
Passed connection info can either be in the form of a dConnectInfo
object,
or individual arguments to pass to dConnection's constructor.
Modified: trunk/dabo/db/dBackend.py
===================================================================
--- trunk/dabo/db/dBackend.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/db/dBackend.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -41,7 +41,7 @@
def isValidModule(self):
- """ Test the dbapi to see if it is supported on this
computer."""
+ """Test the dbapi to see if it is supported on this computer."""
try:
dbapi = __import__(self.dbModuleName)
return True
@@ -50,17 +50,17 @@
def getConnection(self, connectInfo, **kwargs):
- """ override in subclasses """
+ """override in subclasses"""
return None
def getDictCursorClass(self):
- """ override in subclasses """
+ """override in subclasses"""
return None
def getCursor(self, cursorClass):
- """ override in subclasses if necessary """
+ """override in subclasses if necessary"""
return cursorClass(self._connection)
@@ -83,7 +83,8 @@
def formatDateTime(self, val):
- """ Properly format a datetime value to be included in an Update
+ """
+ Properly format a datetime value to be included in an Update
or Insert statement. Each backend can have different
requirements
for formatting dates, so this is where you encapsulate these
rules
in backend-specific subclasses. If nothing special needs to be
done,
@@ -93,7 +94,8 @@
def formatNone(self):
- """ Properly format a None value to be included in an update
statement.
+ """
+ Properly format a None value to be included in an update
statement.
Each backend should override as needed. The default is to
return "NULL".
"""
@@ -101,33 +103,37 @@
def noResultsOnSave(self):
- """ Most backends will return a non-zero number if there are
updates.
+ """
+ Most backends will return a non-zero number if there are
updates.
Some do not, so this will have to be customized in those cases.
"""
raise dException.dException(_("No records updated"))
def noResultsOnDelete(self):
- """ Most backends will return a non-zero number if there are
deletions.
+ """
+ Most backends will return a non-zero number if there are
deletions.
Some do not, so this will have to be customized in those cases.
"""
raise dException.dException(_("No records deleted"))
def flush(self, cursor):
- """ Only used in some backends """
+ """Only used in some backends"""
return
def processFields(self, txt):
- """ Default is to return the string unchanged. Override
+ """
+ Default is to return the string unchanged. Override
in cases where the str needs processing.
"""
return txt
def escQuote(self, val):
- """ Escape special characters in SQL strings.
+ """
+ Escape special characters in SQL strings.
Escapes any single quotes that could cause SQL syntax errors,
as well
as any other characters which have special meanings with the
backend
@@ -138,7 +144,8 @@
def getLastInsertID(self, cursor):
- """ Return the ID of the last inserted row, or None.
+ """
+ Return the ID of the last inserted row, or None.
When inserting a new record in a table that auto-generates a PK
value, different databases have their own way of retrieving
that value.
@@ -158,7 +165,8 @@
def getTables(self, cursor, includeSystemTables=False):
- """ Return a tuple of the tables in the current database.
+ """
+ Return a tuple of the tables in the current database.
Different backends will do this differently, so override in
subclasses.
"""
@@ -166,12 +174,13 @@
def getTableRecordCount(self, tableName, cursor):
- """ Return the number of records in the backend table."""
+ """Return the number of records in the backend table."""
return -1
def getFields(self, tableName, cursor):
- """ Return field information from the backend table.
+ """
+ Return field information from the backend table.
See dCursorMixin.getFields() for a description of the return
value.
"""
@@ -182,7 +191,8 @@
def getDaboFieldType(self, backendFieldType):
- """ Return the Dabo code (I, T, D, ...) for the passed backend
Field Type.
+ """
+ Return the Dabo code (I, T, D, ...) for the passed backend
Field Type.
If it can't be determined, the field type will be '?'.
"""
@@ -190,34 +200,35 @@
def getFieldInfoFromDescription(self, cursorDescription):
- """ Return field information from the cursor description."""
+ """Return field information from the cursor description."""
# Default: return all the field names and "?", None for type
and pkid.
return tuple([(d[0], self.getDaboFieldType(d[1]), None) for d
in cursorDescription])
def beginTransaction(self, cursor):
- """ Begin a SQL transaction. Override in subclasses if
needed."""
+ """Begin a SQL transaction. Override in subclasses if needed."""
self._connection.begin()
dabo.dbActivityLog.info("SQL: begin")
return True
def commitTransaction(self, cursor):
- """ Commit a SQL transaction."""
+ """Commit a SQL transaction."""
self._connection.commit()
dabo.dbActivityLog.info("SQL: commit")
return True
def rollbackTransaction(self, cursor):
- """ Roll back (revert) a SQL transaction."""
+ """Roll back (revert) a SQL transaction."""
self._connection.rollback()
dabo.dbActivityLog.info("SQL: rollback")
return True
def addWithSep(self, base, new, sep=",\n\t"):
- """ Convenient method of adding to an expression that
+ """
+ Convenient method of adding to an expression that
may or may not have an existing value. If there is a value,
the separator is inserted between the two.
"""
@@ -229,7 +240,8 @@
def encloseNames(self, exp, autoQuote=True, keywords=None):
- """When table/field names contain spaces, this will safely
enclose them
+ """
+ When table/field names contain spaces, this will safely enclose
them
in quotes or whatever delimiter is appropriate for the backend,
unless
autoQuote is False, in which case it leaves things untouched.
If there are
keywords that are part of the expression that should not be
enclosed
@@ -256,7 +268,7 @@
def addField(self, clause, exp, alias=None, autoQuote=True):
- """ Add a field to the field clause."""
+ """Add a field to the field clause."""
indent = len("select ") * " "
# If exp is a function, don't do anything special about spaces.
if not self.functionPat.match(exp):
@@ -270,7 +282,7 @@
def addFrom(self, clause, exp, alias=None, autoQuote=True):
- """ Add a table to the sql statement."""
+ """Add a table to the sql statement."""
exp = self.encloseNames(exp, autoQuote=autoQuote,
keywords=("as",))
if alias:
exp = "%(exp)s as %(alias)s" % locals()
@@ -279,7 +291,7 @@
def addJoin(self, tbl, joinCondition, exp, joinType=None,
autoQuote=True):
- """ Add a joined table to the sql statement."""
+ """Add a joined table to the sql statement."""
tbl = self.encloseNames(tbl, autoQuote=autoQuote,
keywords=("as",))
joinType = self.formatJoinType(joinType)
indent = len("select ") * " "
@@ -288,28 +300,29 @@
def addWhere(self, clause, exp, comp="and", autoQuote=True):
- """ Add an expression to the where clause."""
+ """Add an expression to the where clause."""
indent = (len("select ") - len(comp)) * " "
exp = self.processFields(exp)
return self.addWithSep(clause, exp, sep="\n%s%s " % (indent,
comp))
def addGroupBy(self, clause, exp, autoQuote=True):
- """ Add an expression to the group-by clause."""
+ """Add an expression to the group-by clause."""
exp = self.encloseNames(exp, autoQuote=autoQuote)
indent = len("select ") * " "
return self.addWithSep(clause, exp, sep=",\n%s" % indent)
def addOrderBy(self, clause, exp, autoQuote=True):
- """ Add an expression to the order-by clause."""
+ """Add an expression to the order-by clause."""
exp = self.encloseNames(exp, autoQuote=autoQuote,
keywords=("asc", "desc"))
indent = len("select ") * " "
return self.addWithSep(clause, exp, sep=",\n%s" % indent)
def getLimitWord(self):
- """ Return the word to use in the db-specific limit clause.
+ """
+ Return the word to use in the db-specific limit clause.
Override for backends that don't use the word 'limit'
"""
return "limit"
@@ -317,7 +330,8 @@
def formSQL(self, fieldClause, fromClause, joinClause,
whereClause, groupByClause, orderByClause,
limitClause):
- """ Creates the appropriate SQL for the backend, given all
+ """
+ Creates the appropriate SQL for the backend, given all
the required clauses. Some backends order these differently, so
they should override this method with their own ordering.
"""
@@ -328,7 +342,8 @@
def prepareWhere(self, clause, autoQuote=True):
- """ Normally, just return the original. Can be overridden as
needed
+ """
+ Normally, just return the original. Can be overridden as needed
for specific backends.
"""
return clause
@@ -345,7 +360,8 @@
def getWordMatchFormat(self):
- """ By default, will return the standard format for an
+ """
+ By default, will return the standard format for an
equality test. If search by words is available, the format
must be implemented in each specific backend.
@@ -357,8 +373,11 @@
def getUpdateTablePrefix(self, tbl, autoQuote=True):
- """ By default, the update SQL statement will be in the form of
- tablename.fieldname
+ """
+ By default, the update SQL statement will be in the form of
+
+ tablename.fieldname
+
but some backends do no accept this syntax. If not, change
this method to return an empty string, or whatever should
preceed the field name in an update statement.
@@ -368,9 +387,12 @@
def getWhereTablePrefix(self, tbl, autoQuote=True):
- """ By default, the comparisons in the WHERE clauses of
+ """
+ By default, the comparisons in the WHERE clauses of
SQL statements will be in the form of
- tablename.fieldname
+
+ tablename.fieldname
+
but some backends do no accept this syntax. If not, change
this method to return an empty string, or whatever should
preceed the field name in a comparison in the WHERE clause
@@ -381,7 +403,8 @@
def massageDescription(self, cursor):
- """Some dbapi programs do strange things to the description.
+ """
+ Some dbapi programs do strange things to the description.
In particular, kinterbasdb forces the field names to upper case
if the field statement in the SQL that was executed contains an
'as' expression.
@@ -394,7 +417,8 @@
def getDescription(self, cursor):
- """Normally, cursors should always be able to report their
+ """
+ Normally, cursors should always be able to report their
description properly. However, some backends such as
SQLite will not report a description if there is no data in the
record set. This method provides a way for those backends
@@ -408,7 +432,8 @@
def pregenPK(self, cursor):
- """In the case where the database requires that PKs be generated
+ """
+ In the case where the database requires that PKs be generated
before an insert, this method provides a backend-specific
means of accomplishing this. By default, we return None.
"""
@@ -416,7 +441,8 @@
def setNonUpdateFields(self, cursor, autoQuote=True):
- """Normally, this routine should work for all backends. But
+ """
+ Normally, this routine should work for all backends. But
in the case of SQLite, the routine that grabs an empty cursor
doesn't fill in the description, so that backend has to use
an alternative approach.
@@ -581,7 +607,7 @@
wt.start()
def _getEncoding(self):
- """ Get backend encoding."""
+ """Get backend encoding."""
try:
return self._encoding
except AttributeError:
@@ -589,7 +615,8 @@
return self._encoding
def _setEncoding(self, enc):
- """ Set backend encoding. Must be overridden in the subclass
+ """
+ Set backend encoding. Must be overridden in the subclass
to notify database about proper charset conversion.
"""
self._encoding = enc
Modified: trunk/dabo/db/dConnectInfo.py
===================================================================
--- trunk/dabo/db/dConnectInfo.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/db/dConnectInfo.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -8,7 +8,8 @@
class dConnectInfo(dObject):
- """ Holder for the properties for connecting to the backend. Each
+ """
+ Holder for the properties for connecting to the backend. Each
backend may have different names for properties, but this object
tries to abstract that. The value stored in the Password must be
encrypted in the format set in the app. This class has 'encrypt' and
@@ -17,14 +18,14 @@
property for you.
You can create it in several ways, like most Dabo objects. First, you
- can pass all the settings as parameters to the constructor:
+ can pass all the settings as parameters to the constructor::
ci = dConnectInfo(DbType="MySQL", Host="domain.com",
User="daboUser", PlainTextPassword="secret", Port=3306,
Database="myData", Name="mainConnection")
Or you can create a dictionary of the various props, and pass that
- in the 'connInfo' parameter:
+ in the 'connInfo' parameter::
connDict = {"DbType" : "MySQL", "Host" : "domain.com",
"User" : "daboUser", "PlainTextPassword" : "secret",
@@ -32,7 +33,7 @@
ci = dConnectInfo(connInfo=connDict)
Or you can create the object and then set the props
- individually:
+ individually::
ci = dConnectInfo()
ci.DbType = "MySQL"
@@ -56,7 +57,8 @@
def lowerKeys(self, dct):
- """Takes a dict, and returns another dict identical except
+ """
+ Takes a dict, and returns another dict identical except
for the fact that all the keys that were string types are now
lower case.
"""
@@ -158,7 +160,7 @@
return None
def _setDbType(self, dbType):
- """ Set the backend type for the connection if valid. """
+ """Set the backend type for the connection if valid."""
_oldObject = self._backendObject
# As other backends are coded into the framework, we will need
# to expand the if/elif list.
Modified: trunk/dabo/db/dConnection.py
===================================================================
--- trunk/dabo/db/dConnection.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/db/dConnection.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -6,7 +6,7 @@
class dConnection(dObject):
- """ Hold a connection to a backend database. """
+ """Hold a connection to a backend database."""
def __init__(self, connectInfo=None, parent=None, forceCreate=False,
**kwargs):
self._baseClass = dConnection
self._forceCreate = forceCreate
@@ -49,7 +49,8 @@
def getDaboCursor(self, cursorClass=None):
- """ Accepts a backend-specific cursor class, mixes in the Dabo
+ """
+ Accepts a backend-specific cursor class, mixes in the Dabo
dCursorMixin class, and returns the result.
"""
if cursorClass is None:
@@ -75,20 +76,22 @@
def _openConnection(self, **kwargs):
- """ Open a connection to the database and store it for future
use. """
+ """Open a connection to the database and store it for future
use."""
self.getBackendObject().KeepAliveInterval =
self._connectInfo.KeepAliveInterval
return
self._connectInfo.getConnection(forceCreate=self._forceCreate, **kwargs)
def getBackendObject(self):
- """ Return a reference to the connectInfo's backend-specific
+ """
+ Return a reference to the connectInfo's backend-specific
database object.
"""
return self._connectInfo.getBackendObject()
def isRemote(self):
- """Returns True or False, depending on whether a RemoteHost is
+ """
+ Returns True or False, depending on whether a RemoteHost is
specified in this connection.
"""
return bool(self._connectInfo.RemoteHost)
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2011-02-19 14:44:03 UTC (rev 6450)
+++ trunk/dabo/db/dCursorMixin.py 2011-02-19 19:36:07 UTC (rev 6451)
@@ -189,7 +189,8 @@
def pkFieldExpression(self):
- """Returns the field or comma-separated list of field names
+ """
+ Returns the field or comma-separated list of field names
for the PK for this cursor's table.
"""
if isinstance(self.KeyField, tuple):
@@ -200,7 +201,8 @@
def _correctFieldType(self, field_val, field_name, _newQuery=False):
- """C
(75878 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/[email protected]