commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7265 - in trunk: gnue-common gnue-common/src/apps gnue-common/sr


From: jamest
Subject: [gnue] r7265 - in trunk: gnue-common gnue-common/src/apps gnue-common/src/definitions gnue-common/src/events gnue-common/src/formatting/masks gnue-dbtools/src/sql/formatters gnue-designer/src gnue-designer/src/base gnue-designer/src/forms gnue-designer/src/forms/wizards gnue-forms/src gnue-forms/src/uidrivers/wx gnue-forms/src/uidrivers/wx/widgets/form
Date: Sat, 26 Mar 2005 15:37:43 -0600 (CST)

Author: jamest
Date: 2005-03-26 15:37:40 -0600 (Sat, 26 Mar 2005)
New Revision: 7265

Added:
   trunk/gnue-common/src/apps/GImportLogger.py
Modified:
   trunk/gnue-common/BUGS
   trunk/gnue-common/src/apps/GBaseApp.py
   trunk/gnue-common/src/apps/GDebug.py
   trunk/gnue-common/src/definitions/GObjects.py
   trunk/gnue-common/src/events/Event.py
   trunk/gnue-common/src/formatting/masks/InputMask.py
   trunk/gnue-dbtools/src/sql/formatters/text.py
   trunk/gnue-designer/src/Designer.py
   trunk/gnue-designer/src/base/Instance.py
   trunk/gnue-designer/src/base/MRUManager.py
   trunk/gnue-designer/src/base/ModuleSupport.py
   trunk/gnue-designer/src/forms/Instance.py
   trunk/gnue-designer/src/forms/wizards/CreateWebForm.py
   trunk/gnue-forms/src/GFClient.py
   trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py
Log:
added --debug-imports based on designers setup
fixed memory leak in designers MRU manager
added misc docstrings and comments


Modified: trunk/gnue-common/BUGS
===================================================================
--- trunk/gnue-common/BUGS      2005-03-26 19:19:57 UTC (rev 7264)
+++ trunk/gnue-common/BUGS      2005-03-26 21:37:40 UTC (rev 7265)
@@ -1,6 +1,9 @@
 datasources
 -----------
-
+* Using --debug-imports breaks the loading of datasource drivers.
+  This matches the behaviour of the code when it was in designer only
+  Need to find out if this was a known issue and if so then if any
+  work was done to rectify it
 * Some drivers are broken for time fields (time without date)
 * Different drivers return different Python datatypes for the same type of row
   (for example for date, time, and datetime fields)

Modified: trunk/gnue-common/src/apps/GBaseApp.py
===================================================================
--- trunk/gnue-common/src/apps/GBaseApp.py      2005-03-26 19:19:57 UTC (rev 
7264)
+++ trunk/gnue-common/src/apps/GBaseApp.py      2005-03-26 21:37:40 UTC (rev 
7265)
@@ -100,12 +100,18 @@
         help = _('Enables debugging messages.  Argument specifies the '
                  'level of messages to display (e.g., "--debug-level 5" '
                  'displays all debugging messages at level 5 or below.)')),
-
       CommandOption ('debug-file', category = "base", argument = _("filename"),
         help = _('Sends all debugging messages to a specified file '
                  '(e.g., "--debug-file trace.log" sends all output to '
                  '"trace.log")')),
-
+      
+      # This is actually handled during the initial GDebug import
+      # but is added here so that applications won't abort with 
+      # an unknown option 
+      CommandOption ('debug-imports', category = "dev",
+        help = _('All python imports are logged to stdout'
+                 )),
+
       CommandOption ('silent', category = "base",
         help = _('Displays no output at all.')),
 
@@ -257,19 +263,19 @@
       task()
 
     self._run = self.run
-
+
     # Are we silent?
     if self.OPTIONS['silent']:
-      # our file objects (/dev/null and nul) has no encoding, unlike stdout...
+      # our file objects (/dev/null and nul) has no encoding, unlike stdout...
       import __builtin__
       __builtin__.__dict__['u_'] = __builtin__.__dict__['_']
-      if os.name == 'posix':
+      if os.name == 'posix':
         sout = open('/dev/null','w')
-        serr = open('/dev/null','w')
+        serr = open('/dev/null','w')
       elif os.name == 'nt':
         sout = open('nul', 'w')
-        serr = open('nul', 'w')
-
+        serr = open('nul', 'w')
+
       try:
         sys.stdout.close()
         sys.stdout = sout

Modified: trunk/gnue-common/src/apps/GDebug.py
===================================================================
--- trunk/gnue-common/src/apps/GDebug.py        2005-03-26 19:19:57 UTC (rev 
7264)
+++ trunk/gnue-common/src/apps/GDebug.py        2005-03-26 21:37:40 UTC (rev 
7265)
@@ -30,6 +30,10 @@
 import time
 __starttime = time.time ()
 
+import sys, os
+if '--debug-imports' in sys.argv or os.environ.has_key('GNUE_DEBUG_IMPORT'):
+  from gnue.common.apps import GImportLogger
+
 import __builtin__
 import inspect
 import os
@@ -68,9 +72,9 @@
     self.filehandle = filehandle
 
   def write (self, str):
-    lines = string.split (str, "\n")
+    lines = string.split (str, "\n")
     while len(lines) and lines [-1] == "":             # remove empty lines at 
the end
-      del (lines [-1])
+      del (lines [-1])
     self.filehandle.write (string.join (["DB000: " + s for s in lines], "\n"))
     self.filehandle.write ("\n")
     self.filehandle.flush ()

