python-wordpress-xmlrpc icon indicating copy to clipboard operation
python-wordpress-xmlrpc copied to clipboard

WordpressPost incorrectly remaps `author` field

Open teajaymars opened this issue 10 years ago • 1 comments

https://github.com/maxcutler/python-wordpress-xmlrpc/blob/master/wordpress_xmlrpc/wordpress.py#L95

The Wordpress documentation makes it clear that the field name is post_author; following convention this might be remapped to author in this library, but I did not expect it to be remapped to user and just lost several hours of development time to this bug. (I assumed Wordpress was misbehaving...)

  • At the very least there should be an example in the documentation making this remap explicit.
  • In my opinion, a better solution is to have a consistent convention, aim for least surprise, and match the Wordpress documentation. It should be author.

teajaymars avatar Jul 28 '14 22:07 teajaymars

The fields of``WordPressPost` are indeed documented at http://python-wordpress-xmlrpc.readthedocs.org/en/latest/ref/wordpress.html#wordpresspost

The WordPress XML-RPC API is inconsistent in its use of terms, and "user" is more often used than "author". WordPressComment and WordPressAuthor both use the term "user", and WordPressUser is the primary representation of a WordPress user account. Therefore I used the term "user" for posts in an attempt to make it more consistent within the library, since we are not able to change it on the WordPress side.

At this point I can't change the name without breaking backwards compatibility. I'm open to ideas (or pull requests) on how to make the documentation clearer.

maxcutler avatar Aug 01 '14 16:08 maxcutler