[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8366 - in trunk/gnue-forms/src: . GFObjects
From: |
johannes |
Subject: |
[gnue] r8366 - in trunk/gnue-forms/src: . GFObjects |
Date: |
Wed, 5 Apr 2006 03:53:04 -0500 (CDT) |
Author: johannes
Date: 2006-04-05 03:53:03 -0500 (Wed, 05 Apr 2006)
New Revision: 8366
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/GFInstance.py
trunk/gnue-forms/src/GFObjects/GFBlock.py
trunk/gnue-forms/src/GFObjects/GFBox.py
trunk/gnue-forms/src/GFObjects/GFButton.py
trunk/gnue-forms/src/GFObjects/GFComponent.py
trunk/gnue-forms/src/GFObjects/GFContainer.py
trunk/gnue-forms/src/GFObjects/GFDataSource.py
trunk/gnue-forms/src/GFObjects/GFEntry.py
trunk/gnue-forms/src/GFObjects/GFField.py
trunk/gnue-forms/src/GFObjects/GFImage.py
trunk/gnue-forms/src/GFObjects/GFLabel.py
trunk/gnue-forms/src/GFObjects/GFLayout.py
trunk/gnue-forms/src/GFObjects/GFObj.py
trunk/gnue-forms/src/GFObjects/GFPage.py
trunk/gnue-forms/src/GFObjects/GFScrollBar.py
trunk/gnue-forms/src/GFObjects/GFTabStop.py
Log:
Fixed blockChange detection for buttons, pep8-ified
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2006-04-05 08:32:50 UTC (rev 8365)
+++ trunk/gnue-forms/src/GFForm.py 2006-04-05 08:53:03 UTC (rev 8366)
@@ -312,11 +312,11 @@
mode = self.getCurrentMode()
if isinstance(object, GFObj):
- if object.isNavigable(mode):
+ if object.is_navigable(mode):
return object
else:
- if hasattr(object, 'getFocusOrder'):
- for child in object.getFocusOrder():
+ if hasattr(object, 'get_focus_order'):
+ for child in object.get_focus_order():
entry = self.findFocus(child)
if entry:
return entry
@@ -398,12 +398,16 @@
return True
fieldChange = widget != self._currentEntry
- try:
- blockChange = widget._block != self._currentBlock
- except AttributeError:
- # Buttons don't have a block, but also
- # don't trigger a block change
- blockChange = False
+
+ # Determine wether the block should be changed. Since buttons do have a
+ # block attribute now, we have to take care a bit. Only set a
+ # blockChange if the widget has a valid block attribute.
+ newBlock = getattr(widget, '_block', None)
+ if newBlock is not None:
+ blockChange = self._currentBlock != newBlock
+ else:
+ blockChange = False
+
pageChange = widget._page != self._currentPage
if fireFocusTriggers:
@@ -429,17 +433,16 @@
oldEntry = self._currentEntry
self._currentEntry = widget
- try:
- self._currentBlock = self._currentEntry._block
- except AttributeError:
- pass # Buttons, et al
+ if newBlock is not None:
+ self._currentBlock = newBlock
+
self._currentPage = self._currentEntry._page
if pageChange:
self.dispatchEvent('gotoPAGE',self._currentPage, _form=self);
if blockChange:
- self.refreshDisplay(self._currentBlock)
+ self.refreshDisplay(self._currentBlock)
assert gDebug (5, "Updating entries old: %s, new: %s" % \
(oldEntry, self._currentEntry))
@@ -860,10 +863,10 @@
currentBlock.editable in ('Y', 'new')) or \
(reverse and currentBlock.isFirstRecord()) \
))):
- source = self._currentEntry._page.getFocusOrder()
+ source = self._currentEntry._page.get_focus_order()
stayInBlock = False
else:
- source = currentBlock.getFocusOrder()
+ source = currentBlock.get_focus_order()
stayInBlock = True
# If we want the previous entry, then reverse the focusorder we're using
@@ -876,7 +879,7 @@
for object in source:
- if object.isNavigable(mode):
+ if object.is_navigable(mode):
if stayInBlock and \
(currentBlock.name != object.block):
continue
Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py 2006-04-05 08:32:50 UTC (rev 8365)
+++ trunk/gnue-forms/src/GFInstance.py 2006-04-05 08:53:03 UTC (rev 8366)
@@ -426,8 +426,8 @@
tip = ''
if form._currentEntry:
- if form._currentEntry.getOption ('tip'):
- tip = form._currentEntry.getOption ('tip')
+ if form._currentEntry.get_option ('tip'):
+ tip = form._currentEntry.get_option ('tip')
self.updateStatusBar (tip = tip, form = form)
@@ -985,9 +985,9 @@
def executeAbout (self, event):
parameters = {
'name' : event._form.title or "Unknown",
- 'formversion' : event._form.getOption ('version') or "Unknown",
- 'author' : event._form.getOption ('author') or "Unknown",
- 'description' : event._form.getOption ('description') or "Unknown",
+ 'formversion' : event._form.get_option ('version') or "Unknown",
+ 'author' : event._form.get_option ('author') or "Unknown",
+ 'description' : event._form.get_option ('description') or "Unknown",
}
self._uiinstance.showAbout (**parameters)
@@ -1094,7 +1094,7 @@
return False
if event.data._type in ['GFEntry', 'GFImage', 'GFButton']:
- if not event.data.isNavigable (event._form.getCurrentMode ()):
+ if not event.data.is_navigable (event._form.getCurrentMode ()):
return False
newEntry = event.data
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -248,13 +248,13 @@
# Get an ordered list of focus-controls
# ---------------------------------------------------------------------------
- def getFocusOrder (self):
+ def get_focus_order (self):
ctrlList = []
for field in self._children:
ctrlList += getattr (field, '_entryList', [])
- return GFContainer.getFocusOrder (self, ctrlList)
+ return GFContainer.get_focus_order (self, ctrlList)
# ---------------------------------------------------------------------------
@@ -276,9 +276,9 @@
# Implementation of virtual methods
# ---------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_ (self):
- GFContainer._phase1Init_ (self)
+ GFContainer._phase_1_init_ (self)
self._logic = logic = self.findParentOfType ('GFLogic')
@@ -709,8 +709,8 @@
for entry in field._entryList:
# This loop is probably better somewhere else
- entry.recalculateVisible (adjustment, self._currentRecord,
- self._recordCount)
+ entry.recalculate_visible (adjustment, self._currentRecord,
+ self._recordCount)
self._form.updateUIEntry (field)
Modified: trunk/gnue-forms/src/GFObjects/GFBox.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBox.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFBox.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -30,13 +30,13 @@
# Box widget
# =============================================================================
-class GFBox (GFContainer):
+class GFBox(GFContainer):
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
- def __init__ (self, parent = None):
+ def __init__(self, parent=None):
- GFContainer.__init__ (self, parent, "GFBox")
- self.label = ""
+ GFContainer.__init__(self, parent, "GFBox")
+ self.label = ""
Modified: trunk/gnue-forms/src/GFObjects/GFButton.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFButton.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFButton.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -58,11 +58,11 @@
# Implementation of virtual methods
# -------------------------------------------------------------------------
- def _phase1Init_(self):
+ def _phase_1_init_(self):
- GFTabStop._phase1Init_(self)
+ GFTabStop._phase_1_init_(self)
- self._block = self.getBlock()
+ self._block = self.get_block()
if self._block:
self._rows = getattr(self._block, 'rows', self._rows)
self._gap = getattr(self._block, 'rowSpacer', self._gap)
Modified: trunk/gnue-forms/src/GFObjects/GFComponent.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFComponent.py 2006-04-05 08:32:50 UTC
(rev 8365)
+++ trunk/gnue-forms/src/GFObjects/GFComponent.py 2006-04-05 08:53:03 UTC
(rev 8366)
@@ -25,67 +25,66 @@
"""
from gnue.common import events
-from GFValue import GFValue
from gnue.forms.input import displayHandlers
+from gnue.forms.GFObjects.GFValue import GFValue
# =============================================================================
# A component wrapper class
# =============================================================================
-class GFComponent (GFValue):
+class GFComponent(GFValue):
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
- def __init__ (self, parent = None, value = None):
+ def __init__(self, parent=None, value=None):
- GFValue.__init__ (self, parent, value, 'GFComponent')
- self.subEventHandler = events.EventController ()
+ GFValue.__init__(self, parent, value, 'GFComponent')
+ self.subEventHandler = events.EventController()
- # Default attributes (these may be replaced by parser)
- self.type = "URL"
- self.Char__height = int (gConfigForms ('widgetHeight'))
+ # Default attributes (these may be replaced by parser)
+ self.type = "URL"
+ self.Char__height = int(gConfigForms('widgetHeight'))
- # ---------------------------------------------------------------------------
- # Get the current value
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Get the current value
+ # -------------------------------------------------------------------------
- def getValue (self, *args, **parms):
+ def getValue(self, *args, **parms):
- return self._field.getValue (*args, **parms)
+ return self._field.getValue(*args, **parms)
- # ---------------------------------------------------------------------------
- # Set the object's value (by passing the new value to the bound field)
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Set the object's value (by passing the new value to the bound field)
+ # -------------------------------------------------------------------------
- def setValue (self, value):
+ def setValue(self, value):
- self._field.setValue (value)
- if not self._value:
- GFValue.setValue (self, value)
+ self._field.setValue(value)
+ if not self._value:
+ GFValue.setValue(self, value)
- # ---------------------------------------------------------------------------
- # Implementation of virtual methods
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Implementation of virtual methods
+ # -------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_(self):
- GFValue._phase1Init_ (self)
+ GFValue._phase_1_init_(self)
- self._block = self.getBlock ()
- self._block._entryList.append (self)
+ self._block = self.get_block()
+ self._block._entryList.append(self)
- self._field = self.getField ()
- self._field._entryList.append (self)
+ self._field = self.get_field()
+ self._field._entryList.append(self)
- self._page = self.findParentOfType ('GFPage')
- self._page._entryList.append (self)
+ self._page = self.findParentOfType('GFPage')
+ self._page._entryList.append(self)
- self._displayHandler = displayHandlers.Component (self,
- self._form._instance.eventController,
- self.subEventHandler)
+ self._displayHandler = displayHandlers.Component (self,
+ self._form._instance.eventController, self.subEventHandler)
Modified: trunk/gnue-forms/src/GFObjects/GFContainer.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFContainer.py 2006-04-05 08:32:50 UTC
(rev 8365)
+++ trunk/gnue-forms/src/GFObjects/GFContainer.py 2006-04-05 08:53:03 UTC
(rev 8366)
@@ -24,79 +24,81 @@
A base class for all GFObjects that can be containers
"""
-from GFObj import GFObj
-from GFTabStop import GFTabStop
+from gnue.forms.GFObjects.GFObj import GFObj
+from gnue.forms.GFObjects.GFTabStop import GFTabStop
# =============================================================================
# Base class for container objects
# =============================================================================
class GFContainer (GFObj):
- """
- A base class for all GFObjects that can be containers
- """
+ """
+ A base class for all GFObjects that can be containers
+ """
- # ---------------------------------------------------------------------------
- # Determine the focus order of a given list of entries
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Determine the focus order of a given list of entries
+ # -------------------------------------------------------------------------
- def getFocusOrder (self, list = None):
- """
- Builds a list of objects ordered in the way in which they should receive
- focus.
+ def get_focus_order(self, list=None):
+ """
+ Builds a list of objects ordered in the way in which they should
receive
+ focus.
- @param list: An optional list of objects to scan for focus
- @return: A list of objects in the order that they should receive focus
- """
+ @param list: An optional list of objects to scan for focus
+ @return: A list of objects in the order that they should receive focus
+ """
- missingFocusOrder = [] # A list of tab stops in the form that do not have
- # a focus order
- hasFocusOrder = [] # A list of tab stops in the form that have a
- # focus order. stored in the format
- # [focusOrder, [tabstops]]
+ # A list of tab stops in the form that do not have a focus order.
+ missingFocusOrder = []
+
+ # A list of tab stops in the form that have a focus order. Stored in
+ # the format [focusOrder, [tabstops]]
+ hasFocusOrder = []
- # If no list passed then use the instances built in children list
- if list is None:
- list = self._children
+ # If no list passed then use the instances built in children list
+ if list is None:
+ list = self._children
- # Build the missing and has focus lists
- for child in list:
- if isinstance (child, GFContainer):
- tabStops = child.getFocusOrder ()
- elif isinstance (child, GFTabStop):
- tabStops = [child]
- else:
- tabStops = None # Things like labels
+ # Build the missing and has focus lists
+ for child in list:
+ if isinstance(child, GFContainer):
+ tabStops = child.get_focus_order()
+ elif isinstance(child, GFTabStop):
+ tabStops = [child]
+ else:
+ tabStops = None # Things like labels
- if bool (tabStops):
- try:
- index = child.focusorder - 1
- hasFocusOrder.append ([index, tabStops])
- except AttributeError:
- missingFocusOrder.append (tabStops)
+ if bool(tabStops):
+ try:
+ index = child.focusorder - 1
+ hasFocusOrder.append([index, tabStops])
+ except AttributeError:
+ missingFocusOrder.append(tabStops)
- # Sort the focus stops on items that had defined focus order
- hasFocusOrder.sort ()
+ # Sort the focus stops on items that had defined focus order
+ hasFocusOrder.sort()
- # Create a None filled list that will contain all the tab stops
- maxFocusIndex = hasFocusOrder and hasFocusOrder [-1][0] or 0
- totalLength = len (hasFocusOrder) + len (missingFocusOrder)
- workingList = [None] * max (maxFocusIndex + 1, totalLength)
+ # Create a None filled list that will contain all the tab stops
+ maxFocusIndex = hasFocusOrder and hasFocusOrder[-1][0] or 0
+ totalLength = len(hasFocusOrder) + len(missingFocusOrder)
+ workingList = [None] * max(maxFocusIndex + 1, totalLength)
- # Merge in the items with defined focus orders
- for index, tabStop in hasFocusOrder:
- workingList [index] = tabStop
+ # Merge in the items with defined focus orders
+ for index, tabStop in hasFocusOrder:
+ workingList[index] = tabStop
- # Merge in the items missing defined focus orders where ever there is a gap
- while bool(missingFocusOrder):
- tabStop = missingFocusOrder.pop(0)
- workingList[workingList.index(None)] = tabStop
+ # Merge in the items missing defined focus orders where ever there is a
+ # gap.
+ while bool(missingFocusOrder):
+ tabStop = missingFocusOrder.pop(0)
+ workingList[workingList.index(None)] = tabStop
- # Remove any None entries in the list. This would happen if the focusorder
- # settings skipped numbers
- returnValue = []
- for tabStop in workingList:
- if tabStop is not None:
- returnValue.extend (tabStop)
+ # Remove any None entries in the list. This would happen if the
+ # focusorder settings skipped numbers.
+ returnValue = []
+ for tabStop in workingList:
+ if tabStop is not None:
+ returnValue.extend(tabStop)
- return returnValue
+ return returnValue
Modified: trunk/gnue-forms/src/GFObjects/GFDataSource.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFDataSource.py 2006-04-05 08:32:50 UTC
(rev 8365)
+++ trunk/gnue-forms/src/GFObjects/GFDataSource.py 2006-04-05 08:53:03 UTC
(rev 8366)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - GF Object Hierarchy - Datasources
#
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
#
+# This file is part of GNU Enterprise
+#
# GNU Enterprise is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
@@ -16,32 +19,29 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2006 Free Software Foundation
-#
-#
-# FILE:
-# GFObjects.py
-#
-# DESCRIPTION:
+# $Id$
"""
Logical datasource support
"""
-# NOTES:
-#
-# HISTORY:
-#
-import weakref
-
from gnue.common.datasources.GDataSource import GDataSource
-from gnue.common import events
-############################################################
-# GFDataSource
-#
+# =============================================================================
+# Wrapper class for datasources used in GF object trees
+# =============================================================================
-class GFDataSource (GDataSource):
- def __init__(self, parent):
- GDataSource.__init__(self, parent, 'GFDataSource')
- self._toplevelParent = 'GFForm'
- self._form = self.findParentOfType('GFForm')
+class GFDataSource(GDataSource):
+ """
+ A GFDataSource wrapps a L{gnue.common.datasources.GDataSource} object
+ """
+
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__(self, parent):
+
+ GDataSource.__init__(self, parent, 'GFDataSource')
+
+ self._toplevelParent = 'GFForm'
+ self._form = self.findParentOfType('GFForm')
Modified: trunk/gnue-forms/src/GFObjects/GFEntry.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFEntry.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFEntry.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -76,18 +76,18 @@
# Phase I init
# ---------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_ (self):
"""
On Phase 1 initialization add the entry to the owning blocks' entry list as
well as to the pages' field list.
"""
- GFTabStop._phase1Init_ (self)
+ GFTabStop._phase_1_init_ (self)
- self._block = self.getBlock ()
+ self._block = self.get_block ()
self._block._entryList.append (self)
- self._field = self.getField ()
+ self._field = self.get_field ()
self._field._entryList.append (self)
# Have a look wether the entry will be navigable or not
@@ -114,7 +114,7 @@
# Implementation of virtual methods
# ---------------------------------------------------------------------------
- def _isNavigable_ (self, mode):
+ def _is_navigable_ (self, mode):
return self.navigable and self._block.navigable and not self.hidden
Modified: trunk/gnue-forms/src/GFObjects/GFField.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFField.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFField.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -158,9 +158,9 @@
return GFValue._buildObject(self)
- def _phase1Init_ (self):
+ def _phase_1_init_ (self):
- GFValue._phase1Init_ (self)
+ GFValue._phase_1_init_ (self)
self._block = block = self.findParentOfType('GFBlock')
block._fieldMap[self.name] = self
@@ -506,7 +506,7 @@
self.setValue (value)
def triggerGetReadonly(self):
- return self.isNavigable(self._block._form.getCurrentMode())
+ return self.is_navigable(self._block._form.getCurrentMode())
def triggerSetReadonly(self,value):
self.editable = value and 'Y' or 'N'
Modified: trunk/gnue-forms/src/GFObjects/GFImage.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFImage.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFImage.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -60,14 +60,14 @@
# Implementation of virtual methods
# ---------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_ (self):
- GFTabStop._phase1Init_ (self)
+ GFTabStop._phase_1_init_ (self)
- self._block = self.getBlock ()
+ self._block = self.get_block ()
self._block._entryList.append (self)
- self._field = self.getField ()
+ self._field = self.get_field ()
self._field._entryList.append (self)
self._displayHandler = displayHandlers.factory (self,
@@ -76,6 +76,6 @@
# ---------------------------------------------------------------------------
- def _isNavigable_ (self, mode):
+ def _is_navigable_ (self, mode):
return False
Modified: trunk/gnue-forms/src/GFObjects/GFLabel.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFLabel.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFLabel.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -49,14 +49,14 @@
# Implementation of virtual methods
# ---------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_ (self):
"""
On phase 1 initialization make sure to get the current value of the rows-
and rowSpacer-attribute. Since a GFLabel has no block it won't be set
otherwise.
"""
- GFObj._phase1Init_ (self)
+ GFObj._phase_1_init_ (self)
self._rows = getattr (self, 'rows', self._rows)
self._gap = getattr (self, 'rowSpacer', self._gap)
Modified: trunk/gnue-forms/src/GFObjects/GFLayout.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFLayout.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFLayout.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -77,9 +77,9 @@
# Implementation of virtual methods
# ---------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_ (self):
- GFObj._phase1Init_ (self)
+ GFObj._phase_1_init_ (self)
self._xmlchildnamespaces = self.__findNamespaces (self)
Modified: trunk/gnue-forms/src/GFObjects/GFObj.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFObj.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFObj.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -33,216 +33,225 @@
# Exceptions
# =============================================================================
-class BlockNotFoundError (GParser.MarkupError):
- def __init__ (self, item):
- itemType = item._type [2:]
+class BlockNotFoundError(GParser.MarkupError):
+ def __init__(self, item):
+ itemType = item._type[2:]
msg = u_("%(item)s '%(name)s' references non-existent block '%(block)s'") \
- % {'item': itemType, 'name': item.name, 'block': item.block}
- GParser.MarkupError.__init__ (self, msg, item._url, item._lineNumber)
+ % {'item': itemType, 'name': item.name, 'block': item.block}
+ GParser.MarkupError.__init__(self, msg, item._url, item._lineNumber)
# =============================================================================
-class FieldNotFoundError (GParser.MarkupError):
- def __init__ (self, item):
- itemType = item._type [2:]
+class FieldNotFoundError(GParser.MarkupError):
+ def __init__(self, item):
+ itemType = item._type[2:]
msg = u_("%(item)s '%(name)s' references non-existent field '%(field)s'") \
% {'item': itemType, 'name': item.name, 'field': item.field}
- GParser.MarkupError.__init__ (self, msg, item._url, item._lineNumber)
+ GParser.MarkupError.__init__(self, msg, item._url, item._lineNumber)
# =============================================================================
# Base class for GF* objects
# =============================================================================
-class GFObj (GObj, GTriggerExtension):
+class GFObj(GObj, GTriggerExtension):
+ """
+ A GFObj is the base class for all objects of a GF object tree. It
+ implements the GTriggerExtension interface, so all GF objects are capable
+ of associating and calling triggers.
+ """
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
- def __init__ (self, parent = None, type = 'GFObj'):
+ def __init__(self, parent=None, type='GFObj'):
- GTriggerExtension.__init__ (self)
- GObj.__init__ (self, parent, type)
+ GTriggerExtension.__init__(self)
+ GObj.__init__(self, parent, type)
- self.hidden = False
- self.readonly = False
- self.name = "%s%x" % (("%s" % self.__class__).split ('.') [-1], id (self))
+ self.hidden = False
+ self.readonly = False
+ self.name = "%s%x" % (("%s" % self.__class__).split('.')[-1], id(self))
- self._visibleIndex = 0
- self._rows = 1
- self._gap = 0
- self._inits = [self.phase1Init]
+ self._visibleIndex = 0
+ self._rows = 1
+ self._gap = 0
+ self._inits = [self.phase_1_init]
- # The reference to the uiWidget will be set by the
- # uidrivers._base.UIdriver._buildUI () function
- self.uiWidget = None
+ # The reference to the uiWidget will be set by the
+ # uidrivers._base.UIdriver._buildUI () function.
+ self.uiWidget = None
- # ---------------------------------------------------------------------------
- # String representation
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # String representation
+ # -------------------------------------------------------------------------
- def __repr__ (self):
+ def __repr__(self):
- return '<%s instance (%s) at %s>' % (self.__class__, self.name, id (self))
+ return '<%s instance (%s) at %s>' % \
+ (self.__class__, self.name, id(self))
- # ---------------------------------------------------------------------------
- # Check wether an object is navigable or not
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Check wether an object is navigable or not
+ # -------------------------------------------------------------------------
- def isNavigable (self, mode = 'edit'):
- """
- Return wether the object is currently navigable or not.
+ def is_navigable(self, mode = 'edit'):
+ """
+ Return wether the object is currently navigable or not.
- @param mode: current state of the object. Can be 'edit', 'query' or 'new'
- @returns: True or False
- """
+ @param mode: current state of the object. Can be 'edit', 'query' or
+ 'new'
+ @returns: True or False
+ """
- return self._isNavigable_ (mode)
+ return self._is_navigable_(mode)
- # ---------------------------------------------------------------------------
- # Phase 1 initialization
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Phase 1 initialization
+ # -------------------------------------------------------------------------
- def phase1Init (self):
- """
- Phase 1 initialization called after all objects of the XML tree were
- created.
- """
+ def phase_1_init(self):
+ """
+ Phase 1 initialization called after all objects of the XML tree were
+ created.
+ """
- self._phase1Init_ ()
+ self._phase_1_init_()
- # ---------------------------------------------------------------------------
- # Get an option of the object
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Get an option of the object
+ # -------------------------------------------------------------------------
- def getOption (self, name):
- """
- Return the value of a given option of the object or None if no such option
- is present.
+ def get_option(self, name):
+ """
+ Return the value of a given option of the object or None if no such
+ option is present.
- @param name: name of the option to be queried
- @returns: the value of the requested option or None
- """
+ @param name: name of the option to be queried
+ @returns: the value of the requested option or None
+ """
- option = None
+ option = None
- for child in self.findChildrenOfType ('GFOption', False, True):
- if child.name == name:
- option = child.value
- break
+ for child in self.findChildrenOfType('GFOption', False, True):
+ if child.name == name:
+ option = child.value
+ break
- return option
+ return option
- # ---------------------------------------------------------------------------
- # Recalculate the visible index of an object
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Recalculate the visible index of an object
+ # -------------------------------------------------------------------------
- def recalculateVisible (self, adjustment, currentRecord, recordCount):
- """
- Recalculate the visible index of an object. This determines that real UI
- widget of a 'row-based grid' which should be visible.
+ def recalculate_visible(self, adjustment, currentRecord, recordCount):
+ """
+ Recalculate the visible index of an object. This determines that real
UI
+ widget of a 'row-based grid' which should be visible.
- @param adjustment: value to change the visible index, e.g. 1 or -1
- @param currentRecord: the currently active record
- @param recordCount: the number of records available at all
+ @param adjustment: value to change the visible index, e.g. 1 or -1
+ @param currentRecord: the currently active record
+ @param recordCount: the number of records available at all
- As a result of this recalculation the property self._visibleIndex will be
- set to the new value.
- """
+ As a result of this recalculation the property self._visibleIndex will
+ be set to the new value.
+ """
- if not self.hidden:
- index = min (max (self._visibleIndex + adjustment, 0), int
(self._rows)-1)
+ if not self.hidden:
+ index = min(max(self._visibleIndex + adjustment, 0),
+ int(self._rows)-1)
- # Don't let the index pass the number of records
- lowestVisible = max (currentRecord - index, 0)
- if lowestVisible + index > recordCount:
- index = index -1
+ # Don't let the index pass the number of records
+ lowestVisible = max(currentRecord - index, 0)
+ if lowestVisible + index > recordCount:
+ index = index -1
- # If the current record has rolled around from the top to the bottom then
- # reset the counter
- if currentRecord == 0:
- index = 0
+ # If the current record has rolled around from the top to the
+ # bottom then reset the counter.
+ if currentRecord == 0:
+ index = 0
- self._visibleIndex = index
+ self._visibleIndex = index
- # ---------------------------------------------------------------------------
- # Get a block from the block map
- # ---------------------------------------------------------------------------
+ #
--------------------------------------------------------------------------
+ # Get a block from the block map
+ # -------------------------------------------------------------------------
- def getBlock (self):
- """
- Return the objects' block from the block mapping.
+ def get_block(self):
+ """
+ Return the objects' block from the block mapping.
- @returns: the block of the current object or None if the current object
- does not support blocks.
- @raises BlockNotFoundError: if the block specified by the object is not
- listed in the block mapping of the logic instance
- """
+ @returns: the block of the current object or None if the current object
+ does not support blocks.
+ @raises BlockNotFoundError: if the block specified by the object is not
+ listed in the block mapping of the logic instance
+ """
- if not hasattr (self, 'block'):
- return None
+ if not hasattr(self, 'block'):
+ return None
- if not self.block in self._form._logic._blockMap:
- raise BlockNotFoundError, self
+ if not self.block in self._form._logic._blockMap:
+ raise BlockNotFoundError, self
- return self._form._logic._blockMap [self.block]
+ return self._form._logic._blockMap[self.block]
- # ---------------------------------------------------------------------------
- # Get a field
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Get a field
+ # -------------------------------------------------------------------------
- def getField (self):
- """
- Returns the objects' field from the blocks' field mapping
+ def get_field(self):
+ """
+ Returns the objects' field from the blocks' field mapping
- @retruns: GFField instance or None if the object does not support fields
- @raises FieldNotFoundError: if the field is not available through the block
- """
+ @retruns: GFField instance or None if the object does not support
fields
+ @raises FieldNotFoundError: if the field is not available through the
+ block
+ """
- if not hasattr (self, 'field'):
- return None
+ if not hasattr(self, 'field'):
+ return None
- if not self.field in self._block._fieldMap:
- raise FieldNotFoundError, self
+ if not self.field in self._block._fieldMap:
+ raise FieldNotFoundError, self
- return self._block._fieldMap [self.field]
+ return self._block._fieldMap[self.field]
+ # -------------------------------------------------------------------------
+ # Virtual methods to be implemented by descendants
+ # -------------------------------------------------------------------------
- # ---------------------------------------------------------------------------
- # Virtual methods to be implemented by descendants
- # ---------------------------------------------------------------------------
+ def _is_navigable_(self, mode):
+ """
+ Return wether the object is currently navigable or not.
- def _isNavigable_ (self, mode):
- """
- Return wether the object is currently navigable or not.
+ @param mode: current state of the object. Can be 'edit', 'query' or
+ 'new'
- @param mode: current state of the object. Can be 'edit', 'query' or 'new'
+ Descendants can overwrite this method to return either True or False.
If
+ this method is not overwritten it returns False.
+ """
- Descendants can overwrite this method to return either True or False. If
- this method is not overwritten it returns False.
- """
+ return False
- return False
+ # -------------------------------------------------------------------------
+ # Phase 1 initialization
+ # -------------------------------------------------------------------------
- # ---------------------------------------------------------------------------
- # Phase 1 initialization
- # ---------------------------------------------------------------------------
+ def _phase_1_init_(self):
+ """
+ Phase 1 initialization called after all objects of the XML tree were
+ created. Descendants can overwrite this function to perform actions
+ after construction of the objects.
+ """
- def _phase1Init_ (self):
- """
- Phase 1 initialization called after all objects of the XML tree were
- created. Descendants can overwrite this function to perform actions after
- construction of the objects.
- """
-
- self._form = self.findParentOfType ('GFForm')
+ self._form = self.findParentOfType('GFForm')
Modified: trunk/gnue-forms/src/GFObjects/GFPage.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFPage.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFPage.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -54,13 +54,13 @@
# Implementation of virtual methods
# ---------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_ (self):
"""
On phase 1 initialization a logical page registers itself at the logic
object.
"""
- GFContainer._phase1Init_ (self)
+ GFContainer._phase_1_init_ (self)
layout = self.findParentOfType ('GFLayout')
layout._pageList.append (self)
Modified: trunk/gnue-forms/src/GFObjects/GFScrollBar.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFScrollBar.py 2006-04-05 08:32:50 UTC
(rev 8365)
+++ trunk/gnue-forms/src/GFObjects/GFScrollBar.py 2006-04-05 08:53:03 UTC
(rev 8366)
@@ -50,11 +50,11 @@
# Phase I init: find the parent GFForm and the bound GFBlock
# ---------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_(self):
- GFObj._phase1Init_ (self)
+ GFObj._phase_1_init_(self)
- self._block = self.getBlock ()
+ self._block = self.get_block()
self._block.registerScrollbar (self)
self._scrollrows = getattr (self, 'scrollrows', self._block._rows)
Modified: trunk/gnue-forms/src/GFObjects/GFTabStop.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-04-05 08:32:50 UTC (rev
8365)
+++ trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-04-05 08:53:03 UTC (rev
8366)
@@ -59,13 +59,13 @@
# Implementation of virtual methods
# ---------------------------------------------------------------------------
- def _phase1Init_ (self):
+ def _phase_1_init_ (self):
"""
On phase 1 initialization find the owning GFPage-instance.
This instance is then available through self._page.
"""
- GFObj._phase1Init_ (self)
+ GFObj._phase_1_init_ (self)
self._page = self.findParentOfType ('GFPage')
self._page._entryList.append (self)
@@ -73,7 +73,7 @@
# ---------------------------------------------------------------------------
- def _isNavigable_ (self, mode):
+ def _is_navigable_ (self, mode):
"""
In general an object is navigable if it is not hidden and it's navigable
xml-attribute is set. If mode is 'query' it additionally depends wether an
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8366 - in trunk/gnue-forms/src: . GFObjects,
johannes <=