Added: trunk/gnue-common/src/apps/GImportLogger.py
===================================================================
--- trunk/gnue-common/src/apps/GImportLogger.py 2005-03-26 19:19:57 UTC (rev 
7264)
+++ trunk/gnue-common/src/apps/GImportLogger.py 2005-03-26 21:37:40 UTC (rev 
7265)
@@ -0,0 +1,46 @@
+# GNU Enterprise Common Library - Application Services - Debugging support
+#
+# Copyright 2001-2005 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
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id: GDebug.py 7224 2005-03-18 17:13:13Z jcater $
+#
+"""
+Importing this module causes all modules imported after this
+to be printed to stdout 
+"""
+import os, ihooks, sys
+_import_indent = 0
+
+class MyHooks(ihooks.Hooks):
+  pass
+
+class GImportLogger(ihooks.ModuleLoader):
+
+  def load_module(self, name, stuff):  
+    global _import_indent 
+    print "." * _import_indent + "Importing %s..." % name
+    _import_indent += 1
+
+    module = ihooks.ModuleLoader.load_module(self, name, stuff)
+
+    _import_indent -= 1
+    return module
+
+ihooks.ModuleImporter(GImportLogger(MyHooks())).install()

Modified: trunk/gnue-common/src/definitions/GObjects.py
===================================================================
--- trunk/gnue-common/src/definitions/GObjects.py       2005-03-26 19:19:57 UTC 
(rev 7264)
+++ trunk/gnue-common/src/definitions/GObjects.py       2005-03-26 21:37:40 UTC 
(rev 7265)
@@ -53,9 +53,6 @@
   def __init__(self, *args, **parms):
     GTriggerCore.__init__(self)
     ParserObj.__init__(self, *args, **parms)
-    # This should be ok to remove as glimpse doesn't show it being used 
anywhere
-    # and it's messing up the common namespace property logic
-    #self.__properties__ = {}
     self._inits = []
 
   def buildObject(self, **params):
@@ -112,6 +109,10 @@
     initialize itself.  This type of logic cannot be places into an __init__
     as the children may not be loaded yet or may not yet have the needed
     information.
+    
+    @type interations: integer
+    @param interations: Limits the number of passes to the specified number.
+                        This doesn't appear to be used anywhere.
     """
     if iterations == 0:
       iterations = self.maxInits()
@@ -119,9 +120,15 @@
       self._phaseInit(phase)
 
   def _phaseInit(self,phase):
+    """
+    Used internally by phaseInit to walk through the
+    object tree initializing objects.
+    """
 
 ## TODO: Below is a call-less recursive version of
 ## TODO: phaseInit.  Needs to be profiled both ways.
+## TODO: Profile tests have shown this to be .001 
+## TODO: cpu seconds faster per call
 ##    stack = [self]
 ##    while stack:
 ##      object = stack.pop()
@@ -131,7 +138,10 @@
 ##        init = object._inits[phase]
 ##      except IndexError:
 ##        continue
-##      init()
+##      try:
+##        init()
+##      except TypeError:
+##        continue
 
     inits = self._inits
     if (len(inits) > phase) and inits[phase]:
@@ -146,36 +156,48 @@
       initter(phase)
 
 
-  # This function is called after the parsers have completely
-  # constructed. All children should be in place and
-  # attributes and content should be set at this point.
-  # Return the number of phaseInit iterations your object will
-  # need.
-  #
-  # NOTE: Do not initialize datasources, etc at this point.
-  #       This is only so content can be set, etc, after
-  #       loading from XML.
-  #
   def _buildObject(self):
+    """
+    # This function is called after the parsers have completely
+    # constructed. All children should be in place and
+    # attributes and content should be set at this point.
+    # Return the number of phaseInit iterations your object will
+    # need.
+    #
+    # NOTE: Do not initialize datasources, etc at this point.
+    #       This is only so content can be set, etc, after
+    #       loading from XML.
+    #
+    
+    """
     return len(self._inits)
 
-  #
-  # maxInits functions
-  #
-  # maxInits returns the maximum size of all the _inits
-  # list from this object or it's children
-  #
   def maxInits(self):
+    """
+    maxInits returns the maximum size of all the _inits
+    list from this object or it's children
+    """
     self._initCount = 0
     self.walk(self._maxInitsWalker)
     return self._initCount
 
   def _maxInitsWalker(self, object):
+    """
+    The function passed to the tree walker to extract the
+    length of the _inits list.  Used by maxInits.
+    """
     if hasattr(object,'_inits'):
       self._initCount = max(self._initCount,len(object._inits))
 
 
   def getChildrenAsContent(self):
+    """
+    Returns the content of any GContent objects that are children 
+    of this object.  
+    
+    @rtype: string or binary(?)
+    @return: The contents of the children 
+    """
     content = ""
     for child in self._children:
       if isinstance(child, GContent):
@@ -203,9 +225,14 @@
   #
   # addChild
   #
-  # Adds an object to an instances list of children
   #
   def addChild(self, child):
+    """
+    Adds an object to an instances list of children
+    
+    @type child: GObj derived class
+    @param child: The object to add.
+    """
     self._children.append(child)
 
   def getXmlTag(self, stripPrefixes=None):
@@ -366,6 +393,10 @@
 
 
   def walk(self, function, *args, **parms):
+    """
+    Function that recursivly walks down through a tree of GObj 
+    instances and applies a function to them.
+    """
     function(self, *args, **parms)
     for child in self._children:
       if isinstance(child, GObj):
@@ -393,14 +424,13 @@
 
       parentObject = parentObject._parent
 
-  #
-  # findChildOfType
-  #
-  # Moves downward though the children of an object till
-  # it finds the child of the specified type
-  #
   def findChildOfType(self, type, includeSelf=1, allowAllChildren=0):
-
+    """
+    Moves downward though the children of an object till
+    it finds the child of the specified type
+  
+    """
+  
     if includeSelf and self._type == type:
       return self
 
@@ -417,13 +447,10 @@
     return None
 
 
-  #
-  # findChildrenOfType
-  #
-  # find all children of a specific type
-  #
   def findChildrenOfType(self, type, includeSelf=1, allowAllChildren=0):
-
+    """
+    find all children of a specific type
+    """
     rs = []
 
     if includeSelf and self._type == type:
@@ -443,13 +470,11 @@
     return rs
 
 
-  #
-  # getDescription
-  #
-  # Return a useful description of this object
-  # Used by designer clients
-  #
   def getDescription(self):
+    """
+    Return a useful description of the object.
+    Currently used by GNUe Designer.
+    """
     if hasattr(self,'_description'):
       return self._description
     elif hasattr(self,'name'):
@@ -457,7 +482,9 @@
     else:
       return self._type[2:] + " (%s)" % self._type[2:]
 
-  # Hooks
+  # ===========================================================================
+  # Hooks - I haven't a clue yet
+  # ===========================================================================
   def __getitem__(self, key):
     return self.__dict__[key.replace(':','__')]
 

Modified: trunk/gnue-common/src/events/Event.py
===================================================================
--- trunk/gnue-common/src/events/Event.py       2005-03-26 19:19:57 UTC (rev 
7264)
+++ trunk/gnue-common/src/events/Event.py       2005-03-26 21:37:40 UTC (rev 
7265)
@@ -68,7 +68,7 @@
     """
     self.__dict__.update(parms)
 
