OCS and KDE Forums - work continues
By einar- Comments
With my last entry, I announced the start of the work for an OCS library for the KDE Community Forums. Today I’d like to blog again about the recent developments.
First of all, now there isn’t one, but two Python modules:
- _ocslib, _ a pure Python module that can be used to interface with OCS-based forum systems;
- ocslibkde, a PyKDE4 based module that can be used to interface with OCS-based forum system in KDE applications.
Currently ocslib supports reading and posting, while ocslibkde only reading (as of now). Both can be retrieved from the kde-forum-mods repository under the ocs-client subdirectory. The Python lib needs unit-testing, then I’ll be able to push a tarball soon for people to test (but you can always check out the Git repository). With regards to the PyKDE4 library, I plan on making a proof-of-concept plasmoid soon that shows how to use the API.
Speaking of API, here are some examples using ocslib:
>>> from ocslib import service# Connect to OCS >>> ocs_service = ocslib.service.OCService("http://www.example.com") #Retrieve all forums >>> forums = ocs_service.list_forums() # Elements have attributes for name, posts, etc. >>> print forums.name "Test forum" #Retrieve threads for forum 15 >>> threads = ocs_service.list_forum_threads(forum_id=15) # Retrieve thread 8945 from forum 15 >>> messages = ocs_service.show_thread(forum_id=15, topic_id=8945) >>> print messages.text "Hello world! #Post to a forum - requires authentication >>> ocs_service = service.OCService("http://www.example.com", username="foo", password="bar") >>> message = "Hello, KDE people!" >>> subject = "Test message" >>> ocs_service.post(forum_id=15, subject=subject, message=message) True # Return code of operation
Feedback (especially on the API) welcome!