def get_product(self):
     '''
         return dict with the info, interface 
         needed for setting component-level productClass
     '''
     getName = "_getProductClass"
     setName = "_setProductClass"
     getKlass = stringToMethod(getName, '''def %s(self):\n    return self._object.getProductKey()\n''' % (getName))
     setKlass = stringToMethod(setName, '''def %s(self, value):\n    self._object.productKey = value\n    self._object.setProductKey(value)\n'''% (setName))
     data = {'info': {}, 'interface': {}, 'infotext': {}}
     data['info'][getName] = getKlass
     data['info'][setName] = setKlass
     data['info'][self.id] = property(getKlass, setKlass)
     data['interface'][self.id] = self.interface_type()(title=_t(u'%s' % self.title), alwaysEditable=True, readonly=False, default=_t(u'%s' % self.default))
     return data
 def get_password(self):
     '''
         return dict with the info, interface 
         needed for setting component-level password
     '''
     getName = "_get%s" % self.id.lower().capitalize()
     setName = "_set%s" % self.id.lower().capitalize()
     getChoice = stringToMethod(getName, '''def %s(self):\n    return self._object.getPassword("%s")\n''' % (getName, self.id))
     setChoice = stringToMethod(setName, '''def %s(self, value):\n    self._object.setPassword("%s", value)\n'''% (setName, self.id))
     data = {'info': {}, 'interface': {}, 'infotext': {}}
     data['info'][getName] = getChoice
     data['info'][setName] = setChoice
     data['info'][self.id] = property(getChoice, setChoice)
     data['interface'][self.id] = self.get_interface()
     return data
 def get_info(self):
     '''return object suitable for info.py'''
     if self.isMethod == True:
         text = '''@property\ndef %s(self):\n    return self._object.%s()''' % (self.id, self.id)
         return stringToMethod(self.id, text)
     else:
         return ProxyProperty('%s' % self.id)
 def get_chooser(self, vocname, vocref, voctext):
     ''''''
     listName = "list%s" % self.methodName
     getName = "_get%s" % self.id
     setName = "_set%s" % self.id
     listChoices = stringToMethod(listName, '''def %s(self):\n    return self._object.%s()\n''' % (listName, self.methodName))
     getChoice = stringToMethod(getName, '''def %s(self):\n    return self._object.%s\n''' % (getName, self.id))
     setChoice = stringToMethod(setName, '''def %s(self, value):\n    self._object.%s = value\n'''% (setName, self.id))
     data = {'info': {}, 'interface': {}, 'infotext': {}}
     data['info'][listName] = listChoices
     data['info'][getName] = getChoice
     data['info'][setName] = setChoice
     data['info'][self.id] = property(getChoice, setChoice)
     #voctext = '''from zope.schema.vocabulary import SimpleVocabulary\ndef %s(context):\n    return SimpleVocabulary.fromValues(context.%s())\n\n''' % (vocname, listName)
     data['infotext'][vocname] = voctext % (vocname, listName)
     data['interface'][self.id] = schema.Choice(title=_t(u'%s' % self.title), alwaysEditable=True, vocabulary=vocref, default=self.default)
     return data
 def get_chooser(self, vocname, vocref, voctext):
     '''
         return dict with the info, interface, and vocablulary 
         needed for drop-down chooser menus like eventClass
     '''
     listName = "list%s" % self.methodName
     getName = "_get%s" % self.id
     setName = "_set%s" % self.id
     listChoices = stringToMethod(listName, '''def %s(self):\n    return self._object.%s()\n''' % (listName, self.methodName))
     getChoice = stringToMethod(getName, '''def %s(self):\n    return self._object.%s\n''' % (getName, self.id))
     setChoice = stringToMethod(setName, '''def %s(self, value):\n    self._object.%s = value\n'''% (setName, self.id))
     data = {'info': {}, 'interface': {}, 'infotext': {}}
     data['info'][listName] = listChoices
     data['info'][getName] = getChoice
     data['info'][setName] = setChoice
     data['info'][self.id] = property(getChoice, setChoice)
     data['infotext'][vocname] = voctext % (vocname, listName)
     data['interface'][self.id] = schema.Choice(title=_t(u'%s' % self.title), alwaysEditable=True, vocabulary=vocref, default=self.default)
     return data
def addMethods(definition, title, data={}):
    ''' add get, set, and link methods to a supplemental relation'''
    from ZenPacks.community.ConstructionKit.ClassHelper import stringToMethod
    methods = []
    names = []
    for v in data.values():
        name = v['name']
        args = (name,) 
        args += v['args']
        text = v['text'] % args
        names.append(name)
        methods.append(stringToMethod(v['name'], text))
    definition.componentMethods += methods
    definition.componentData['properties'][ data['set']['name'].lower() ] = getSetter(data['set']['name'])
    definition.componentData['properties'][ data['link']['name']] = getReferredMethod(title, data['link']['name'])
    definition.ignoreKeys += names
    definition.ignoreKeys += [data['set']['name'].lower(), data['link']['name']]