-    # TODO: Get rid of data=
+    # TODO: Get rid of data=    
     self.data  = data
 
     self.__event__ = event

Modified: trunk/gnue-common/src/formatting/masks/InputMask.py
===================================================================
--- trunk/gnue-common/src/formatting/masks/InputMask.py 2005-03-26 19:19:57 UTC 
(rev 7264)
+++ trunk/gnue-common/src/formatting/masks/InputMask.py 2005-03-26 21:37:40 UTC 
(rev 7265)
@@ -232,11 +232,12 @@
       try:
         while True:
           parsed, extra = scanner.read()
+          print parsed, extra
           if parsed is None:
             last_state = self.eof_nextstate[0]
             break
           else:
-#            print parsed
+            print "Parsed", parsed
             state, char = parsed
             mstate = state[0]
             inputted_states[mstate].append(state)

Modified: trunk/gnue-dbtools/src/sql/formatters/text.py
===================================================================
--- trunk/gnue-dbtools/src/sql/formatters/text.py       2005-03-26 19:19:57 UTC 
(rev 7264)
+++ trunk/gnue-dbtools/src/sql/formatters/text.py       2005-03-26 21:37:40 UTC 
(rev 7265)
@@ -38,7 +38,7 @@
   def writeHeading(self, text):
     if self.width:
       leading = max(0, int((self.width - len(text))/2)
-    self.stream.write(' ' * leading + text + '\n')
+    self.stream.write((' ' * leading) + text + '\n')
 
   def writeText(self, text):
     self.stream.write(str(text) + '\n')

Modified: trunk/gnue-designer/src/Designer.py
===================================================================
--- trunk/gnue-designer/src/Designer.py 2005-03-26 19:19:57 UTC (rev 7264)
+++ trunk/gnue-designer/src/Designer.py 2005-03-26 21:37:40 UTC (rev 7265)
@@ -28,39 +28,6 @@
 import sys, os, string
 from gnue.common.apps import RuntimeSettings
 
-######################
-#
-# This is a debugging thing
-#
-import os, ihooks
-
-class MyHooks(ihooks.Hooks):
-  pass
-
-_import_indent = 0
-
-import __builtin__
-__builtin__.__dict__['gStartupStatus'] = lambda string:string
-
-class MyModuleLoader(ihooks.ModuleLoader):
-
-  def load_module(self, name, stuff):
-
-    global _import_indent
-    print "." * _import_indent + "Importing %s..." % name
-    _import_indent += 1
-
-    module = ihooks.ModuleLoader.load_module(self, name, stuff)
-
-    _import_indent -= 1
-    return module
-
-
-if os.environ.has_key('GNUE_DEBUG_IMPORT'):
-  ihooks.ModuleImporter(MyModuleLoader(MyHooks())).install()
-
-######################
-
 from StringIO import StringIO
 from wxPython.wx import *
 from gnue.common.apps.GClientApp import GClientApp
@@ -89,35 +56,51 @@
   USAGE = GClientApp.USAGE + " [file] [file] ..."
   USE_DATABASE_OPTIONS = 1
 
-  def __init__(self):
+  def __init__(self):    
     GClientApp.__init__(self, application="forms",defaults=ConfigOptions)
-    self.mru = MRUManager.MRUManager(self)
+
     self._instances = []
 
+    # Load the configuration information
     
self.configurationManager.loadApplicationConfig(section="designer",defaults=DesignerConfigOptions)
     self.configurationManager.registerAlias('gConfigNav', 'navigator')
     self.configurationManager.registerAlias('gConfigForms', 'forms')
     self.configurationManager.registerAlias('gConfigReports', 'reports')
     
+    # Setup the Most Recently Used URL manager    
+    self.mru = MRUManager.MRUManager(self)
+    
     # Set Form's wxApp, so it doesn't try to create another. 
     setWxApp(self)
-    
-    # This has to happen after setWxApp, 
-    # otherwise bad things happen. (and  
-    # we don't like bad things, do we?)   
+        
+    # Reuse the login handler from Form's wx driver   
+    # This has to happen after setWxApp, otherwise bad things happen
     from gnue.forms.uidrivers.wx import UILoginHandler
     self.getConnectionManager().setLoginHandler(UILoginHandler())
     
-    # Load individual module information
+    # get list of available modules
     self.loadModuleInformation()
 
-    wxApp.__init__(self,0)
+    wxApp.__init__(self,0) # 0 prevents IO redirect 
 
-
+  # ==========================================================================
+  # Startup functions
+  # ========================================================================== 
 
   def run(self):
+    """
+    Startup logic for Designer.  Currently just a wrapper for wxPython's 
wxApp.MainLoop()
+    """
     self.MainLoop()
-
+    
   def OnInit(self):
+    """
+    Standard wxApp OnInit function.  
+    Designer uses it to display the startup screen and 
+    load the initial editor instance      
+    
+    @rtype: boolean
+    @return: Always true
+    """
     wxInitAllImageHandlers()
 
     # Init the splashscreen
@@ -125,9 +108,11 @@
     self.startup = Startup()
     gStartupStatus(_('Initializing Client Library'))
 
+    # Load the specified file, a requested new instance, or the default empty 
instance 
     if len(self.ARGUMENTS):
       for arg in self.ARGUMENTS:
         self.SetTopWindow(self.load(arg))
+                
     elif self.OPTIONS['new']:
       try:
         self.SetTopWindow(self.newInstance(self.OPTIONS['new']))
@@ -136,18 +121,120 @@
         self.handleStartupError('"%s" is not a valid option for --new' % 
self.OPTIONS['new'])
 
     else:
-
       # TODO: What to do when no object is specified on command line?
       # TODO: jcater thinks of some task selector like kword uses,
       # TODO: or, restore the session to the way it was (same files, etc)
 
       self.SetTopWindow(self.newInstance('forms'))
 
+    # Close startup screen
     self.startup.pauseAndClose()
-    return 1
+    return true
 
+  def loadModuleInformation(self):
+    """
+    Loads all the available editor modules into memory and 
+    extracts from them a list of file types/extensions
+    that they support
+    """
+    gStartupStatus(_('Loading available tool modules'))
 
+    self.supportedModuleObjects = []  # A list of supported modules along with 
their "nickname"
+    self.supportedOpenWildcard = ""   #
+    self.moduleExtensionMapping = {}  # A dictionary of {file extension: 
designer module}
+
+    wildcard = ""
+    alltypes = []
+
+    # TODO: wxWidgets currently doesn't consistently support multiple file
+    # TODO: extension wildcards (e.g., "All GNUe Form Files (*.gfd,*.gfl)").
+    # TODO: However, the code is left commented out in case some day it does.
+
+    
+    for module in SupportedModules:
+      self.supportedModuleObjects.append((module.properties.nickname, module))
+
+
+    ##  if len(module.properties.fileExtensions.keys()) > 1:
+    ##
+    ##    wildcard += "%s Files (*.%s)|*.%s|" % \
+    ##             ( module.properties.application,
+    ##               
string.join(module.properties.fileExtensions.keys(),',*.'),
+    ##               
string.join(module.properties.fileExtensions.keys(),';*.') )
+
+
+      # Make the "default" file extension for a module
+      # appear before the other extensions.
+      wildcard += "%s (*.%s)|*.%s|" % \
+       ( 
module.properties.fileExtensions[module.properties.defaultFileExtension],
+         module.properties.defaultFileExtension,
+         module.properties.defaultFileExtension)
+
+      for type in module.properties.fileExtensions.keys():
+        if type != module.properties.defaultFileExtension:
+          wildcard += "%s (*.%s)|*.%s|" % \
+             ( module.properties.fileExtensions[type], type, type)
+        alltypes.append(type)
+
+        # Keep a dict of Extension::Handler mappings
+        self.moduleExtensionMapping[type] = module.properties.module
+
+
+    ##  self.supportedOpenWildcard = "All Supported Files (*.%s)|*.%s|" % \
+    ##              ( string.join(alltypes,',*.'),
+    ##              string.join(alltypes,';*.') ) \
+    ##            + wildcard \
+    ##            + "All Files (*.*)|*.*"
+      self.supportedOpenWildcard = wildcard \
+                                 + "All Files (*.*)|*.*"
+  # ==========================================================================
+  # Instance functions
+  # ========================================================================== 
 
