Support for extra XML attributes exists now. You can include
feed_extra_attrs and/or item_extra_attrs that return a dictionary of
attribute name values to add to the feed and entry respectively.
I haven't added support for extension elements (which is what Google
Base "attributes" are) yet but that should be fairly straightforward.
The biggest challenge is just deciding how to pass the element
structure.
Including something like (to use an example from the Google Base docs):
<g:employer>Hewlett Packard</g:employer>
<g:job_type>full time</g:job_type>
<g:job_industry>Computers</g:job_industry>
<g:job_function>Marketing</g:job_function>
could be supported as something like
def item_extension_elements(self, item):
return [
("g:employer", "Hewlett Packard"),
("g:job_type", "full time"),
("g:job_industry", "Computers"),
("g:job_function", "Marketing"),
]
with the appropriate namespace bound to "g" on the feed element itself.
The tuples corresponding to XML elements, could optionally include a
third component -- a dict for XML attributes. e.g.:
<g:private_id type="text" access="private">
this is not visible by others
</g:private_id>
would be
("private_id", "this is not visible by others", {"type": "text",
"access": "private"})
But Google Base does support elements with child elements. e.g.:
<g:shipping>
<g:country> US </g:country>
<g:service> By monkey </g:service>
<g:price> 20 EUR </g:price>
</g:shipping>
Another possibility would be, as I currently do for XHTML content,
just expect the raw XML to be passed in. e.g.:
def item_extension_elements(self, item):
return """
<g:shipping>
<g:country> US </g:country>
<g:service> By monkey </g:service>
<g:price> 20 EUR </g:price>
</g:shipping>
""""
The biggest risk with that approach is that it's easy to make the
entire feed malformed by making a mistake here.
Thoughts?
On 01/08/2007, at 11:51 PM, Jason Davies wrote:
>
> On Aug 1, 5:21 pm, James Tauber <[EMAIL PROTECTED]> wrote:
>> As of r11, the full data model for the Atom Format (RFC 4287) is now
>> implemented.
>
> Great stuff. How easy is it to extend feeds with additional
> attributes, e.g. for Google Base?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---