commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8906 - trunk/gnue-forms/src/GFObjects


From: reinhard
Subject: [gnue] r8906 - trunk/gnue-forms/src/GFObjects
Date: Mon, 23 Oct 2006 08:27:06 -0500 (CDT)

Author: reinhard
Date: 2006-10-23 08:27:04 -0500 (Mon, 23 Oct 2006)
New Revision: 8906

Modified:
   trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
Code reformatting.


Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-10-23 12:40:25 UTC (rev 
8905)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-10-23 13:27:04 UTC (rev 
8906)
@@ -50,315 +50,314 @@
 
 
 # =============================================================================
-# Wrapper of a block
+# <block>
 # =============================================================================
 
 class GFBlock (GFContainer, events.EventAware):
-  """
-  Class that represents the <block> tag in a gfd file.
-  """
+    """
+    Class that represents the <block> tag in a gfd file.
+    """
 
-  # ---------------------------------------------------------------------------
-  # Constructor
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
 
-  def __init__ (self, parent = None):
+    def __init__(self, parent=None):
 
-    GFContainer.__init__ (self, parent, 'GFBlock')
+        GFContainer.__init__ (self, parent, 'GFBlock')
 
-    self.mode = 'normal'
+        self.mode = 'normal'
 
-    self._resultSet      = None
-    self._dataSourceLink = None
+        self._resultSet      = None
+        self._dataSourceLink = None
 
-    self._currentRecord   = 0
-    self._recordCount     = 0
-    self._queryDefaults   = {}
+        self._currentRecord   = 0
+        self._recordCount     = 0
+        self._queryDefaults   = {}
 
-    self.__query_values      = {}
-    self.__last_query_values = {}
+        self.__query_values      = {}
+        self.__last_query_values = {}
 
-    #: A list of all GFScrollbar objects bound to this block
-    self.__scrollbars = []
+        #: A list of all GFScrollbar objects bound to this block
+        self.__scrollbars = []
 
-    # Populated by GFEntry's initialize
-    self._entryList = []
+        # Populated by GFEntry's initialize
+        self._entryList = []
 
-    # Populated by GFField's initialize
-    self._fieldMap  = {}
-    self._fieldList = []
+        # Populated by GFField's initialize
+        self._fieldMap  = {}
+        self._fieldList = []
 
-    # Current top of visible portion (only used for scrollbars, every entry
-    # maintains its own visible portion because the number of visible rows can
-    # differ per entry)
-    self.__visibleStart = 0
+        # Current top of visible portion (only used for scrollbars, every entry
+        # maintains its own visible portion because the number of visible rows 
can
+        # differ per entry)
+        self.__visibleStart = 0
 
-    # If this is true, notifying attached objects of current record changes is
-    # temporarily blocked
-    self.__scrolling_blocked = False
+        # If this is true, notifying attached objects of current record 
changes is
+        # temporarily blocked
+        self.__scrolling_blocked = False
 
-    # Trigger exposure
-    self._validTriggers = {
-      'ON-NEWRECORD':   'On-NewRecord',
-      'ON-RECORDLOADED':'On-RecordLoaded',
-      'PRE-COMMIT':     'Pre-Commit',
-      'POST-COMMIT':    'Post-Commit',
-      'PRE-QUERY':      'Pre-Query',
-      'POST-QUERY':     'Post-Query',
-      'PRE-MODIFY':     'Pre-Modify',
-      'PRE-INSERT':     'Pre-Insert',
-      'PRE-DELETE':     'Pre-Delete',
-      'PRE-UPDATE':     'Pre-Update',
-      'PRE-FOCUSOUT':   'Pre-FocusOut',
-      'POST-FOCUSOUT':  'Post-FocusOut',
-      'PRE-FOCUSIN':    'Pre-FocusIn',
-      'POST-FOCUSIN':   'Post-FocusIn',
-      'PRE-CHANGE':     'Pre-Change',
-      'POST-CHANGE':    'Post-Change',
-    }
+        # Trigger exposure
+        self._validTriggers = {
+                'ON-NEWRECORD':   'On-NewRecord',
+                'ON-RECORDLOADED':'On-RecordLoaded',
+                'PRE-COMMIT':     'Pre-Commit',
+                'POST-COMMIT':    'Post-Commit',
+                'PRE-QUERY':      'Pre-Query',
+                'POST-QUERY':     'Post-Query',
+                'PRE-MODIFY':     'Pre-Modify',
+                'PRE-INSERT':     'Pre-Insert',
+                'PRE-DELETE':     'Pre-Delete',
+                'PRE-UPDATE':     'Pre-Update',
+                'PRE-FOCUSOUT':   'Pre-FocusOut',
+                'POST-FOCUSOUT':  'Post-FocusOut',
+                'PRE-FOCUSIN':    'Pre-FocusIn',
+                'POST-FOCUSIN':   'Post-FocusIn',
+                'PRE-CHANGE':     'Pre-Change',
+                'POST-CHANGE':    'Post-Change'}
 