+  def load(self, file):
+    """
+    Loads the requested file into a new instance of the appropriate 
+    designer module if the extension is recognized.
+    
+    @type file: string
+    @param file: The url of the file to open.
+    @rtype: designer editor instance
+    @return: An instance of the appropriate editor module or None if 
+             an error is encountered
+    """
+    gStartupStatus(_('Loading document'))
+
+    extension = string.lower(os.path.splitext(file)[1][1:])
+
+    if not self.moduleExtensionMapping.has_key(extension):
+
+      # TODO: This should try to figure out what kind of file this is.
+      # TODO: We maintain a list of opening xml elements in the
+      # TODO: (gnue.designer.SupportedModules).properties object.
+      # TODO: [gnue.designer.SupportedModules is a list]
+
+      # TODO: Shouldn't this display graphically? 
+      print "I do not know what to do with a .%s file!" % extension
+      return None
+
+    return self.newInstance(self.moduleExtensionMapping[extension], file)
+
+  
+  def newInstance(self, module, *args, **parms):
+    """
+    Creates an instance of the appropriate designer editor module
+    """
+    c = dyn_import("gnue.designer.%s.Instance" % module).Instance
+    return c(self, *args, **parms)
+
   def addInstance(self, instance):
+    """
+    Adds a newly created instance to the list of open instances
+    Sets several event handlers in the instance to point back to 
+    this class so it can proxy the events for the instance.
+    
+    @type instance: Designer Editor Module
+    @param instance: An instance of a designer module
+    """
     self._instances.append(instance)
     instance.registerEventListeners({
                        # Proxy for the main app
@@ -160,56 +247,38 @@
                        'RequestExit'         : self.OnExit
                     })
 
