jsumners / jsumners/feedparser
How to monkey patch to get key value pairs when the parent element is different but child elements are namespaced the same
Open
Nobody has claimed this yet.
auto-migrated
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
What steps will reproduce the problem?
I have (Word Press) namespaced markup that looks like:
<wp:postmeta>
<wp:meta_key>_edit_last</wp:meta_key>
<wp:meta_value><![CDATA[6]]></wp:meta_value>
</wp:postmeta>
I can retrieve this fine with my current monkey patching. However, I also have
blocks like this:
<wp:commentmeta>
<wp:meta_key>akismet_result</wp:meta_key>
<wp:meta_value><![CDATA[false]]></wp:meta_value>
</wp:commentmeta>
This replaces my values for wp_meta_key and wp_meta_value because my monkey
patching doesn't take into account the parent elements (in this case,
wp_postmeta and wp_commentmeta respectively).
I know how to monkey patch. I don't know how to determine the parent element
and assign the key value pairs to specific parent elements. Please advise.
What is the expected output? What do you see instead?
I see the last entry of my wp_postmeta object (created by my monkey patches)
replaced with the key and value of the entry of the wp_commentmeta object.
What I want to see is:
wp_postmeta = [{'wp_meta_value': u'6', 'wp_meta_key': u'_edit_last'}]
wp_commentmeta = [{'wp_meta_value': u'false', 'wp_meta_key': u'akismet_result'}]
What I end up seeing is:
wp_postmeta = [{'wp_meta_value': u'false', 'wp_meta_key': u'akismet_result'}]
What version of the product are you using? On what operating system?
5.1.3, OS X Yosemite, Python 2.7.5
Please provide any additional information below.
I can provide additional info as needed. What I really need (and have asked for
before in June, 2014) is a guide on monkey patching best practices. Right now
it is just trial and error. Looking at the source doesn't give much of a guide
as it is not commented sufficiently with explanations as to what does what.
Thanks in advance.
Original issue reported on code.google.com by robertln...@gmail.com on 20 Oct 2014 at 11:20
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source file or test. Reproduce the two namespaced XML fragments described with Python 2.7.5 and compare the resulting wp_postmeta and wp_commentmeta values. Inspect the parser's namespace and monkey-patching behavior; done means parent-specific collections preserve both key/value pairs without replacement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100