-    self._triggerGlobal = 1
-    self._triggerFunctions = {
-            # Record status
-            'get_record_status': {'function': self.get_record_status},
-            'isPending': {'function': self.is_pending},
-            'isSaved': {'function': self.is_saved},             # deprecated?
-            'isEmpty': {'function': self.is_empty},             # deprecated?
+        self._triggerGlobal = True
+        self._triggerFunctions = {
+                # Record status
+                'get_record_status': {'function': self.get_record_status},
+                'isPending': {'function': self.is_pending},
+                'isSaved': {'function': self.is_saved},         # deprecated?
+                'isEmpty': {'function': self.is_empty},         # deprecated?
 
-            # Record navigation
-            'firstRecord': {'function': self.first_record},
-            'prevRecord': {'function': self.prev_record},
-            'nextRecord': {'function': self.next_record},
-            'lastRecord': {'function': self.last_record},
-            'gotoRecord': {'function': self.goto_record},
-            'jumpRecords': {'function': self.jump_records},
+                # Record navigation
+                'firstRecord': {'function': self.first_record},
+                'prevRecord': {'function': self.prev_record},
+                'nextRecord': {'function': self.next_record},
+                'lastRecord': {'function': self.last_record},
+                'gotoRecord': {'function': self.goto_record},
+                'jumpRecords': {'function': self.jump_records},
 
-            # Record insertion and deletion
-            'newRecord': {'function': self.new_record},
-            'duplicateRecord': {'function': self.duplicate_record},
-            'deleteRecord': {'function': self.delete_record},
-            'undeleteRecord': {'function': self.undelete_record},
+                # Record insertion and deletion
+                'newRecord': {'function': self.new_record},
+                'duplicateRecord': {'function': self.duplicate_record},
+                'deleteRecord': {'function': self.delete_record},
+                'undeleteRecord': {'function': self.undelete_record},
 
-            # Other stuff
-            'call': {'function': self.callFunction},
-            'update': {'function': self.updateCurrentRecordSet},
-            'getResultSet': {'function': self.getResultSet},
-            'get_data': {'function': self.get_data}}
+                # Other stuff
+                'call': {'function': self.callFunction},
+                'update': {'function': self.updateCurrentRecordSet},
+                'getResultSet': {'function': self.getResultSet},
+                'get_data': {'function': self.get_data}}
 
 
-  # ---------------------------------------------------------------------------
-  # Object construction from xml
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Object construction from xml
+    # -------------------------------------------------------------------------
 
-  def _buildObject (self):
+    def _buildObject (self):
 
-    self._rows = getattr (self, 'rows', self._rows)
-    self._gap  = getattr (self, 'rowSpacer', self._gap)
+        self._rows = getattr (self, 'rows', self._rows)
+        self._gap  = getattr (self, 'rowSpacer', self._gap)
 
-    if hasattr (self, 'restrictDelete') and self.restrictDelete:
-      self.deletable = False
-      del self.__dict__ ['restrictDelete']
+        if hasattr (self, 'restrictDelete') and self.restrictDelete:
+            self.deletable = False
+            del self.__dict__ ['restrictDelete']
 
-    if hasattr (self, 'restrictInsert') and self.restrictInsert:
-      self.editable = 'update'
-      del self.__dict__ ['restrictInsert']
+        if hasattr (self, 'restrictInsert') and self.restrictInsert:
+            self.editable = 'update'
+            del self.__dict__ ['restrictInsert']
 
-    if hasattr (self,'datasource'):
-      self.datasource = self.datasource.lower ()
+        if hasattr (self,'datasource'):
+            self.datasource = self.datasource.lower ()
 
-    return GFContainer._buildObject (self)
+        return GFContainer._buildObject (self)
 
 
-  # ---------------------------------------------------------------------------
-  # Implementation of virtual methods
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Implementation of virtual methods
+    # -------------------------------------------------------------------------
 
-  def _phase_1_init_ (self):
+    def _phase_1_init_ (self):
 
-    GFContainer._phase_1_init_ (self)
+        GFContainer._phase_1_init_ (self)
 
-    self._convertAsterisksToPercent = gConfigForms('AsteriskWildcard')
+        self._convertAsterisksToPercent = gConfigForms('AsteriskWildcard')
 
-    self._logic = logic = self.findParentOfType ('GFLogic')
+        self._logic = logic = self.findParentOfType ('GFLogic')
 
-    self._lastValues = {}
+        self._lastValues = {}
 
-    logic._blockList.append (self)
-    logic._blockMap [self.name] = self
+        logic._blockList.append (self)
+        logic._blockMap [self.name] = self
 
-    # Initialize our events system
-    events.EventAware.__init__ (self, self._form._instance.eventController)
+        # Initialize our events system
+        events.EventAware.__init__ (self, self._form._instance.eventController)
 
-    # Create a stub/non-bound datasource if we aren't bound to one
-    if not hasattr (self, 'datasource') or not self.datasource:
-      ds = GFDataSource (self._form)
-      ds.type = 'unbound'
-      self.datasource = ds.name = "__dts_%s" % id (self)
-      self._form._datasourceDictionary [ds.name] = ds
-      ds._buildObject ()
-      ds.phaseInit ()
+        # Create a stub/non-bound datasource if we aren't bound to one
+        if not hasattr (self, 'datasource') or not self.datasource:
+            ds = GFDataSource (self._form)
+            ds.type = 'unbound'
+            self.datasource = ds.name = "__dts_%s" % id (self)
+            self._form._datasourceDictionary [ds.name] = ds
+            ds._buildObject ()
+            ds.phaseInit ()
 
-    dsDict = self._form._datasourceDictionary
-    self._dataSourceLink = dsDict.get (self.datasource)
+        dsDict = self._form._datasourceDictionary
+        self._dataSourceLink = dsDict.get (self.datasource)
 
-    if self._dataSourceLink is None:
-      raise DatasourceNotFoundError, (self.datasource, self)
+        if self._dataSourceLink is None:
+            raise DatasourceNotFoundError, (self.datasource, self)
 
-    # Register event handling functions
-    self._dataSourceLink.registerEventListeners ({
-        'dsResultSetActivated': self.__dsResultSetActivated,
-        'dsResultSetChanged'  : self.__dsResultSetActivated, # sic!
-        'dsCursorMoved'       : self.__dsCursorMoved,
-        'dsRecordInserted'    : self.__dsRecordInserted,
-        'dsRecordLoaded'      : self.__dsRecordLoaded,
-        'dsRecordTouched'     : self.__dsRecordTouched,
-        'dsCommitInsert'      : self.__dsCommitInsert,
-        'dsCommitUpdate'      : self.__dsCommitUpdate,
-        'dsCommitDelete'      : self.__dsCommitDelete})
+        # Register event handling functions
+        self._dataSourceLink.registerEventListeners ({
+                'dsResultSetActivated': self.__dsResultSetActivated,
+                'dsResultSetChanged'  : self.__dsResultSetActivated, # sic!
+                'dsCursorMoved'       : self.__dsCursorMoved,
+                'dsRecordInserted'    : self.__dsRecordInserted,
+                'dsRecordLoaded'      : self.__dsRecordLoaded,
+                'dsRecordTouched'     : self.__dsRecordTouched,
+                'dsCommitInsert'      : self.__dsCommitInsert,
+                'dsCommitUpdate'      : self.__dsCommitUpdate,
+                'dsCommitDelete'      : self.__dsCommitDelete})
 