-
-
-
   def removeInstance(self, instance):
+    """
+    Removes an instance from the list of open instances
+    
+    @type instance: Designer Editor Module
+    @param instance: An instance of a designer module
+    """    
     self._instances.remove(instance)
-    #for i in range(0, len(self._instances)):
-    #  if self._instances[i] == instance:
-    #    self._instances.pop(i)
-    #    break
 
-  # Do we have unsaved files?
-  def isDirty(self):
-    isdirty = 0
-    for instance in self._instances:
-      if instance.isDirty():
-        isdirty = 1
-        break
-    return isdirty
-
-
+    
+  # ==========================================================================
+  # Proxy event functions
+  # ========================================================================== 
 
   def OnWizard(self, event):
-
+    """
+    Handles the request to display the wizard selection dialog
+        
+    type event: GNUe Event
+    param event: The event request
+    """
     wizard = TemplateChooser.TemplateChooser(self).run()
     if wizard != None:
       self.RunWizard(wizard)
 
-
-  def RunWizard(self, templateInformation):
-
-    product = templateInformation['Product']
-    templateSupport = dyn_import('gnue.designer.%s.TemplateSupport' % product)
-
-    try:
-      style = templateInformation['ProductStyle']
-    except:
-      style = None
-
-    instance = self.newInstance(product, style=style)
-
-    if not TemplateParser.TemplateParser(instance, instance.rootObject,
-          instance, templateInformation).run():
-      instance.Close()
-
-
-  def isFileOpened(self, location):
-    # TODO: Check to see if a file is already opened
-    return 0
-
   def OnOpen(self, event):
-
+    """
+    Handles the request to open a file
+    
+    type event: GNUe Event
+    param event: The event request
+    """
+    print dir(event)
     dlg = wxFileDialog(NULL, _("Open GNUe File..."), defaultDir=os.getcwd(),
                            wildcard = self.supportedOpenWildcard,
                            style=wxOPEN)
@@ -225,24 +294,24 @@
 
 
   def OnOpenRecent(self, event):
-
+    """
+    Handles the request to open a recent opened URL
+    
+    type event: GNUe Event
+    param event: The event request
+    """
     location = self.mru.mruMenuMap[event.GetId()]
     if not self.isFileOpened(location):
       self.load(location )
 
 
   def OnExit(self, event=None):
-
-##     if self.isDirty():
-##       dlg = wxMessageDialog(NULL,
-##               _("There are open documents with unsaved changes.\n")+
-##               _("Exit anyway?"),
-##               _("Unsaved Changes"), style=wxYES_NO|wxICON_WARNING)
-##       save = dlg.ShowModal()
-##       dlg.Destroy()
-##       if save == wxID_NO:
-##        return
-
+    """
+    Handles the request for application exit
+    
+    type event: GNUe Event
+    param event: The event request
+    """
     for instance in self._instances[:]:
       instance.Close()
       #
@@ -253,11 +322,24 @@
       #instance.Destroy()
 
   def OnSaveAll(self, event):
+    """
+    Handles the request for all instances to save their files
+    
+    type event: GNUe Event
+    param event: The event request
+    """
     for instance in self._instances:
       if instance.isDirty():
         instance.OnSave(event)
 
   def OnAbout(self, event):
+    """
+    Handles the request for an about box
+    
+    type event: GNUe Event
+    param event: The event request
+    """
+    
     imports = []
     for f in ('common','forms','reports','appserver','navigator'):
       try:
@@ -283,98 +365,67 @@
     dlg.ShowModal()
     dlg.Destroy()
 
+  def OnNew(self, event):
+    """
+    Handles the request when for a new instance of a designer editor module
+    
+    type event: GNUe Event
+    param event: The event request
+    """
+    self.newInstance(event.type)
 
+  
+  # ==========================================================================
+  # Support functions
+  # ==========================================================================
+      
+  def isDirty(self):
+    """
+    Determines if all instances currently have unsaved edits.
+    
+    @rtype: boolean
+    @return: True if any instance contains unsaved information
+             False if all instances are saved   
+    """
+    isdirty = false
+    for instance in self._instances:
+      if instance.isDirty():
+        isdirty = true
+        break
+    return isdirty
+  
+  def isFileOpened(self, location):
+    """
+    Determines if an instance already has the requested file open.
 
-  def loadModuleInformation(self):
+    TODO: Currently this function is not implemented.  It always 
+          returns false.
+          
+    @rtype: boolean
+    @return: True if any instance contains the requested file
+             False if the file is not currently loaded
+    """
 
