Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4872
basic_edit_test.py
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 10:10 PM
2014-11-21 22:10:23 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
basic_edit_test.py
View Options
import
sys
,
os
if
len
(
sys
.
argv
)
>
3
:
sys
.
path
.
append
(
os
.
path
.
abspath
(
sys
.
argv
[
3
]))
if
len
(
sys
.
argv
)
<
3
:
print
'python basic_edit_test.py <config> <prefix> [<include path>]'
print
sys
.
exit
()
## Create a config file containing:
# host = 'test.wikipedia.org'
# path = '/w/'
# ext = '.php'
# username = 'Bryan'
# password = 'xyz'
prefix
=
sys
.
argv
[
2
]
#import cgitb; cgitb.enable(format = 'text')
try
:
import
apiedit
as
mwclient
except
ImportError
:
import
mwclient
site
=
mwclient
.
ex
.
ConfiguredSite
(
sys
.
argv
[
1
])
site
.
compress
=
False
print
'Running configured site'
,
sys
.
argv
[
1
]
print
'Site has writeapi:'
,
getattr
(
site
,
'writeapi'
,
False
)
page
=
site
.
Pages
[
prefix
+
'/text1'
]
print
'Editting page1'
page
.
edit
()
text1
=
u"""== [[Test page]] ==
This is a [[test]] page generated by [http://mwclient.sourceforge.org/ mwclient].
This test is done using the [[w:mw:API]]."""
comment1
=
'Test page1'
page
.
save
(
text1
,
comment1
)
rev
=
page
.
revisions
(
limit
=
1
,
prop
=
'timestamp|comment|content'
)
.
next
()
assert
rev
[
'comment'
]
==
comment1
,
rev
assert
rev
[
'*'
]
==
rev
[
'*'
],
rev
print
'Page editted on'
,
rev
[
'timestamp'
]
print
'Links:'
,
list
(
page
.
links
(
generator
=
False
))
print
'External links:'
,
list
(
page
.
extlinks
())
print
'Done'
File Metadata
Details
Attached
Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4436
Default Alt Text
basic_edit_test.py (1 KB)
Attached To
Mode
T16443: successful edit causes server to return HTTP 500
Attached
Detach File
Event Timeline
Log In to Comment