-    # Get min and max child rows, if applicable
-    self._minChildRows = getattr (self._dataSourceLink, 'detailmin', 0)
-    self._maxChildRows = getattr (self._dataSourceLink, 'detailmax', None)
+        # Get min and max child rows, if applicable
+        self._minChildRows = getattr (self._dataSourceLink, 'detailmin', 0)
+        self._maxChildRows = getattr (self._dataSourceLink, 'detailmax', None)
 
-    self.walk (self.__setChildRowSettings)
+        self.walk (self.__setChildRowSettings)
 
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __setChildRowSettings (self, child):
+    def __setChildRowSettings (self, child):
 
-    # If a child has no rows- or rowSpacer-attribute copy the blocks values to
-    # the child 
-    child._rows = getattr (child, 'rows', self._rows)
-    child._gap  = getattr (child, 'rowSpacer', self._gap)
+        # If a child has no rows- or rowSpacer-attribute copy the blocks values
+        # to the child 
+        child._rows = getattr (child, 'rows', self._rows)
+        child._gap  = getattr (child, 'rowSpacer', self._gap)
 
 
-  # ---------------------------------------------------------------------------
-  # Get an ordered list of focus-controls
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Get an ordered list of focus-controls
+    # -------------------------------------------------------------------------
 
-  def get_focus_order (self):
+    def get_focus_order (self):
 
-    ctrlList = []
-    for field in self._children:
-      ctrlList += getattr (field, '_entryList', [])
+        ctrlList = []
+        for field in self._children:
+            ctrlList += getattr (field, '_entryList', [])
 
-    return GFContainer.get_focus_order (self, ctrlList)
+        return GFContainer.get_focus_order (self, ctrlList)
 
 
-  # ---------------------------------------------------------------------------
-  # Register a scrollbar widget
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Register a scrollbar widget
+    # -------------------------------------------------------------------------
 
-  def register_scrollbar (self, widget):
-    """
-    Register a given scrollbar widget to the block. This widget will be
-    notified on record movement. It has to implement a method
-    'adjust_scrollbar', taking the current record and the number of records
-    as arguments.
-    """
+    def register_scrollbar (self, widget):
+        """
+        Register a given scrollbar widget to the block. This widget will be
+        notified on record movement. It has to implement a method
+        'adjust_scrollbar', taking the current record and the number of records
+        as arguments.
+        """
 
-    self.__scrollbars.append (widget)
+        self.__scrollbars.append (widget)
 
 
-  # ---------------------------------------------------------------------------
-  # Event handling functions for datasource events
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Event handling functions for datasource events
+    # -------------------------------------------------------------------------
 
-  def __dsResultSetActivated (self, event):
+    def __dsResultSetActivated (self, event):
 
-    # FIXME: If an exception appears here, we have a problem: it is probably
-    # too late to cancel the operation.
-    self._focus_out()
+        # FIXME: If an exception appears here, we have a problem: it is 
probably
+        # too late to cancel the operation.
+        self._focus_out()
 
-    self._resultSet = event.resultSet
+        self._resultSet = event.resultSet
 
-    # FIXME: during commit, master datasources navigate the current record
-    # through the dirty record list and cause the detail blocks to follow
-    # through this event. However, in that case, we wouldn't want the UI to
-    # follow, so we wouldn't want to run the following lines in that case.
-    recno = self._resultSet.getRecordNumber ()
-    if recno == -1:
-      self.__scrolling_blocked = True
-      try:
-        if not self._resultSet.firstRecord ():
-          self._resultSet.insertRecord(self._lastValues)
-      finally:
-        self.__scrolling_blocked = False
+        # FIXME: during commit, master datasources navigate the current record
+        # through the dirty record list and cause the detail blocks to follow
+        # through this event. However, in that case, we wouldn't want the UI to
+        # follow, so we wouldn't want to run the following lines in that case.
+        recno = self._resultSet.getRecordNumber ()
+        if recno == -1:
+            self.__scrolling_blocked = True
+            try:
+                if not self._resultSet.firstRecord ():
+                    self._resultSet.insertRecord(self._lastValues)
+            finally:
+                self.__scrolling_blocked = False
 
-    self.__current_record_changed(True)
+        self.__current_record_changed(True)
 
-    self._focus_in()
+        self._focus_in()
 
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __dsCursorMoved (self, event):
+    def __dsCursorMoved (self, event):
 
-    if self.__scrolling_blocked:
-        return
+        if self.__scrolling_blocked:
+            return
 
