dennogumi/content/post/2010-07-25-ocs-and-kde-forums-work-continues.markdown
Luca Beltrame 64b24842b8
All checks were successful
continuous-integration/drone/push Build is passing
Update all posts to not show the header text
2021-01-13 00:05:30 +01:00

2.1 KiB

author categories comments date slug tags title omit_header_text disable_share wordpress_id
einar
KDE
Linux
true 2010-07-25T18:49:22Z ocs-and-kde-forums-work-continues
KDE
OCS
python
OCS and KDE Forums - work continues true true 787

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:

{{< highlight python >}}

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[0].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[0].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 {{< / highlight >}}

Feedback (especially on the API) welcome!