Changeset 85

Show
Ignore:
Timestamp:
01/22/08 18:05:47 (4 years ago)
Author:
phil
Message:

added set with an rdfObject on the lhs

Location:
rdfalchemy/trunk/rdfalchemy
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • rdfalchemy/trunk/rdfalchemy/orm.py

    r73 r85  
    1414 
    1515def allsub(cl): 
     16    "return all subclasses of the given class" 
    1617    sub = set(cl.__subclasses__()) 
    1718    for onesub in cl.__subclasses__(): 
    1819        sub |= allsub(onesub) 
    1920    return sub 
     21     
    2022 
    2123def mapper(*classes): 
    2224    """Map the classes given to allow descriptors with ranges to the proper Class of that type 
    23     default if no args is to map all subclasses(recursivly) of rdfObject""" 
     25    default if no args is to map all subclasses(recursivly) of rdfObject 
     26     
     27    preforms the mapping 
     28     
     29    returns a dict of {rdf_type: mapped_class} for further processing""" 
    2430    if not classes: 
    2531        classes = allsub(rdfObject) 
     
    3238                except KeyError: 
    3339                    log.warn("No Class Found\nFailed to map %s range of %s"%(v,v.range_type)) 
    34                      
     40    return class_dict 
     41 
     42#def mapBase(baseclass): 
     43#    """This maps all classes below baseclass as in mapper() 
     44#    AND puts the dict of {rdf_type: mapped_class}  in an baseclass.type2class attribute""" 
     45#    baseclass.type2class = mapper(allsub(baseclass)) 
     46     
  • rdfalchemy/trunk/rdfalchemy/rdfalchemy.py

    r84 r85  
    4141formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 
    4242console.setFormatter(formatter) 
    43 log=logging.getLogger('rdfAlchemy') 
     43log=logging.getLogger('rdfalchemy') 
    4444##log.setLevel(logging.DEBUG) 
    4545log.addHandler(console) 
     
    146146        if isinstance(value,Literal) or isinstance(value,URIRef) or isinstance(value,BNode): 
    147147            o = value 
     148        elif isinstance(value,rdfObject): 
     149            o = value.resUri 
    148150        elif isinstance(value,str) or isinstance(value,unicode): 
    149151            o = Literal(value,) 
     
    304306         
    305307    def __repr__(self): 
    306         return "<%s -> %s>"%(self.__class__, self.resUri) 
     308        return "<%s: %s>"%(self.__class__.__name__, self.n3()) 
    307309 
    308310    def __getitem__(self, pred):