-
Notifications
You must be signed in to change notification settings - Fork 68
[IMP] util.update_record_from_xml #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
src/util/records.py
Outdated
@@ -1147,6 +1148,8 @@ def add_ref(ref): | |||
doc = lxml.etree.parse(fp) | |||
for node in doc.xpath(xpath): | |||
found = True | |||
if xml_filename is None and module == from_module: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we check module vs from_module? Don't we need to set the xml_filename to be the actual file always?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to avoid setting the filename when we load an overridden record (initially declared in another module).
However, the models that use this xml_filename
(views, mail templates) are not usually changed by other modules (and even less updated via update_record_from_xml
), so I can remove this condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do what standard code does.
Set the `xml_filename` argument of the `xml_import` records.
a24211e
to
e6d1bdf
Compare
@@ -1147,6 +1148,8 @@ def add_ref(ref): | |||
doc = lxml.etree.parse(fp) | |||
for node in doc.xpath(xpath): | |||
found = True | |||
if xml_filename is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we now need the found
variable? We can keep the xml_filename as the "found" signal whenever it's set. Maybe named found_in_xml_file
?
There is a slight subtlety. We do not break the search loop when found. Thus in practice we keep searching and adding nodes to our new root. This means that we will be lying if we keep the same filename when loading our new root. Maybe we should have a new_root
per found_in_xml_file
, a sort of map filename->new_root
. We should double check the standard behavior if we really care about this.
EDIT: This is obviously a corner case since it's a mistake to have two records with same xmlid redefined in the same module in xml. But this has been actually seen before. Aligning with standard code would be "saner" even for the corner case.
upgradeci retry with always only hr |
After some tests, it doesn't work as expected in all cases.
Maybe all those usages should be standardized in a common mixin which also handle the update. |
I think this could be an option if this becomes more widely use. For current cases it looks very localized and (if I'm not mistaked) with a simple solution. The mixin may add extra complexity that we don't need for these few cases. |
No, it's not enough. It should be set in |
What I had in mind was that the field should be a computed stored field, with "depends". I missed that it was just |
Set the
xml_filename
argument of thexml_import
records.