Pergunta

in a Plone Site, I have got a Professor and a Department class. They are bidirectionally m:n. I am using ArgoUML and ArchGenXML to generate these classes - how can I make this relation navigable, so that I can get not only to a professor's departments, but also to a department's professors in a view? The way I am doing it seems to generate classes so, that I can navigate from Professor to Department, but in the Department schema, no such link is created...

Thanks!

schema = Schema(( #professor

StringField(
    name='name',
    widget=StringField._properties['widget'](
        label='Name',
        label_msgid='ufscar_label_name',
        i18n_domain='ufscar',
    ),
),
ReferenceField(
    name='departments',
    widget=ReferenceBrowserWidget(
        label='Departments',
        label_msgid='ufscar_label_departments',
        i18n_domain='ufscar',
    ),
    allowed_types=('Department',),
    multiValued=1,
    relationship='DepartmentMembership',
),
)

and

schema = Schema(( #department

StringField(
    name='name',
    widget=StringField._properties['widget'](
        label='Name',
        label_msgid='ufscar_label_name',
        i18n_domain='ufscar',
    ),
),
)

------------- Appendix -----------------

Sorry, cannot format in the comments, so I'll ask here:

The Products.ATBackRef 2.1 page says

  • in your UML tool create a relation between 2 classes and make the 'to' end of i the assocation navigable (such a beast is provided in the sample dir).

I guess this the default, both ends are navigateable

  • add the tagged value backreferences_support to your model and set it to 1.

The model being the class? Or create an attribute for that? Or the relation? I am confused... By setting it to one, how would it know which back reference to navigate? There could be more than one...

Foi útil?

Solução

You want to use BackReferenceField. References are directional, which is to say one object points to another and going the other direction is not the same. The reference engine can, however, do that reverse lookup using back references. A BackReferenceField lets you use that.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top