def update_categories(self, klass): """ :param klass: OpenKMFolderlist class object """ klass.objects.all().delete() document = client.Document() categories = document.get_categories() for folder in categories: try: folder_obj = klass.objects.create(okm_uuid=folder.uuid) folder_obj.okm_author = folder.author #folder_obj.okm_created = folder.created folder_obj.okm_has_childs = folder.hasChildren folder_obj.okm_path = utils.strip_runs_of_whitespace(folder.path) folder_obj.okm_permissions = folder.permissions folder_obj.okm_subscribed = folder.subscribed folder_obj.save() except Exception, e: logger.exception(e)
def update_categories(self, klass): """ :param klass: OpenKMFolderlist class object """ klass.objects.all().delete() document = client.Document() categories = document.get_categories() for folder in categories: try: folder_obj = klass.objects.create(okm_uuid=folder.uuid) folder_obj.okm_author = folder.author #folder_obj.okm_created = folder.created folder_obj.okm_has_childs = folder.hasChildren folder_obj.okm_path = utils.strip_runs_of_whitespace( folder.path) folder_obj.okm_permissions = folder.permissions folder_obj.okm_subscribed = folder.subscribed folder_obj.save() except Exception, e: logger.exception(e)
def save(self, folders, klass): """ Iterate over the returned """ if hasattr(folders, 'item') and isinstance(folders.item, list): for folder in folders.item: if hasattr(folder, 'folder'): folder = folder.folder try: cl = klass.objects.create(okm_uuid=folder.uuid) cl.okm_author = folder.author # cl.okm_created = folder.created cl.okm_has_childs = folder.hasChildren cl.okm_path = utils.strip_runs_of_whitespace(folder.path) cl.okm_permissions = folder.permissions cl.okm_subscribed = folder.subscribed cl.save() except UnicodeEncodeError, e: logging.debug(e) except Exception, e: logging.debug(e) elif hasattr(folder, 'document'): logging.error('This is a document, not a folder')
def save(self, folders, klass): """ Iterate over the returned """ if hasattr(folders, 'item') and isinstance(folders.item, list): for folder in folders.item: if hasattr(folder, 'folder'): folder = folder.folder try: cl = klass.objects.create(okm_uuid=folder.uuid) cl.okm_author = folder.author # cl.okm_created = folder.created cl.okm_has_childs = folder.hasChildren cl.okm_path = utils.strip_runs_of_whitespace( folder.path) cl.okm_permissions = folder.permissions cl.okm_subscribed = folder.subscribed cl.save() except UnicodeEncodeError, e: logging.debug(e) except Exception, e: logging.debug(e) elif hasattr(folder, 'document'): logging.error('This is a document, not a folder')