def get_child_id(self, name, trans=None): """ Given a name this function returns the ID of the child. @param name: The name of the child @type name: str @param trans: A valid transaction handle @return: The ID of the child if a child with the given name exists else None. @rtype: str """ conditions = (('_parentid', self._id), ('displayName', name)) cursor = None try: cursor = _db.join(conditions, trans) cursor.use_primary = True iterator = iter(cursor) try: child = iterator.next() except StopIteration: child = None iterator.close() finally: if cursor != None: cursor.close() return child
def get_child_by_name(self, name, trans=None): """ This method returns the child with the specified name. @param name: The name of the child @type name: str @param trans: A valid transaction handle @return: The child object if a child with the given name exists else None. @rtype: L{GenericItem} """ conditions = (('_parentid', self._id), ('displayName', name)) cursor = None iterator = None try: cursor = _db.join(conditions, trans) iterator = iter(cursor) try: child = iterator.next() except StopIteration: child = None finally: if iterator != None: iterator.close() if cursor != None: cursor.close() return child
def get_subfolders(self, trans=None, resolve_shortcuts=False): """ This method returns the children that are containers. @param trans: A valid transaction handle @rtype: L{ObjectSet<porcupine.core.objectSet.ObjectSet>} """ conditions = (('_parentid', self._id), ('isCollection', True)) cursor = None try: cursor = _db.join(conditions, trans) cursor.resolve_shortcuts = resolve_shortcuts subfolders = ObjectSet([f for f in cursor]) finally: if cursor != None: cursor.close() return subfolders