-    # Blocks can't cope with current record #-1
-    recno = self._resultSet.getRecordNumber ()
-    if recno != -1:
-      self.__current_record_changed(False)
+        # Blocks can't cope with current record #-1
+        recno = self._resultSet.getRecordNumber ()
+        if recno != -1:
+            self.__current_record_changed(False)
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __dsRecordInserted (self, event):
-    self._initializingRecord = event.record
-    oldmode = self.mode
-    self.mode = 'init'
-    self.processTrigger ('ON-NEWRECORD')
-    self.mode = oldmode
+    def __dsRecordInserted (self, event):
+        self._initializingRecord = event.record
+        oldmode = self.mode
+        self.mode = 'init'
+        self.processTrigger ('ON-NEWRECORD')
+        self.mode = oldmode
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __dsRecordLoaded (self, event):
-    self._initializingRecord = event.record
-    oldmode = self.mode
-    self.mode = 'init'
-    self.processTrigger ('ON-RECORDLOADED')
-    self.mode = oldmode
+    def __dsRecordLoaded (self, event):
+        self._initializingRecord = event.record
+        oldmode = self.mode
+        self.mode = 'init'
+        self.processTrigger ('ON-RECORDLOADED')
+        self.mode = oldmode
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __dsRecordTouched (self, event):
-    # This already gets called by GFField??
-    # self.__fireRecordTrigger ('PRE-CHANGE')
-    pass
+    def __dsRecordTouched (self, event):
+        # This already gets called by GFField??
+        # self.__fireRecordTrigger ('PRE-CHANGE')
+        pass
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __dsCommitInsert (self, event):
-    self.__fireRecordTrigger ('PRE-INSERT')
-    self.__fireRecordTrigger ('PRE-COMMIT')
+    def __dsCommitInsert (self, event):
+        self.__fireRecordTrigger ('PRE-INSERT')
+        self.__fireRecordTrigger ('PRE-COMMIT')
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __dsCommitUpdate (self, event):
-    self.__fireRecordTrigger ('PRE-UPDATE')
-    self.__fireRecordTrigger ('PRE-COMMIT')
+    def __dsCommitUpdate (self, event):
+        self.__fireRecordTrigger ('PRE-UPDATE')
+        self.__fireRecordTrigger ('PRE-COMMIT')
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __dsCommitDelete (self, event):
-    self.__fireRecordTrigger ('PRE-DELETE')
-    self.__fireRecordTrigger ('PRE-COMMIT')
+    def __dsCommitDelete (self, event):
+        self.__fireRecordTrigger ('PRE-DELETE')
+        self.__fireRecordTrigger ('PRE-COMMIT')
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __fireRecordTrigger (self, trigger):
-    self.processTrigger (trigger)
-    for field in self._fieldList:
-      field.processTrigger (trigger)
+    def __fireRecordTrigger (self, trigger):
+        self.processTrigger (trigger)
+        for field in self._fieldList:
+            field.processTrigger (trigger)
 
 
-  # ---------------------------------------------------------------------------
-  # Event handlers for UI events (scrollbar or mouse wheel)
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Event handlers for UI events (scrollbar or mouse wheel)
+    # -------------------------------------------------------------------------
 
-  def _event_rows_changed (self, new_rows):
+    def _event_rows_changed (self, new_rows):
         """
         Notify the block that the number of rows displayed has changed.
 
@@ -374,21 +373,21 @@
         else:
             self.__adjust_scrollbars()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def _event_scroll_delta (self, adjustment):
-    """
-    Scroll the given number of records.
+    def _event_scroll_delta (self, adjustment):
+        """
+        Scroll the given number of records.
 
-    @param adjustment: number of records to move relative to the current
-      record.
-    """
+        @param adjustment: number of records to move relative to the current
+            record.
+        """
   
-    self._event_scroll_to_record (self.__visibleStart + adjustment)
+        self._event_scroll_to_record (self.__visibleStart + adjustment)
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def _event_scroll_to_record (self, position):
+    def _event_scroll_to_record (self, position):
         """
         Scrolls the block to the given position.
 
@@ -423,11 +422,11 @@
             self.__new_current_record()
 
 
-  # ---------------------------------------------------------------------------
-  # Field access
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Field access
+    # -------------------------------------------------------------------------
 
-  def get_value(self, field, offset):
+    def get_value(self, field, offset):
         """
         Return the value of the given field, depending on the block's state.
 
@@ -461,9 +460,9 @@
 
         return value
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def set_value(self, field, value):
+    def set_value(self, field, value):
         """
         Set the value of the given field, depending on the block's state.
 
@@ -498,11 +497,11 @@
             field.value_changed()
 
 
-  # ---------------------------------------------------------------------------
-  # Status information
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Status information
+    # -------------------------------------------------------------------------
 
-  def get_record_status(self):
+    def get_record_status(self):
         """
         Find out about the status of the record.
 
@@ -532,9 +531,9 @@
         else:
             return 'clean'
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def get_possible_operations(self):
+    def get_possible_operations(self):
         """
         Return a list of possible operations for this block.
 
@@ -583,9 +582,9 @@
 
         return result
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def is_saved(self):
+    def is_saved(self):
         """
         Return True if the block is not pending any uncommited changes.
 
@@ -595,18 +594,18 @@
         assert gDebug(1, "DEPRECIATION WARNING: block.isSaved()")
         return not self.is_pending()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def is_pending(self):
+    def is_pending(self):
         """
         Return True if the block is pending any uncommited changes.
         """
 
         return self._resultSet is not None and self._resultSet.isPending()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def is_empty(self):
+    def is_empty(self):
         """
         Return True if the current record is empty.
 
@@ -618,18 +617,18 @@
         return self._resultSet is None or self._resultSet.current is None \
                 or self._resultSet.current.isEmpty()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def is_first_record (self):
+    def is_first_record (self):
         """
         Returns True if the current record is the first one in the ResultSet
         """
 
         return self._resultSet.isFirstRecord()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def is_last_record (self):
+    def is_last_record (self):
         """
         Returns True if the current record is the last one in the ResultSet.
         """
@@ -637,11 +636,11 @@
         return self._resultSet.isLastRecord ()
 
 
-  # ---------------------------------------------------------------------------
-  # Record Navigation
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Record Navigation
+    # -------------------------------------------------------------------------
 
-  def first_record(self):
+    def first_record(self):
         """
         Move to the first record of the block. Pre- and Post-Focusout triggers
         are fired before moving as well as Pre- and Post-Focusin triggers after
@@ -660,9 +659,9 @@
 
         self._focus_in()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def prev_record(self):
+    def prev_record(self):
         """
         Move to the previous record of the block. Pre- and Post-Focusout
         triggers are fired before moving as well as Pre- and Post-Focusin
@@ -681,9 +680,9 @@
 
         self._focus_in()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def next_record(self):
+    def next_record(self):
         """
         Move to the next record. If autoCommit is set a commit is performed
         prior to move the record pointer. If the record is already the last
@@ -707,9 +706,9 @@
 
         self._focus_in()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def last_record(self):
+    def last_record(self):
         """
         Move to the last record of the block. Pre- and Post-Focusout triggers
         are fired before moving as well as Pre- and Post-Focusin triggers after
