481 """ |
481 """ |
482 def __init__(self, *expected_ifaces): |
482 def __init__(self, *expected_ifaces): |
483 self.expected_ifaces = expected_ifaces |
483 self.expected_ifaces = expected_ifaces |
484 |
484 |
485 def score_class(self, eclass, req): |
485 def score_class(self, eclass, req): |
|
486 print '***********************************' |
486 score = 0 |
487 score = 0 |
487 for iface in self.expected_ifaces: |
488 for iface in self.expected_ifaces: |
|
489 print 'TESTING', iface, 'on', eclass |
488 if isinstance(iface, basestring): |
490 if isinstance(iface, basestring): |
489 # entity type |
491 # entity type |
490 iface = eclass.vreg.etype_class(iface) |
492 iface = eclass.vreg.etype_class(iface) |
|
493 print 'found iface ===', iface |
491 if implements_iface(eclass, iface): |
494 if implements_iface(eclass, iface): |
|
495 print 'and implementing !!!' |
492 score += 1 |
496 score += 1 |
493 if getattr(iface, '__registry__', None) == 'etypes': |
497 if getattr(iface, '__registry__', None) == 'etypes': |
494 score += 1 |
498 score += 1 |
495 # adjust score if the interface is an entity class |
499 # adjust score if the interface is an entity class |
496 if iface is eclass: |
500 if iface is eclass: |
502 basecls = eclass.vreg.etype_class(etype) |
506 basecls = eclass.vreg.etype_class(etype) |
503 if iface is basecls: |
507 if iface is basecls: |
504 score += index |
508 score += index |
505 # print 'etype majoration', index |
509 # print 'etype majoration', index |
506 break |
510 break |
|
511 print '***********************************', score |
507 return score |
512 return score |
508 |
513 |
509 |
514 |
510 class specified_etype_implements(implements): |
515 class specified_etype_implements(implements): |
511 """accept if entity class specified using an 'etype' parameters in name |
516 """accept if entity class specified using an 'etype' parameters in name |