-    gStartupStatus(_('Loading available tool modules'))
+    return false
 
-    self.supportedModuleObjects = []
-    self.supportedOpenWildcard = ""
-    self.moduleExtensionMapping = {}
+  def RunWizard(self, templateInformation):
+    """
+    
+    """
+    product = templateInformation['Product']
+    templateSupport = dyn_import('gnue.designer.%s.TemplateSupport' % product)
 
+    try:
+      style = templateInformation['ProductStyle']
+    except:
+      style = None
 
-    wildcard = ""
-    alltypes = []
+    instance = self.newInstance(product, style=style)
 
+    if not TemplateParser.TemplateParser(instance, instance.rootObject,
+          instance, templateInformation).run():
+      instance.Close()
 
-    # TODO: wxWidgets currently doesn't consistently support multiple file
-    # TODO: extension wildcards (e.g., "All GNUe Form Files (*.gfd,*.gfl)").
-    # TODO: However, the code is left commented out in case some day it does.
-
-    for module in SupportedModules:
-      self.supportedModuleObjects.append((module.properties.nickname, module))
-
-
-    ##  if len(module.properties.fileExtensions.keys()) > 1:
-    ##
-    ##    wildcard += "%s Files (*.%s)|*.%s|" % \
-    ##             ( module.properties.application,
-    ##               
string.join(module.properties.fileExtensions.keys(),',*.'),
-    ##               
string.join(module.properties.fileExtensions.keys(),';*.') )
-
-
-      # Make the "default" file extension for a module
-      # appear before the other extensions.
-      wildcard += "%s (*.%s)|*.%s|" % \
-       ( 
module.properties.fileExtensions[module.properties.defaultFileExtension],
-         module.properties.defaultFileExtension,
-         module.properties.defaultFileExtension)
-
-      for type in module.properties.fileExtensions.keys():
-        if type != module.properties.defaultFileExtension:
-          wildcard += "%s (*.%s)|*.%s|" % \
-             ( module.properties.fileExtensions[type], type, type)
-        alltypes.append(type)
-
-        # Keep a dict of Extension::Handler mappings
-        self.moduleExtensionMapping[type] = module.properties.module
-
-
-
-    ##  self.supportedOpenWildcard = "All Supported Files (*.%s)|*.%s|" % \
-    ##              ( string.join(alltypes,',*.'),
-    ##              string.join(alltypes,';*.') ) \
-    ##            + wildcard \
-    ##            + "All Files (*.*)|*.*"
-      self.supportedOpenWildcard = wildcard \
-                                 + "All Files (*.*)|*.*"
-
-
-  #
-  # Load a new object from file
-  #
-  def load(self, file):
-
-    gStartupStatus(_('Loading document'))
-
-    extension = string.lower(os.path.splitext(file)[1][1:])
-
-    if not self.moduleExtensionMapping.has_key(extension):
-
-      # TODO: This should try to figure out what kind of file this is.
-      # TODO: We maintain a list of opening xml elements in the
-      # TODO: (gnue.designer.SupportedModules).properties object.
-      # TODO: [gnue.designer.SupportedModules is a list]
-
-      print "I do not know what to do with a .%s file!" % extension
-      return None
-
-    return self.newInstance(self.moduleExtensionMapping[extension], file)
-
-
-  def OnNew(self, event):
-    self.newInstance(event.type)
-
-
-  #
-  # Create a new instance
-  #
-  def newInstance(self, module, *args, **parms):
-    c = dyn_import("gnue.designer.%s.Instance" % module).Instance
-    return c(self, *args, **parms)
-
-
 #
 # Workaround for Python 2.2's big unicode bug!!!
 # TODO: I don't think this is working!
@@ -383,10 +434,6 @@
 if sys.version[:5] == "2.2.0":
   from cStringIO import StringIO
 
-
-#
-#
-#
 if __name__ == '__main__':
   Designer().run()
 

Modified: trunk/gnue-designer/src/base/Instance.py
===================================================================
--- trunk/gnue-designer/src/base/Instance.py    2005-03-26 19:19:57 UTC (rev 
7264)
+++ trunk/gnue-designer/src/base/Instance.py    2005-03-26 21:37:40 UTC (rev 
7265)
@@ -311,7 +311,7 @@
 
     # Add supported tools to File|New
     for tool in SupportedModules:
-       self.menubar.addAction('File|New', '&%s' % 
tool.properties.nickname,'RequestNew', 100,
+      self.menubar.addAction('File|New', '&%s' % 
tool.properties.nickname,'RequestNew', 100,
         help=_('Create a new %s') % string.lower(tool.properties.nickname), 
eventdata={'type': tool.properties.module })
 
     # Add connections
@@ -449,7 +449,7 @@
         if object.name:
           object._description = object.name + "(out:)"
         else:
-         object._description = object._xmltag + "(out:)"
+          object._description = object._xmltag + "(out:)"
 
       # Assign an ID if none exists
       # TODO: in the future, I want to change these to id=".." instead of 
name=".."

Modified: trunk/gnue-designer/src/base/MRUManager.py
===================================================================
--- trunk/gnue-designer/src/base/MRUManager.py  2005-03-26 19:19:57 UTC (rev 
7264)
+++ trunk/gnue-designer/src/base/MRUManager.py  2005-03-26 21:37:40 UTC (rev 
7265)
@@ -31,7 +31,13 @@
 from gnue.common.apps import RuntimeSettings
 from wxPython import wx
 
-class MRUManager: 
+class MRUManager:
+  """
+  Most Recently Used (MRU) Manager 
+
+  Responsible for maintaining the menu that displays the most
+  recently used items.
+  """
   def __init__(self, app): 
     self._menus = []
     self._locations = []
@@ -57,30 +63,36 @@
 
 
   def addLocation(self, location): 
+    """
+    Adds a URL to the MRU list.
+    @type location: string
+    @param location: URL to be added
+    """
+
+    # Remove entry from old position
     absloc = os.path.normcase(os.path.abspath(location))
     try:
       self._locations.remove(absloc)
     except ValueError:
       pass
-    ## for i in range(len(self._locations)): 
-##       if self._locations[i] == absloc: 
-##         self._locations.pop(i)
-##         break
 
+    # Add to top of list
     self._locations.insert(0, absloc)
 
+    # Truncate list if necessary
     if len(self._locations) >= self._maxMRUs: 
       self._locations = self._locations[:self._maxMRUs]
- 
+
     self._refreshMenuList()
 
 
   def _refreshMenuList(self):
-    # This figures out the common prefix of all the forms and reduces 
appropriately.
-    # i.e., if you have /usr/home/me/form1.gfd, /usr/home/you/form2.gfd then
-    # this will reduce to me/form1.gfd and you/form2.gfd.. This is to keep the
-    # MRU menu list from being too wide!
-
+    """
+    This figures out the common prefix of all the forms and reduces 
appropriately.
+    i.e., if you have /usr/home/me/form1.gfd, /usr/home/you/form2.gfd then
+    this will reduce to me/form1.gfd and you/form2.gfd.. This is to keep the
+    MRU menu list from being too wide!
+    """     
     commonpos=len(os.path.commonprefix(
        map(lambda x: os.path.join(os.path.split(x)[0],''),self._locations)))
 
@@ -91,26 +103,52 @@
 
     self.refreshMenus()
 
+  def addMenu(self, menu, instance):
+    """
+    Adds a link to a wxMenu that needs maintained.
 
-  def addMenu(self, menu, instance):
+    @type menu: wxMenu instance
+    @param menu: A menu that needs maintained
+    @type instance: BaseInstance or child
+    @param instance: A designer instance to which this menu belongs.  Designer 
creates
+                                 an instance for every file it currently has 
open.
+    """
     self._menus.append(menu)
     menu.__instance = instance
     self.refreshMenu(menu)
 
   def removeMenu(self, menu, instance):
+    """
+    Removes a wxMenu from the list of wxMenus that 
+    contain recently opened files.
+
+    @type menu: wxMenu instance
+    @param menu: Menu that needs removed
+    @type instance: BaseInstance
+    @param instance: A designer instance to which this menu belongs.  Designer 
creates
+                                 an instance for every file it currently has 
open.  NOT USED?
+    
+    """
     self._menus.remove(menu)
 
-
   def refreshMenus(self):
+    """
+    Iterates through all the wxMenus under management and refreshes 
+    their list.
+    """
     map(self.refreshMenu, self._menus)
 
-
   def refreshMenu(self, menu):
-
-    # Rid ourselves of old entries
+    """
+    Resets and updates the wxMenu that displays the MRU list.
+    """
+    # Purge all entries from the existing wxMenu and 
+    # reset the menu mapping
+    self.mruMenuMap = {}
     for i in menu.GetMenuItems():
       menu.Delete(i.GetId())
 
+    # Rebuild the menu with the current items.
     i = 0
     for location in self.menulist:
       tid = wx.wxNewId()
@@ -121,17 +159,17 @@
       self.mruMenuMap[tid] = self._locations[i]
       i += 1
 
-
-  #
-  #  Used by RuntimeSettings
-  #
   def saveRuntimeSettings(self):
+    """
+    Returns a dictionary used by Designer's instance of RuntimeSettings
+    to save the recently used urls
+    
+    @rtype: dict of {position:URL}
+    @return: The recently used files.
+    """
     results = {}
 
     for i in range(len(self._locations)):
       results["%s" % i] = self._locations[i]
 
     return ( self.runtime_section, results )
-
-
-

Modified: trunk/gnue-designer/src/base/ModuleSupport.py
===================================================================
--- trunk/gnue-designer/src/base/ModuleSupport.py       2005-03-26 19:19:57 UTC 
(rev 7264)
+++ trunk/gnue-designer/src/base/ModuleSupport.py       2005-03-26 21:37:40 UTC 
(rev 7265)
@@ -22,11 +22,13 @@
 # ModuleSupport.py
 #
 # DESCRIPTION:
-#
+# 
 # NOTES:
 #
-
-
+"""
+Loads all modules available to designer.  
+Modules are only loaded once 
+"""
 from gnue.common.apps import GDebug as _GDebug
 from gnue.common.utils.FileUtils import dyn_import
 
@@ -34,8 +36,8 @@
 UnsupportedModules = []
 Modules = (  'forms',
            'reports',
+           'schema',
 ##           'navigator',
-           'schema'
 )
 
 for module in Modules:
@@ -46,4 +48,3 @@
     UnsupportedModules.append(module)
     _GDebug.printMesg(1,'Cannot load Designer support for %s' % module)
     _GDebug.printMesg(2,'  Error: %s' % mesg)
-

Modified: trunk/gnue-designer/src/forms/Instance.py
===================================================================
--- trunk/gnue-designer/src/forms/Instance.py   2005-03-26 19:19:57 UTC (rev 
7264)
+++ trunk/gnue-designer/src/forms/Instance.py   2005-03-26 21:37:40 UTC (rev 
7265)
@@ -20,11 +20,6 @@
 #
 # $Id$
 
-"""
-Creates a "Form" instance.
-"""
-
-
 __all__ = ['Instance']
 
 from wxPython.wx import *
@@ -62,13 +57,16 @@
 from gnue.common.datasources import GDataSource
 
 class Instance(BaseInstance, GFInstance.GFInstance):
-
+  """
+  Designer's form editor instance.  
+  """
   def __init__(self, app, *args, **params):
 
-    self.incubator = Incubator(self)
-    self.properties = formProperties
-    self.wizardRunner = WizardRunner
-    self.debugLevel = '1'
+    self.incubator = Incubator(self) # Incubator
+    self.properties = formProperties # List of the modules properties
+    self.wizardRunner = WizardRunner # 
+    self.debugLevel = '1'            # The debug level used when running a form
+                                     # inside designer
 
     # TODO: Can we make it so the GFInstance is not
     # TODO: part of the main Instance class, but an

Modified: trunk/gnue-designer/src/forms/wizards/CreateWebForm.py
===================================================================
--- trunk/gnue-designer/src/forms/wizards/CreateWebForm.py      2005-03-26 
19:19:57 UTC (rev 7264)
+++ trunk/gnue-designer/src/forms/wizards/CreateWebForm.py      2005-03-26 
21:37:40 UTC (rev 7265)
@@ -496,7 +496,7 @@
                 'height: %spx;\n  ' % 
int(obj.Char__height*self.Yraster-self.baseline)
 
       if visible==0:
-       pos_code+='visibility:hidden;'
+        pos_code+='visibility:hidden;'
 
       if obj._type=='GFLabel':
         pos_code+='font-size: %spx;' % int(self.fontsize) +\
@@ -520,7 +520,7 @@
           outp+='  <input type="password"'
         elif obj.style=="dropdown":
           outp+='  <select'
-         print "ATTENTION: creating dropdown widgets which are not supported 
by the javascript client yet!"
+          print "ATTENTION: creating dropdown widgets which are not supported 
by the javascript client yet!"
         elif obj.Char__height>1:
           outp+='  <textarea'
         else:

Modified: trunk/gnue-forms/src/GFClient.py
===================================================================
--- trunk/gnue-forms/src/GFClient.py    2005-03-26 19:19:57 UTC (rev 7264)
+++ trunk/gnue-forms/src/GFClient.py    2005-03-26 21:37:40 UTC (rev 7265)
@@ -44,8 +44,8 @@
 
 except:
   REPORTS_SUPPORT = False
-  
-  
+
+
 # =============================================================================
 # GNU Enterprise Forms Client
 # =============================================================================

Modified: trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/UIdriver.py       2005-03-26 19:19:57 UTC 
(rev 7264)
+++ trunk/gnue-forms/src/uidrivers/wx/UIdriver.py       2005-03-26 21:37:40 UTC 
(rev 7265)
@@ -54,15 +54,11 @@
 
 from common import wxEncode
 
-
-#
-# GFUserInterface
-#
-# The public interface to the User Interface
-# All UIs must provide this class
-#
 class GFUserInterface(commonToolkit.GFUserInterface):
-
+  """
+  The public interface to a GNUe Forms user interface
+  All UI drivers must provide this class
+  """
   _MBOX_KIND = {'Info'    : {'style': wxICON_INFORMATION | wxOK,
                              'title': _("Information")},
                 'Warning' : {'style': wxICON_EXCLAMATION | wxOK,
@@ -83,7 +79,7 @@
     # WX Specifics
     ################################################################
 
-    self._disabledColour = wxLIGHT_GREY
+##    self._disabledColour = wxLIGHT_GREY
 
     self._wxapp = getWxApp()
 

Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py    2005-03-26 
19:19:57 UTC (rev 7264)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py    2005-03-26 
21:37:40 UTC (rev 7265)
@@ -71,9 +71,9 @@
     formWidth = int(self._form._layout.Char__width)
     formHeight = int(self._form._layout.Char__height)
     self._visibleSize = wxSize(formWidth * self._uiDriver.widgetWidth,
-                      formHeight * self._uiDriver.widgetHeight)
-    self._formSize = formSize = wxSize(formWidth * self._uiDriver.widgetWidth,
-                      (formHeight + self.menu_sb_space) * 
self._uiDriver.widgetHeight)
+                               formHeight * self._uiDriver.widgetHeight)
+    self._formSize    = wxSize(formWidth * self._uiDriver.widgetWidth,
+                                (formHeight + self.menu_sb_space) * 
self._uiDriver.widgetHeight)
 
     # The main frame of this form
     if self._form.style != 'dialog':
@@ -159,6 +159,8 @@
   def _setStatusBar(self, tip, statusValue, insertValue, currentRecord, 
maxRecord, currentPage, maxPage):
     """
     Sets statusbar values.
+    
+    
     """
     if not self.statusBar:
       return





reply via email to

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