@@ -728,9 +727,9 @@
 
         self._focus_in()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def goto_record(self, record_number):
+    def goto_record(self, record_number):
         """
         Jump to a specific record. If the block is the block being currently
         edited in the form, the focus-out and focus-in block-level triggers
@@ -759,9 +758,9 @@
 
         self._focus_in()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def jump_records(self, count):
+    def jump_records(self, count):
         """
         Move the record-pointer by a given adjustment relative to the current
         record.
@@ -777,11 +776,11 @@
         self.goto_record(record_number)
 
 
-  # ---------------------------------------------------------------------------
-  # Insertion and Deletion of Records
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Insertion and Deletion of Records
+    # -------------------------------------------------------------------------
 
-  def new_record(self):
+    def new_record(self):
         """
         Add a new record to the block. If autoCommit is set and a record is
         currently pending it will be commited first.
@@ -796,9 +795,9 @@
 
         self._focus_in()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def duplicate_record(self, exclude=(), include=()):
+    def duplicate_record(self, exclude=(), include=()):
         """
         Create a new record and initialize it with field values from the record
         at the current cursor position.
@@ -818,9 +817,9 @@
 
         self._focus_in()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def delete_record(self):
+    def delete_record(self):
         """
         Mark the current record for deletion. The acutal deletion will be done
         on the next commit, call or update.
@@ -834,9 +833,9 @@
         if self._form.get_focus_block() is self:
             self.__update_record_status()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def undelete_record(self):
+    def undelete_record(self):
         """
         Removes the deletion mark from the current record.
         """
@@ -850,11 +849,11 @@
             self.__update_record_status()
 
 
-  # ---------------------------------------------------------------------------
-  # Queries
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Queries
+    # -------------------------------------------------------------------------
 
-  def init_query(self):
+    def init_query(self):
 
         self.mode = 'query'
         self.__query_values = {}
@@ -863,9 +862,9 @@
         if self._form.get_focus_block() is self:
             self.__update_record_status()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def copy_query(self):
+    def copy_query(self):
 
         self.__query_values = {}
         self.__query_values.update(self.__last_query_values)
@@ -873,81 +872,81 @@
         if self._form.get_focus_block() is self:
             self.__update_record_status()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def cancel_query(self):
+    def cancel_query(self):
 
         self.mode = 'normal'
         self.__current_record_changed(True)
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def execute_query(self):
+    def execute_query(self):
 
-    # Set the maxList to a single master block as a placeholder.
-    maxList = [self._getTopMasterBlock ()]
+        # Set the maxList to a single master block as a placeholder.
+        maxList = [self._getTopMasterBlock ()]
 
-    # Find the longest master/detail chain that contains query values.  This
-    # will become the chain that is queried.
-    for block in self._logic._blockList:
-      if block.__query_values.keys ():
-        templist = [block]
+        # Find the longest master/detail chain that contains query values. This
+        # will become the chain that is queried.
+        for block in self._logic._blockList:
+            if block.__query_values.keys ():
+                templist = [block]
 
-        while (templist [-1])._getMasterBlock ():
-          templist.append ((templist [-1])._getMasterBlock ())
+                while (templist [-1])._getMasterBlock ():
+                    templist.append ((templist [-1])._getMasterBlock ())
 
-        if len (maxList) < len (templist):
-          maxList = templist
+                if len (maxList) < len (templist):
+                    maxList = templist
 
-    # Store block states
-    for block in self._logic._blockList:
-      block.__last_query_values = {}
-      block.__last_query_values.update (block.__query_values)
+        # Store block states
+        for block in self._logic._blockList:
+            block.__last_query_values = {}
+            block.__last_query_values.update (block.__query_values)
 
-    # graft in the sloppy query stuff if needed
-    for block in maxList:
-      for entry in block._entryList:
-        if entry._type == 'GFEntry' and \
-           hasattr (entry._field, 'sloppyQuery') and \
-           block.__query_values.has_key (entry._field):
-          block.__query_values [entry._field] = "%" + \
-            "%".join (list (block.__query_values [entry._field])) + "%"
+        # graft in the sloppy query stuff if needed
+        for block in maxList:
+            for entry in block._entryList:
+                if entry._type == 'GFEntry' and \
+                        hasattr (entry._field, 'sloppyQuery') and \
+                        block.__query_values.has_key (entry._field):
+                    block.__query_values [entry._field] = "%" + "%".join(
+                            list (block.__query_values [entry._field])) + "%"
 
-    # Find root block
-    rootBlock = maxList [-1]
+        # Find root block
+        rootBlock = maxList [-1]
 
-    # Condition for the master block
-    conditions = rootBlock._generateConditional ()
+        # Condition for the master block
+        conditions = rootBlock._generateConditional ()
 
-    # Conditions for the detail block
-    for block in maxList [:-1]:
+        # Conditions for the detail block
+        for block in maxList [:-1]:
 
-      block.processTrigger ('PRE-QUERY')
-      for field in block._fieldList:
-        field.processTrigger ('PRE-QUERY')
+            block.processTrigger ('PRE-QUERY')
+            for field in block._fieldList:
+                field.processTrigger ('PRE-QUERY')
 
-      c = block._generateConditional ()
-      exist = GConditions.GCexist ()
-      exist.table = block._dataSourceLink.table
-      exist.masterlink = block._dataSourceLink.masterlink
-      exist.detaillink = block._dataSourceLink.detaillink
-      exist._children = [c]
-      conditions = GConditions.combineConditions (conditions, exist)
+            c = block._generateConditional ()
+            exist = GConditions.GCexist ()
+            exist.table = block._dataSourceLink.table
+            exist.masterlink = block._dataSourceLink.masterlink
+            exist.detaillink = block._dataSourceLink.detaillink
+            exist._children = [c]
+            conditions = GConditions.combineConditions (conditions, exist)
 
-    rootBlock._dataSourceLink.createResultSet (conditions)
+        rootBlock._dataSourceLink.createResultSet (conditions)
 
-    for block in self._logic._blockList:
-      block.processTrigger ('POST-QUERY')
-      for field in block._fieldList:
-        field.processTrigger ('POST-QUERY')
-      block.cancel_query()
+        for block in self._logic._blockList:
+            block.processTrigger ('POST-QUERY')
+            for field in block._fieldList:
+                field.processTrigger ('POST-QUERY')
+            block.cancel_query()
 
 
-  # ---------------------------------------------------------------------------
-  # Saving and Discarding
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Saving and Discarding
+    # -------------------------------------------------------------------------
 
-  def post(self):
+    def post(self):
         """
         Post all pending changes of the block
         """
@@ -961,9 +960,9 @@
         if self._getMasterBlock() is None:
             self._dataSourceLink.postAll()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def requery(self, commit):
+    def requery(self, commit):
         """
         Called after the commit on the backend is through.
         """
@@ -984,9 +983,9 @@
 
         self.__current_record_changed(True)
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def clear(self):
+    def clear(self):
         """
         Clear the result set of this block.
         """
@@ -998,81 +997,81 @@
         self._dataSourceLink.createEmptyResultSet()
 
 
-  # ---------------------------------------------------------------------------
-  # Function and Update
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Function and Update
+    # -------------------------------------------------------------------------
 
-  def callFunction (self, name, parameters):
+    def callFunction (self, name, parameters):
 
-    # Remember the current record; the record pointer is not reliable between
-    # postAll and requeryAll!
-    current = self._resultSet.current
-    self._dataSourceLink.postAll ()
+        # Remember the current record; the record pointer is not reliable
+        # between postAll and requeryAll!
+        current = self._resultSet.current
+        self._dataSourceLink.postAll ()
 
-    try:
-      res = current.call (name, parameters)
-    finally:
-      self._dataSourceLink.requeryAll (False)
+        try:
+            res = current.call (name, parameters)
+        finally:
+            self._dataSourceLink.requeryAll (False)
 
-    return res
+        return res
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def updateCurrentRecordSet (self):
+    def updateCurrentRecordSet (self):
 
-    self._dataSourceLink.postAll ()
-    self._dataSourceLink.requeryAll (False)
+        self._dataSourceLink.postAll ()
+        self._dataSourceLink.requeryAll (False)
 
 
-  # ---------------------------------------------------------------------------
-  # Raw data access
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Raw data access
+    # -------------------------------------------------------------------------
 
-  def getResultSet (self):
-    """
-    Return the current ResultSet of the block.
-    """
+    def getResultSet (self):
+        """
+        Return the current ResultSet of the block.
+        """
 
-    return self._resultSet
+        return self._resultSet
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def get_data(self, fieldnames):
-      """
-      Build a list of dictionaries of the current resultset using the fields
-      defined by fieldnames.
+    def get_data(self, fieldnames):
+        """
+        Build a list of dictionaries of the current resultset using the fields
+        defined by fieldnames.
 
-      @param fieldnames: list of fieldnames to export per record
-      @returns: list of dictionaries (one per record)
-      """
+        @param fieldnames: list of fieldnames to export per record
+        @returns: list of dictionaries (one per record)
+        """
 
-      result = []
-      if not fieldnames:
-          fields = self._fieldMap.values()
-      else:
-          fields = [self._fieldMap[fld] for fld in fieldnames]
+        result = []
+        if not fieldnames:
+            fields = self._fieldMap.values()
+        else:
+            fields = [self._fieldMap[fld] for fld in fieldnames]
 
-      for r in self._resultSet:
-          add = {}
-          for field in fields:
-              fname = field.field
-              if hasattr(field, 'fk_source'):
-                  value = field._allowedValues.get(r[fname])
-              else:
-                  value = r[fname]
+        for r in self._resultSet:
+            add = {}
+            for field in fields:
+                fname = field.field
+                if hasattr(field, 'fk_source'):
+                    value = field._allowedValues.get(r[fname])
+                else:
+                    value = r[fname]
 
-              add[fname] = value
+                add[fname] = value
 
-          result.append(add)
+            result.append(add)
 
-      return result
+        return result
 
 
-  # ---------------------------------------------------------------------------
-  # Shared code called whenever focus enters or leaves a record
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Shared code called whenever focus enters or leaves a record
+    # -------------------------------------------------------------------------
 
-  def _focus_in(self):
+    def _focus_in(self):
 
         if self._form.get_focus_block() is self:
             self.focus_in()
@@ -1082,9 +1081,9 @@
 
             self._form.beginEditing()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def _focus_out(self):
+    def _focus_out(self):
 
         if self._form.get_focus_block() is self:
 
@@ -1103,11 +1102,11 @@
                 raise
 
 
-  # ---------------------------------------------------------------------------
-  # Focus handling
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Focus handling
+    # -------------------------------------------------------------------------
 
-  def focus_in(self):
+    def focus_in(self):
         """
         Notify the block that it has received the focus.
         """
@@ -1118,9 +1117,9 @@
 
         self.__update_record_status()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def validate(self):
+    def validate(self):
         """
         Validate the block to decide whether the focus can be moved away from
         it.
