commit-gnue
[Top][All Lists]
Advanced

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

gnue common/doc/technotes/00005.txt common/src/...


From: Jason Cater
Subject: gnue common/doc/technotes/00005.txt common/src/...
Date: Sun, 01 Dec 2002 17:53:04 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/12/01 17:53:04

Modified files:
        common/doc/technotes: 00005.txt 
        common/src     : GConnections.py 
        designer/src   : TemplateBase.py TemplateParser.py 
        forms/src      : GFForm.py 

Log message:
        * Added form.getAuthenticatedUser(connection)
        * Cleaned up custom authenticators

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/doc/technotes/00005.txt.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GConnections.py.diff?tr1=1.44&tr2=1.45&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TemplateBase.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TemplateParser.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFForm.py.diff?tr1=1.214&tr2=1.215&r1=text&r2=text

Patches:
Index: gnue/common/doc/technotes/00005.txt
diff -c gnue/common/doc/technotes/00005.txt:1.4 
gnue/common/doc/technotes/00005.txt:1.5
*** gnue/common/doc/technotes/00005.txt:1.4     Sun Dec  1 09:42:37 2002
--- gnue/common/doc/technotes/00005.txt Sun Dec  1 17:53:04 2002
***************
*** 154,160 ****
          'select 1 from users where username=%s and password=%s',
          (loginData['_username'],
           loginData['_password']) )
!     if not results.fetchone():
        raise LoginError
      else:
        loginData['_username'] = 'dbLogin'
--- 154,160 ----
          'select 1 from users where username=%s and password=%s',
          (loginData['_username'],
           loginData['_password']) )
!     if not cursor.fetchone():
        raise LoginError
      else:
        loginData['_username'] = 'dbLogin'
Index: gnue/common/src/GConnections.py
diff -c gnue/common/src/GConnections.py:1.44 
gnue/common/src/GConnections.py:1.45
*** gnue/common/src/GConnections.py:1.44        Wed Sep 18 02:49:27 2002
--- gnue/common/src/GConnections.py     Sun Dec  1 17:53:04 2002
***************
*** 66,71 ****
--- 66,72 ----
      self._loginHandler = loginHandler
      self._parser = ConfigParser()
      self._location = location
+     self._authenticatedUsers = {}
  
      GDebug.printMesg(1,'Conn File: "%s"' % location)
  
***************
*** 259,265 ****
            break
  
        if haveAllInformation:
!         if authenticator: 
            dataObject.connect(authenticator.login(loginData))
          else:
            dataObject.connect(loginData)
--- 260,271 ----
            break
  
        if haveAllInformation:
!         try:
!           self._authenticatedUsers[connection] = loginData['_username']
!         except KeyError:
!           self._authenticatedUsers[connection] = None
! 
!         if authenticator:
            dataObject.connect(authenticator.login(loginData))
          else:
            dataObject.connect(loginData)
***************
*** 283,290 ****
                 self.getConnectionParameter(connection_name,'comment',''),
                 dataObject.getLoginFields()], errortext))
  
              # Ask the data object to connect to the database
!             dataObject.connect(loginData)
  
              # Save the newly opened connection for future datasources
              self._openConnections[connection_name] = \
--- 289,305 ----
                 self.getConnectionParameter(connection_name,'comment',''),
                 dataObject.getLoginFields()], errortext))
  
+             # Add to authenticated user list
+             try:
+               self._authenticatedUsers[connection] = loginData['_username']
+             except KeyError:
+               self._authenticatedUsers[connection] = None
+ 
              # Ask the data object to connect to the database
!             if authenticator:
!               dataObject.connect(authenticator.login(loginData))
!             else:
!               dataObject.connect(loginData)
  
              # Save the newly opened connection for future datasources
              self._openConnections[connection_name] = \
