forked from maxcutler/python-wordpress-xmlrpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposts.py
More file actions
125 lines (90 loc) · 3.64 KB
/
Copy pathposts.py
File metadata and controls
125 lines (90 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
from wordpress_xmlrpc.base import *
from wordpress_xmlrpc.mixins import *
from wordpress_xmlrpc.wordpress import WordPressPost
class GetRecentPosts(AuthenticatedMethod):
"""
Retrieve most recent posts from the blog.
Parameters:
`num_posts`: Number of blog posts to return.
Returns: `list` of `WordPressPost` instances.
"""
method_name = 'metaWeblog.getRecentPosts'
method_args = ('num_posts',)
results_class = WordPressPost
class GetPost(AuthParamsOffsetMixin, AuthenticatedMethod):
"""
Retrieve an individual blog post.
Parameters:
`post_id`: ID of the blog post to retrieve.
Returns: `WordPressPost` instance.
"""
method_name = 'metaWeblog.getPost'
method_args = ('post_id',)
results_class = WordPressPost
class NewPost(AuthenticatedMethod):
"""
Create a new post on the blog.
Parameters:
`content`: A `WordPressPost` instance with at least the `title` and `description` values set.
`publish`: Boolean indicating whether the blog post should be published upon creation.
Returns: ID of the newly-created blog post (an integer).
"""
method_name = 'metaWeblog.newPost'
method_args = ('content', 'publish')
class EditPost(AuthParamsOffsetMixin, AuthenticatedMethod):
"""
Edit an existing blog post.
Parameters:
`post_id`: ID of the blog post to edit.
`content`: A `WordPressPost` instance with the new values for the blog post.
`publish`: Boolean indicating whether the blog post should be published upon being updated.
Returns: `True` on successful edit.
"""
method_name = 'metaWeblog.editPost'
method_args = ('post_id', 'content', 'publish')
class DeletePost(BloggerApiMethodMixin, AuthParamsOffsetMixin, AuthenticatedMethod):
"""
Delete a blog post.
Parameters:
`post_id`: ID of the blog post to delete.
Returns: `True` on successful deletion.
"""
method_name = 'blogger.deletePost'
method_args = ('post_id', )
class GetPostStatusList(AuthenticatedMethod):
"""
Retrieve the set of possible blog post statuses (e.g., "draft," "private," "publish").
Parameters:
None
Returns: `dict` of values and their pretty names.
Example:
>>> client.call(GetPostStatusList())
{'draft': 'Draft', 'private': 'Private', 'pending': 'Pending Review', 'publish': 'Published'}
"""
method_name = 'wp.getPostStatusList'
class GetPostFormats(AuthenticatedMethod):
"""
Retrieve the set of post formats used by the blog.
Parameters:
None
Returns: `dict` containing a `dict` of all blog post formats (`all`)
and a list of formats `supported` by the theme.
Example:
>>> client.call(GetPostFormats())
{'all': {'status': 'Status', 'quote': 'Quote', 'image': 'Image', 'aside': 'Aside', 'standard': 'Standard', 'link': 'Link', 'chat': 'Chat', 'video': 'Video', 'audio': 'Audio', 'gallery': 'Gallery'},
'supported': ['aside', 'link', 'gallery', 'status', 'quote', 'image']}
"""
method_name = 'wp.getPostFormats'
def get_args(self, client):
args = super(GetPostFormats, self).get_args(client)
args += ({'show-supported': True},)
return args
class PublishPost(AuthParamsOffsetMixin, AuthenticatedMethod):
"""
Mark a blog post as published.
Parameters:
`post_id`: ID of the blog post to publish.
Returns: ID of the published blog post.
"""
method_name = 'mt.publishPost'
method_args = ('post_id',)