Skip to main content

Connector for Flask with phpBB3 board

Project description

Flask-phpBB3
============

Connector for Flask with phpBB3. Do note, this connector does not use any caches
and is *read-only*.

Supported drivers
-----------------

* Direct access

+ psycopg2 - direct access to PostgreSQL

Supported phpBB3 versions
-------------------------

* 3.1.x

Configuration
-------------

To configure this extension, you have to specify PHPBB3 and one of access modes
configs. All of them are dicts.

Settings
++++++++++++++++

* PHPBB3

+ **DRIVER** - Which driver to use (see `Supported drivers`_)
+ **VERSION** - Which version of phpBB3 (see `Supported phpBB3 versions`_)

* PHPBB3_DATABASE - These settings are used when using direct access drivers

+ **HOST** - Database host, default is 127.0.0.1
+ **DATABASE** - Database name, default is phpbb3
+ **USER** - User for connecting to database, default is phpbb3
+ **PASSWORD** - Database user's password, default is empty
+ **TABLE_PREFIX** - Table prefix of phpBB3 tables, default is phpbb\_
+ **CUSTOM_USER_FIELDS** - List of custom fields setup in phpBB3 forum
+ **CUSTOM_STATEMENTS** - Dictionary of prepared statements to add or
override. **Careful** with raw queries, use
`{TABLE_PREFIX}` to re-use configured prefix

* PHPBB3_SESSION_BACKEND - Setting up session backend, it configures the werkzeug cache subsystem

+ **TYPE** - Type of the cache, *simple* or *memcached*
+ **SERVERS** - A list/tuple of Memcached servers ('host:pair', ...)
+ **KEY_PREFIX** - Key prefix used with all keys

* **PHPBB3_COOKIE_NAME** - Sets prefix of session cookie names, default is
phpbb3\_

Example
+++++++

.. code:: python

PHPBB3 = {
'DRIVER': 'psycopg2',
}
PHPBB3_DATABASE = {
'DATABASE': 'mydb',
'USER': 'myuser',
}

API
---

Usage of this connector is simple, just create it as any extension
::

phpbb3 = PhpBB3(app)

And in your views just call the apropriate API call:

.. code:: python

@app.route('/my/view')
def view(...):
# ...
latest_posts = phpbb3.fetch_latest_posts()
# ...

**IMPORTANT:** Use only keyword paramaters!

Predefined prefixes
-------------------

A prefix of a function can define it's behaviour if declared with SQL query.

get\_
+++++

It will return only one value or None.

fetch\_
+++++++

Returns a list. If defining your own functions, do not use OFFSET and LIMIT, it will
be appended by the extension.

has\_
+++++

Returns a bool, true or false. Query must return a single value!

Common keyword arguments
------------------------

With all prepared queries, you may use cache (True/False) and cache_ttl arguments to control
result caching. TTL is specified in seconds.

List of functions
-----------------

get_autologin(key)
++++++++++++++++++

Gets autologin information. Used by session integration.

get_session(session_id)
+++++++++++++++++++++++

Gets user session. Usable for integrating with phpBB3 sessions.

Remember to check user id and session id! Currenlty only database session storage is
supported.

get_user(user_id)
+++++++++++++++++

Gets user settings and profile.

Use string named interpolation format (the psycopg one) to specify kwargs of a function.
Do not forget to use {TABLE_PREFIX} variable, to add specific table prefix. (First, the
python variables from config get evaluated, and then psycopg variables).

has_membership(user_id, group_id)
+++++++++++++++++++++++++++++++++

Checks if user belongs to a group.

has_membership_resolve(user_id, group_name)
+++++++++++++++++++++++++++++++++++++++++++

Same as has_membership, only it works with group name.

fetch_acl_options()
+++++++++++++++++++

Fetches ACL data. Used by session integration.

get_unread_notifications_count(user_id)
+++++++++++++++++++

Retrieves user's unread notifications count. Used by session integration.

Sessions integration
--------------------

When using this extension, it will install it's own session interface. Also, all properties
not present in phpBB3 session, will be stored in session backend.

And you can use session's **is_authenticated** property to test if user is authenticated.

.. code:: python

from flask import session

# ...

if session.is_authenticated:
print 'User is authenticated!'

Available is also the following API:
* is_member(group) - group may be id of the group or name
* has_privilege(option, forum_id=0) - tests if user has specified privilege
* has_privileges(*options, forum_id=0) - same as has_privilege, but for multiple privileges
* get_link_hash(link) - calculates hash
* num_unread_notifications - number of unread notifications for session user

Caching
-------

By default, it configures werkzeug's cache using the configuration set in PHPBB3_SESSION_BACKEND.
If you are using Flask-cache extension, you may pass it along when instantiating this extension
to use the common cache using the keyword parameter **cache**.



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-phpBB3-0.2.1.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flask_phpBB3-0.2.1-py2.py3-none-any.whl (13.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file Flask-phpBB3-0.2.1.tar.gz.

File metadata

  • Download URL: Flask-phpBB3-0.2.1.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for Flask-phpBB3-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a8351ad86d0fa48c86c03416f45c73e75b7b2dbbdfed35b0fe0cf84aa2596c45
MD5 73d392e5351cc5ee88b2d72605a93b5f
BLAKE2b-256 37d9b9e9a39b39210cfc062ff6e40c4cbd9b664776963aaa7fc0a44c5dbfc3c7

See more details on using hashes here.

File details

Details for the file Flask_phpBB3-0.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: Flask_phpBB3-0.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for Flask_phpBB3-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a59d88ba5bcc842ee904baf12014c789e90ff08f466b6053110a9918d1bb01d5
MD5 5cef7f639ee74ee04c475e01b3989e61
BLAKE2b-256 aefd9fa10da395bc98e583836b1257b1298688cfe1fe198ebef956f53f839712

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page