Package Gnumed :: Package wxpython :: Module gmEditArea :: Class cGenericEditAreaMixin
[frames] | no frames]

Class cGenericEditAreaMixin

source code

object --+
         |
        cGenericEditAreaMixin
Known Subclasses:

Mixin for edit area panels providing generic functionality.

#====================================================================
# Class definition:

from Gnumed.wxGladeWidgets import wxgXxxEAPnl

class cXxxEAPnl(wxgXxxEAPnl.wxgXxxEAPnl, gmEditArea.cGenericEditAreaMixin):

        def __init__(self, *args, **kwargs):

                try:
                        data = kwargs['xxx']
                        del kwargs['xxx']
                except KeyError:
                        data = None

                wxgXxxEAPnl.wxgXxxEAPnl.__init__(self, *args, **kwargs)
                gmEditArea.cGenericEditAreaMixin.__init__(self)

                # Code using this mixin should set mode and data
                # after instantiating the class:
                self.mode = 'new'
                self.data = data
                if data is not None:
                        self.mode = 'edit'

                #self.__init_ui()
        #----------------------------------------------------------------
#       def __init_ui(self):
#               # adjust phrasewheels etc
        #----------------------------------------------------------------
        # generic Edit Area mixin API
        #----------------------------------------------------------------
        def _valid_for_save(self):
                return False
                return True
        #----------------------------------------------------------------
        def _save_as_new(self):
                # save the data as a new instance
                data = 

                data[''] = 
                data[''] = 

                data.save()

                # must be done very late or else the property access
                # will refresh the display such that later field
                # access will return empty values
                self.data = data
                return False
                return True
        #----------------------------------------------------------------
        def _save_as_update(self):
                # update self.data and save the changes
                self.data[''] = 
                self.data[''] = 
                self.data[''] = 
                self.data.save()
                return True
        #----------------------------------------------------------------
        def _refresh_as_new(self):
                pass
        #----------------------------------------------------------------
        def _refresh_from_existing(self):
                pass
        #----------------------------------------------------------------
        def _refresh_as_new_from_existing(self):
                pass
        #----------------------------------------------------------------
        

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
display_tctrl_as_valid(self, tctrl=None, valid=None) source code
 
refresh(self)
Invoked from the generic edit area dialog.
source code
 
save(self)
Invoked from the generic edit area dialog.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties
  data
  mode

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

refresh(self)

source code 
Invoked from the generic edit area dialog.

Invokes
        _refresh_as_new
        _refresh_from_existing
        _refresh_as_new_from_existing
on the implementing edit area as needed.

save(self)

source code 
Invoked from the generic edit area dialog.

Invokes
        _valid_for_save,
        _save_as_new,
        _save_as_update
on the implementing edit area as needed.

_save_as_* must set self.__data and return True/False


Property Details

data

Get Method:
_get_data(self)
Set Method:
_set_data(self, data=None)

mode

Get Method:
_get_mode(self)
Set Method:
_set_mode(self, mode=None)