Example #1
0
    def createObject(self):

        package = self.metaclass.package.qualifiedName()
        parts = package.split('.')
        parts[1:1] = apiSubDirs
        moduleName = '.'.join(parts)

        try:
            module = importModule(moduleName)
        except:
            showError('Finding module',
                      'Could not find module "%s"' % moduleName,
                      parent=self)
            return

        try:
            Clazz = getattr(module, self.metaclass.name)
        except:
            showError('Finding class',
                      'Could not find module "%s", class "%s"' %
                      (moduleName, self.metaclass.name),
                      parent=self)
            return

        try:
            attrlinks = self.creatorMap.copy()
            del attrlinks[self.metaclass.parentRole.name]  # remove parent link
            object = Clazz(self.objParent, **attrlinks)
        except Implementation.ApiError, e:
            showError('Creating object', e.error_msg, parent=self)
            return
Example #2
0
 def __init__(self, parent, inGui=None):
 
   if inGui:
     self.popup           = None
     self.dataEntryDialog = importModule('memops.gui.DataEntry')
     self.messageReporter = importModule('memops.gui.MessageReporter')
     try:
       self.chooseObjectDialog = self.objectSelectionPopup
       self.dataModelPopup  = importModule('ccp.general.SelectObject')
     except ImportError:
       self.chooseObjectDialog = self.pickObjectByAttribute
   else:
     self.chooseObjectDialog = self.pickObjectByAttribute
     self.dataEntryDialog = importModule('memops.universal.DataEntry')
     self.messageReporter = importModule('memops.universal.MessageReporter')
 
   self.inGui   = inGui
   self.parent  = parent
Example #3
0
  def getFile(self, file_types = None, dismiss_text='Cancel',
              selected_file_must_exist = False):

    if self.inGui:
      module = importModule('memops.gui.FileSelectPopup')
      popup = module.FileSelectPopup(self.parent, file_types=file_types,
                                     dismiss_text=dismiss_text,
                                     selected_file_must_exist=selected_file_must_exist)
      fileName = popup.getFile()
      popup.destroy()
    else:
      fileName = raw_input('Enter file name: ').strip()

    return fileName
Example #4
0
    def getDirectory(self,
                     dismiss_text='Cancel',
                     selected_file_must_exist=False):

        if self.inGui:
            module = importModule('memops.gui.FileSelectPopup')
            popup = module.FileSelectPopup(
                self.parent,
                dismiss_text=dismiss_text,
                selected_file_must_exist=selected_file_must_exist)
            directory = popup.getDirectory(needFileSelected=False)
            popup.destroy()
        else:
            directory = raw_input('Enter directory: ').strip()

        return directory