@@ -1135,9 +1134,9 @@
             if self.autoCommit and self.is_pending():
                 self._form.execute_commit()
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def focus_out(self):
+    def focus_out(self):
         """
         Notify the block that it is going to lose the focus.
 
@@ -1149,66 +1148,66 @@
             self.processTrigger('POST-FOCUSOUT')
 
 
-  # ---------------------------------------------------------------------------
-  # Current record has changed
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Current record has changed
+    # -------------------------------------------------------------------------
 
-  def __current_record_changed(self, refresh_all):
+    def __current_record_changed(self, refresh_all):
 
         self.__switch_record(None, refresh_all)
         self.__new_current_record()
 
 
-  # ---------------------------------------------------------------------------
-  # Switch the proper record into editing position
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Switch the proper record into editing position
+    # -------------------------------------------------------------------------
 
-  def __switch_record (self, new_visible_start, refresh_all):
+    def __switch_record (self, new_visible_start, refresh_all):
 
-    if self.mode == 'query':
-        newRecord = 0
-        newRecordCount = 1
-    else:
-        newRecord      = self._resultSet.getRecordNumber ()
-        newRecordCount = self._resultSet.getRecordCount ()
+        if self.mode == 'query':
+            newRecord = 0
+            newRecordCount = 1
+        else:
+            newRecord      = self._resultSet.getRecordNumber ()
+            newRecordCount = self._resultSet.getRecordCount ()
 
-    adjustment = newRecord - self._currentRecord
+        adjustment = newRecord - self._currentRecord
 
-    if new_visible_start is None:
-        new_visible_start = self.__visibleStart
-    new_visible_start = min(new_visible_start, newRecord)
-    new_visible_start = max(new_visible_start, newRecord - self._rows + 1)
-    new_visible_start = max(new_visible_start, 0)
+        if new_visible_start is None:
+            new_visible_start = self.__visibleStart
+        new_visible_start = min(new_visible_start, newRecord)
+        new_visible_start = max(new_visible_start, newRecord - self._rows + 1)
+        new_visible_start = max(new_visible_start, 0)
 
-    adjustment += self.__visibleStart - new_visible_start
-    self.__visibleStart = new_visible_start
+        adjustment += self.__visibleStart - new_visible_start
+        self.__visibleStart = new_visible_start
 
-    # Find out which ui entries to refresh
-    if refresh_all:
-        # Result set completely changed, refresh everything
-        refresh = 'all'
-    elif newRecordCount != self._recordCount:
-        # Newly inserted or deleted record, so all records starting from this
-        # one have moved, so refresh them
-        refresh = 'current'
-    else:
-        refresh = 'none'
+        # Find out which ui entries to refresh
+        if refresh_all:
+            # Result set completely changed, refresh everything
+            refresh = 'all'
+        elif newRecordCount != self._recordCount:
+            # Newly inserted or deleted record, so all records starting from
+            # this one have moved, so refresh them
+            refresh = 'current'
+        else:
+            refresh = 'none'
 
-    self._currentRecord = newRecord
-    self._recordCount   = newRecordCount
+        self._currentRecord = newRecord
+        self._recordCount   = newRecordCount
 
-    for entry in self._entryList:
-        entry.recalculate_visible (adjustment, self._currentRecord,
-                self._recordCount, refresh)
+        for entry in self._entryList:
+            entry.recalculate_visible (adjustment, self._currentRecord,
+                    self._recordCount, refresh)
 
-    self.__adjust_scrollbars()
+        self.__adjust_scrollbars()
 
 
-  # ---------------------------------------------------------------------------
-  # Things that have to be done if a new current record is activated
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Things that have to be done if a new current record is activated
+    # -------------------------------------------------------------------------
 
-  def __new_current_record(self):
+    def __new_current_record(self):
 
         for field in self._fieldList:
             field._event_new_current_record()
@@ -1216,11 +1215,11 @@
         self._form.refreshUIEvents()
 
 
-  # ---------------------------------------------------------------------------
-  # Update the record status
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Update the record status
+    # -------------------------------------------------------------------------
 
-  def __update_record_status(self):
+    def __update_record_status(self):
 
         if self.mode == 'query':
             record_number = 1
@@ -1243,162 +1242,166 @@
 
         self._form.update_record_status(record_status)
 
-  # ---------------------------------------------------------------------------
-  # Adjust the scrollbars connected to this block
-  # ---------------------------------------------------------------------------
 
-  def __adjust_scrollbars(self):
+    # -------------------------------------------------------------------------
+    # Adjust the scrollbars connected to this block
+    # -------------------------------------------------------------------------
 
+    def __adjust_scrollbars(self):
+
         for sb in self.__scrollbars:
             sb.adjust_scrollbar (self.__visibleStart,
                     max (self._recordCount, self.__visibleStart + self._rows))
 
 
-  # ---------------------------------------------------------------------------
-  # Return the top level master block of this block
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Return the top level master block of this block
+    # -------------------------------------------------------------------------
 
-  def _getTopMasterBlock (self):
+    def _getTopMasterBlock (self):
 
-    result = self
-    master = result._getMasterBlock ()
-    while master is not None:
-      result = master
-      master = result._getMasterBlock ()
-    return result
+        result = self
+        master = result._getMasterBlock ()
+        while master is not None:
+            result = master
+            master = result._getMasterBlock ()
+        return result
 
 
-  # ---------------------------------------------------------------------------
-  # Return the master block of this block
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Return the master block of this block
+    # -------------------------------------------------------------------------
 
-  def _getMasterBlock (self):
+    def _getMasterBlock (self):
 
-    if self._dataSourceLink.hasMaster ():
-      ds = self._dataSourceLink.getMaster ()
-      for block in self._logic._blockList:
-        if block._dataSourceLink == ds:
-          return block
-      # return None in case our master is not bound to a block; e.g. if our
-      # master is a dropdown
-      return None
-    else:
-      return None
+        if self._dataSourceLink.hasMaster ():
+            ds = self._dataSourceLink.getMaster ()
+            for block in self._logic._blockList:
+                if block._dataSourceLink == ds:
+                    return block
+            # return None in case our master is not bound to a block; e.g. if
+            # our master is a dropdown
+            return None
+        else:
+            return None
 
 
-  # ---------------------------------------------------------------------------
-  # Create a condition tree
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Create a condition tree
+    # -------------------------------------------------------------------------
 
-  def _generateConditional (self):
-    """
-    Create a condition tree based upon the values currently stored in the form.
+    def _generateConditional (self):
+        """
+        Create a condition tree based upon the values currently stored in the
+        form.
 
-    @return: GCondition instance with the condition to use or an empty
-        dictionary if no condition is needed.
-    """
+        @return: GCondition instance with the condition to use or an empty
+            dictionary if no condition is needed.
+        """
 
-    # 'user input': [GCondition, pass value?]
-    baseComparisons = { '>': ['gt', True],
-                        '>=': ['ge', True],
-                        '<': ['lt', True],
-                        '<=': ['le', True],
-                        '=': ['eq', True],
-                        '!=': ['ne', True],
-                        'like': ['like', True],
-                        'empty': ['null', False],
-                        'notempty': ['notnull', False],
-                      }
-    comparisonDelimeter = ":"
+        # 'user input': [GCondition, pass value?]
+        baseComparisons = {
+                '>': ['gt', True],
+                '>=': ['ge', True],
+                '<': ['lt', True],
+                '<=': ['le', True],
+                '=': ['eq', True],
+                '!=': ['ne', True],
+                'like': ['like', True],
+                'empty': ['null', False],
+                'notempty': ['notnull', False]}
+        comparisonDelimiter = ":"
   
-    condLike = {}
-    condEq   = {}
-    conditions = []
-    # Get all the user-supplied parameters from the entry widgets
-    for entry, val in self.__query_values.items ():
-      if entry._bound and entry.isQueryable () and len (("%s" % val)):
+        condLike = {}
+        condEq   = {}
+        conditions = []
+        # Get all the user-supplied parameters from the entry widgets
+        for entry, val in self.__query_values.items ():
+            if entry._bound and entry.isQueryable () and len (("%s" % val)):
       
-        # New : operator support
-        match = False
-        for comparison in baseComparisons.keys():
-          
-          if isinstance(val, basestring) and \
-                  val[:2+len(comparison)].lower() == "%s%s%s" % \
-            (comparisonDelimeter, comparison, comparisonDelimeter):
-            value=val[2+len(comparison):]
-          
-            if baseComparisons[comparison][1]:
-                field = ['field', entry.field]
-                const = ['const', value]
+                # New : operator support
+                match = False
+                for comparison in baseComparisons.keys():
+                    if isinstance(val, basestring) and \
+                            val[:2+len(comparison)].lower() == "%s%s%s" % \
+                        (comparisonDelimiter, comparison, comparisonDelimiter):
+                        value=val[2+len(comparison):]
 
-                if not entry.query_casesensitive:
-                    field = ['upper', field]
-                    const = ['upper', const]
+                        if baseComparisons[comparison][1]:
+                            field = ['field', entry.field]
+                            const = ['const', value]
 
-                conditions.append([baseComparisons[comparison][0], field, 
const])
-            else:
-              conditions.append([ baseComparisons[comparison][0],
-                                  ['field', entry.field]
-                                ])
-            match = True
-            break
+                            if not entry.query_casesensitive:
+                                field = ['upper', field]
+                                const = ['upper', const]
 
-        if not match and isinstance(val, bool) and not val:
-            conditions.append(['or', \
-                    ['eq', ['field', entry.field], ['const', val]],
-                    ['null', ['field', entry.field]]])
-            match = True
+                            conditions.append([
+                                baseComparisons[comparison][0],
+                                field,
+                                const])
+                        else:
+                            conditions.append([
+                                baseComparisons[comparison][0],
+                                ['field', entry.field]])
+                        match = True
+                        break
 
-      
-        # Falls through to old behaviour if no : condition given or 
-        # the : condition is unknown
-        if not match:
-          if entry.typecast == 'text':
-            if self._convertAsterisksToPercent:
-              try:
-                val = ("%s" % val).replace ('*', '%')
-              except ValueError:
-                pass
+                if not match and isinstance(val, bool) and not val:
+                    conditions.append(['or', \
+                            ['eq', ['field', entry.field], ['const', val]],
+                            ['null', ['field', entry.field]]])
+                    match = True
 
-            val = cond_value(val)
+                # Falls through to old behaviour if no : condition given or 
+                # the : condition is unknown
+                if not match:
+                    if entry.typecast == 'text':
+                        if self._convertAsterisksToPercent:
+                            try:
+                                val = ("%s" % val).replace ('*', '%')
+                            except ValueError:
+                                pass
+
+                        val = cond_value(val)
   
-            if (val.find ('%') >= 0 or val.find ('_') >= 0):
-              condLike [entry] = val
-            else:
-              condEq [entry] = val
-          else:
-            condEq [entry] = val
+                        if (val.find ('%') >= 0 or val.find ('_') >= 0):
+                            condLike [entry] = val
+                        else:
+                            condEq [entry] = val
+                    else:
+                        condEq [entry] = val
 
-    epf = []
-    for (entry, value) in condEq.items():
-        field = ['field', entry.field]
-        const = ['const', value]
+        epf = []
+        for (entry, value) in condEq.items():
+            field = ['field', entry.field]
+            const = ['const', value]
 
-        if not entry.query_casesensitive:
-            field = ['upper', field]
-            const = ['upper', const]
+            if not entry.query_casesensitive:
+                field = ['upper', field]
+                const = ['upper', const]
 
-        epf.append(['eq', field, const])
+            epf.append(['eq', field, const])
 
-    lpf = []
-    for (entry, value) in condLike.items():
-        field = ['field', entry.field]
-        const = ['const', value]
+        lpf = []
+        for (entry, value) in condLike.items():
+            field = ['field', entry.field]
+            const = ['const', value]
 
-        if not entry.query_casesensitive:
-            field = ['upper', field]
-            const = ['upper', const]
+            if not entry.query_casesensitive:
+                field = ['upper', field]
+                const = ['upper', const]
 
-        epf.append(['like', field, const])
+            epf.append(['like', field, const])
 
-    if epf or lpf or conditions:
-      result = GConditions.buildConditionFromPrefix (['and'] + epf +
-                                                     lpf + conditions)
-    else:
-      result = {}
+        if epf or lpf or conditions:
+            result = GConditions.buildConditionFromPrefix(
+                    ['and'] + epf + lpf + conditions)
+        else:
+            result = {}
 
-    return result
+        return result
 
+
 # -----------------------------------------------------------------------------
 # Change a condition value as needed
 # -----------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]