I am trying to create a report content type that contains a point-in-time snapshot of the contents of a custom container object over a time interval. I will eventually be storing additional time-variable data with the list so generating the list just-in-time in a view will not quite work.
I have a content type for the report that includes the time interval and a field to hold the list of references to the container contents:
class IIssuesReport(form.Schema):
report_begin_date = schema.Date(
title=_(u"Report begin date"),
)
report_end_date = schema.Date(
title=_(u"Report end date"),
)
issues = RelationList(
title=_(u"Report Issues"),
description=_(u'Select Issues'),
default = [],
value_type=RelationChoice(
title=_(u'Issue'),
default=[],
source=ObjPathSourceBinder()
),
required=False,
)
I want to programatically populate the "issues" field when the form is submitted. I believe I should be able to do this by writing an adapter that override the issues() property setter to generate and assign the data to the list. I created a "populated" class with a factory to override the issues property setter:
class IPopulatedIssuesReport(interface.Interface):
"""A list of issues.
"""
class PopulateIssuesReport(object):
""" Generate the IssuesReport issues from existing inventory
"""
implements(IPopulatedIssuesReport)
adapts(IIssuesReport)
def __init__(self, context):
self.context = context
@property
def issues(self):
import pdb; pdb.set_trace()
And registered the adapter factory:
<adapter factory=".issuesReport.PopulateIssuesReport" />
I patterned much of this after other posts about adapting INameFromTitle to use other separate fields, specifically DavidJB's post:
When I created my IIssueReport content I expected to be dropped into the debugger in the adapter but it did not happen, as if the adapter never got executed. What am I missing? Is this the correct approach to populate this field with existing data from my site?