def checkValidId(self, id, prep_id=False): """ Checks that an id is a valid Zope id. Looks for invalid characters and checks that the id doesn't already exist in this context. @type id: string @type prep_id: boolean @rtype: boolean >>> dmd.Devices.checkValidId('^*') 'The id "^*" contains characters illegal in URLs.' >>> dmd.Devices.checkValidId('Server') 'The id "Server" is invalid - it is already in use.' >>> dmd.Devices.checkValidId('ZenTestId') True """ new_id = unquote(id) if prep_id: new_id = self.prepId(id) try: globalCheckValidId(self, new_id) return True except: return str(sys.exc_info()[1])
def checkValidId(self, id, prep_id = False): """ Checks that an id is a valid Zope id. Looks for invalid characters and checks that the id doesn't already exist in this context. @type id: string @type prep_id: boolean @rtype: boolean >>> dmd.Devices.checkValidId('^*') 'The id "^*" contains characters illegal in URLs.' >>> dmd.Devices.checkValidId('Server') 'The id "Server" is invalid - it is already in use.' >>> dmd.Devices.checkValidId('ZenTestId') True """ new_id = unquote(id) if prep_id: new_id = self.prepId(id) try: globalCheckValidId(self, new_id) return True except: return str(sys.exc_info()[1])