***************
*** 312,317 ****
--- 327,340 ----
              self._loginHandler.destroyLoginDialog()
              raise GDataObjects.LoginError, _("User canceled the login 
request.")
  
+   def getAuthenticatedUser(self, connection=None):
+     try:
+       if connection == None:
+         return self._authenticatedUsers[self._authenticatedUsers.keys()[0]]
+       else:
+         return self._authenticatedUsers[connection]
+     except (KeyError, IndexError):
+       return None
  
  
  
Index: gnue/designer/src/TemplateBase.py
diff -c gnue/designer/src/TemplateBase.py:1.20 
gnue/designer/src/TemplateBase.py:1.21
*** gnue/designer/src/TemplateBase.py:1.20      Sat Nov 30 18:00:35 2002
--- gnue/designer/src/TemplateBase.py   Sun Dec  1 17:53:04 2002
***************
*** 225,237 ****
  # Wizard elements
  #
  ###########################################################
- class WizardPage:
- 
- ##  _ELEMENTS = GFParser.getXMLelements()
- 
-   def __init__(self, variables):
-     self.variables = variables
- 
  
  # Available field types
  boolean = GTypecast.boolean
--- 225,230 ----
Index: gnue/designer/src/TemplateParser.py
diff -c gnue/designer/src/TemplateParser.py:1.23 
gnue/designer/src/TemplateParser.py:1.24
*** gnue/designer/src/TemplateParser.py:1.23    Wed Nov 27 19:11:31 2002
--- gnue/designer/src/TemplateParser.py Sun Dec  1 17:53:04 2002
***************
*** 29,34 ****
--- 29,35 ----
  from wxPython.wx import *
  from gnue.designer import TemplateBase
  from gnue.common.FileUtils import dyn_import
+ from gnue.common import TextUtils
  from gnue.common.events import Event
  
  class TemplateParser:
***************
*** 47,128 ****
  
      self.template = self.templateInformation['BaseClass'](self)
  
!     self.template.Start(self.rootObject,
!                         self.instance.buildWizardCurrentDict(),
!                         **params)
! 
!     # If this is simply a template and not a wizard,
!     # generate the results and get out of Dodge.
!     if self.templateInformation['Behavior'] == TemplateBase.TEMPLATE:
!       return self.template.Finalize()
! 
!     self.wizard = wxDialog(self.parent, -1, self.templateInformation['Name'],
!        style=wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
! 
!     self.panel = wxPanel(self.wizard, -1, wxPoint(0,0), wxSize(400,400))
!     self.wizard.SetClientSize(wxSize(400,400))
! 
!     self.wizardPage = WizardPage(self, self.panel)
! 
!     self.prevButton = wxButton(self.panel, -1, _('< Back'))
!     self.nextButton = wxButton(self.panel, -1, _('Continue >'))
!     self.cancelButton = wxButton(self.panel, -1, _('Cancel'))
! 
!     self.nextButton.SetDefault()
! 
!     self.prevButton.SetSize(self.nextButton.GetSize())
!     self.cancelButton.SetSize(self.nextButton.GetSize())
! 
!     y = self.panel.GetClientSize().y - 9 - self.nextButton.GetSize().y
!     dx = self.nextButton.GetSize().x + 6
!     x = self.panel.GetClientSize().x - 9 - self.nextButton.GetSize().x
! 
!     self.cancelButton.SetPosition( (x, y) )
!     self.nextButton.SetPosition( (x - dx, y) )
!     self.prevButton.SetPosition( (x - dx*2, y) )
! 
!     EVT_BUTTON(self.wizard,self.prevButton.GetId(), 
self.wizardPage.OnPrevStep)
!     EVT_BUTTON(self.wizard,self.nextButton.GetId(), 
self.wizardPage.OnNextStep)
!     EVT_BUTTON(self.wizard,self.cancelButton.GetId(), 
self.wizardPage.OnCancel)
! 
!     EVT_CLOSE(self.wizard, self.wizardPage.OnCancel)
! 
!     self.title = wxStaticText(self.panel, -1, _("Wizard Header"), 
pos=wxPoint(10,10))
!     font = self.title.GetFont()
!     font.SetPointSize(int(self.title.GetFont().GetPointSize()*1.5))
!     font.SetStyle(wxITALIC)
! #    font.SetWeight(wxBOLD)
!     self.title.SetForegroundColour(wxColour(255,255,255))
!     self.title.SetFont(font)
!     self.title2 = wxStaticText(self.panel, -1, _("Wizard Header"), 
pos=wxPoint(11,11))
!     self.title2.SetForegroundColour(wxColour(0,0,102))
!     self.title2.SetFont(font)
! 
!     self.wizard.Fit()
! 
!     self.wizardPage.SetPosition((20, 20 + self.title.GetSize().y))
!     w,h = self.wizard.GetClientSizeTuple()
!     w = w - 50
!     h = h - 56 - self.title.GetSize().y - self.nextButton.GetSize().y
!     self.wizardPage.SetSize((w,h))
! 
!     r = self.panel.GetBackgroundColour().Red()
!     g = self.panel.GetBackgroundColour().Green()
!     b = self.panel.GetBackgroundColour().Blue()
! 
!     self.wizardPage.SetBackgroundColour(
!         wxColour(
!           (r <= 223 and r or 223) + 32,
!           (g <= 223 and g or 223) + 32,
!           (b <= 223 and b or 223) + 32) )
! 
!     self.wizardPage.setStep(self.template.FIRST_STEP)
!     completed = self.wizard.ShowModal()
!     if completed:
!       completed = self.template.Finalize()
  
-     self.wizardPage.Destroy()
-     self.wizard.Destroy()
      return completed
  
  
--- 48,149 ----
  
      self.template = self.templateInformation['BaseClass'](self)
  
!     completed = 0
! 
!     try:
!       self.template.Start(self.rootObject,
!                           self.instance.buildWizardCurrentDict(),
!                           **params)
! 
!       # If this is simply a template and not a wizard,
!       # generate the results and get out of Dodge.
!       if self.templateInformation['Behavior'] == TemplateBase.TEMPLATE:
!         return self.template.Finalize()
! 
!       self.wizard = wxDialog(self.parent, -1, 
self.templateInformation['Name'],
!          style=wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
! 
!       self.panel = wxPanel(self.wizard, -1, wxPoint(0,0), wxSize(400,400))
!       self.wizard.SetClientSize(wxSize(400,400))
! 
!       self.wizardPage = WizardPage(self, self.panel)
! 
!       self.prevButton = wxButton(self.panel, -1, _('< Back'))
!       self.nextButton = wxButton(self.panel, -1, _('Continue >'))
!       self.cancelButton = wxButton(self.panel, -1, _('Cancel'))
! 
!       self.nextButton.SetDefault()
! 
!       self.prevButton.SetSize(self.nextButton.GetSize())
!       self.cancelButton.SetSize(self.nextButton.GetSize())
! 
!       y = self.panel.GetClientSize().y - 9 - self.nextButton.GetSize().y
!       dx = self.nextButton.GetSize().x + 6
!       x = self.panel.GetClientSize().x - 9 - self.nextButton.GetSize().x
! 
!       self.cancelButton.SetPosition( (x, y) )
!       self.nextButton.SetPosition( (x - dx, y) )
!       self.prevButton.SetPosition( (x - dx*2, y) )
! 
!       EVT_BUTTON(self.wizard,self.prevButton.GetId(), 
self.wizardPage.OnPrevStep)
!       EVT_BUTTON(self.wizard,self.nextButton.GetId(), 
self.wizardPage.OnNextStep)
!       EVT_BUTTON(self.wizard,self.cancelButton.GetId(), 
self.wizardPage.OnCancel)
! 
!       EVT_CLOSE(self.wizard, self.wizardPage.OnCancel)
! 
!       self.title = wxStaticText(self.panel, -1, _("Wizard Header"), 
pos=wxPoint(10,10))
!       font = self.title.GetFont()
!       font.SetPointSize(int(self.title.GetFont().GetPointSize()*1.5))
!       font.SetStyle(wxITALIC)
! #      font.SetWeight(wxBOLD)
!       self.title.SetForegroundColour(wxColour(255,255,255))
!       self.title.SetFont(font)
!       self.title2 = wxStaticText(self.panel, -1, _("Wizard Header"), 
pos=wxPoint(11,11))
!       self.title2.SetForegroundColour(wxColour(0,0,102))
!       self.title2.SetFont(font)
! 
!       self.wizard.Fit()
! 
!       self.wizardPage.SetPosition((20, 20 + self.title.GetSize().y))
!       w,h = self.wizard.GetClientSizeTuple()
!       w = w - 50
!       h = h - 56 - self.title.GetSize().y - self.nextButton.GetSize().y
!       self.wizardPage.SetSize((w,h))
! 
!       r = self.panel.GetBackgroundColour().Red()
!       g = self.panel.GetBackgroundColour().Green()
!       b = self.panel.GetBackgroundColour().Blue()
! 
!       self.wizardPage.SetBackgroundColour(
!           wxColour(
!             (r <= 223 and r or 223) + 32,
!             (g <= 223 and g or 223) + 32,
!             (b <= 223 and b or 223) + 32) )
! 
!       self.wizardPage.setStep(self.template.FIRST_STEP)
!       completed = self.wizard.ShowModal()
!       if completed:
!         completed = self.template.Finalize()
! 
!     except TemplateBase.InsufficientInformation, msg:
!       # Give feedback if the wizard raised an exception
!       if str(msg):
!         msg = "\n\n" + TextUtils.lineWrap(str(msg),40)
!       else:
!         msg = ""
! 
!       dlg = wxMessageDialog(NULL,
!               _("Unable to perform the requested action.") + msg,
!               _("Wizard Error"), style=wxOK|wxICON_WARNING)
!       dlg.ShowModal()
!       dlg.Destroy()
! 
!     # Cleanup...
!     try:      self.wizardPage.Destroy()
!     except:   pass
!     try:      self.wizard.Destroy()
!     except:   pass
  
      return completed
  
  
***************
*** 153,158 ****
--- 174,180 ----
      self.prevStep = self.stepInfo['prev']
      self.buildPage()
  
+   # User clicked the "Next >" (or "Finish") button
    def OnNextStep(self, event):
  
      validation = []
***************
*** 162,182 ****
        value = o.get()
        if o.source.required and (value == None or not o.source.set and
                 o.source.typecast == TemplateBase.text and not len(value)):
!         validation.append('A required value is missing for "%s"' % 
o.source.variable)
  
          ## TODO: Add the various other validation checks
  
        self.parser.template.variables[self.editorMappings[o].variable] = value
  
  
      if not validation:
        validation = self.parser.template.ValidateStep(self.step)
  
      if validation:
!       # TODO: This should display a dialog box listing problems...
!       for mesg in validation:
!         print "(*) %s" % mesg
        return
      else:
        if self.nextStep == None:
          self.parser.wizard.EndModal(1)
--- 184,214 ----
        value = o.get()
        if o.source.required and (value == None or not o.source.set and
                 o.source.typecast == TemplateBase.text and not len(value)):
!         validation.append('A required value is missing for "%s"' % (
!             hasattr(o.source,'label') and o.source.label or 
o.source.variable))
  
          ## TODO: Add the various other validation checks
  
        self.parser.template.variables[self.editorMappings[o].variable] = value
  
  
+     # Ask the template instance if it validates or not
      if not validation:
        validation = self.parser.template.ValidateStep(self.step)
  
+     # Whoop! The user forgot something... inform them
      if validation:
!       # Give feedback
!       dlg = wxMessageDialog(self.parser.wizard,
!               _("Please correct the following mistakes before continuing:\n\n 
- ") + \
!               string.join(validation,'\n - '),
!               _("Wizard Error"), style=wxOK|wxICON_WARNING)
!       dlg.ShowModal()
!       dlg.Destroy()
! 
        return
+ 
+     # Life is good and we have our info.... High-tail it out of here
      else:
        if self.nextStep == None:
          self.parser.wizard.EndModal(1)
***************
*** 184,189 ****
--- 216,222 ----
          self.setStep(self.nextStep)
          event.Skip()
  
+   # User clicked the "< Prev" button
    def OnPrevStep(self, event):
      # Save the variables from current step
      for o in self.editorMappings.keys():
***************
*** 191,199 ****
--- 224,234 ----
  
      self.setStep(self.prevStep)
  
+   # User clicked the "Cancel" button
    def OnCancel(self, event):
      self.parser.wizard.EndModal(0)
  
+   # Build all the widgets and position them
    def buildPage(self):
      for child in self.GetChildren():
        child.Destroy()
***************
*** 228,238 ****
      for object in self.stepInfo['content']:
  
        if isinstance(object, TemplateBase.WizardText):
- 
-         # TODO: WizardText should automagically be wrapped.
-         # TODO: Currently, we must embed \n in the text to
-         # TODO: perform our own wrapping. Of course, this is
-         # TODO: not at all portable!
  
          width = self.GetSize().x - xMargin * 2
  
--- 263,268 ----
Index: gnue/forms/src/GFForm.py
diff -c gnue/forms/src/GFForm.py:1.214 gnue/forms/src/GFForm.py:1.215
*** gnue/forms/src/GFForm.py:1.214      Fri Nov 29 02:07:00 2002
--- gnue/forms/src/GFForm.py    Sun Dec  1 17:53:04 2002
***************
*** 101,106 ****
--- 101,109 ----
      self._triggerFunctions = {'setFocus':{'function':self.triggerSetFocus,
                                            'global': 1,
                                            },
+                               
'getAuthenticatedUser':{'function':self.getAuthenticatedUser,
+                                           'global': 1,
+                                           },
                                
'getCurrentEntry':{'function':self.triggerGetCurrentEntry,
                                            'global': 1,
                                            },
***************
*** 763,766 ****
      except KeyError:
        raise KeyError, "Trigger attempted to get unknown feature %s" % feature
  
! 
--- 766,770 ----
      except KeyError:
        raise KeyError, "Trigger attempted to get unknown feature %s" % feature
  
!   def getAuthenticatedUser(self, connection=None):
!     return self._instance.connections.getAuthenticatedUser(connection)




reply via email to

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