AnyBlok / Pyramid framework¶
anyblok_pyramid.pyramid_config¶
-
class
anyblok_pyramid.pyramid_config.
Configurator
(*args, **kwargs) Bases:
pyramid.config.Configurator
Overwrite the Pyramid Configurator
-
default_setting
() Call all the entry point
anyblok_pyramid.settings
to update the argument settingthe callable need to have one parametter, it is a dict:
def settings_callable(setting): ...
We add the entry point by the setup file:
setup( ..., entry_points={ 'anyblok_pyramid.settings': [ settings_callable=path:settings_callable, ... ], }, ..., )
-
include_from_entry_point
() Call all the entry point
anyblok_pyramid.includeme
to update the pyramid configurationthe callable need to have one parametter(the instance of
Configurator
class, self):def config_callable(config): config.include(...)
We add the entry point by the setup file:
setup( ..., entry_points={ 'anyblok_pyramid.includeme': [ config_callable=path:config_callable, ... ], }, ..., )
-
load_config_bloks
() loop on each blok, keep the order of the blok to load the pyramid config. The blok must declare the meth
pyramid_load_config
:def pyramid_load_config(config): config.add_route('hello', '/hello/{name}/') ...
-
-
class
anyblok_pyramid.pyramid_config.
AnyBlokRequest
(request) Bases:
object
Add anyblok properties in the request
request.anyblok
-
registry
Add the property registry
registry = request.anyblok.registry
Note
The db_name must be defined
-
-
class
anyblok_pyramid.pyramid_config.
InstalledBlokPredicate
(blok_name, config) Bases:
object
Predicate
installed_blok
pyramid_config.settings¶
-
anyblok_pyramid.pyramid_config.
pyramid_settings
(settings) Add in settings the default value for pyramid configuration
Parameters: settings – dict of the existing settings
pyramid_config.includeme¶
-
anyblok_pyramid.pyramid_config.
static_paths
(config) Pyramid includeme, add the static path of the blok
Parameters: config – Pyramid configurator instance
anyblok_pyramid.adapter module¶
-
anyblok_pyramid.adapter.
datetime_adapter
(obj, request) Format the fields.DateTime to return String
If the datetime hasn’t any timezone, force the timezone by the server timezone
from pyramid.renderers import JSON from datetime import datetime json_renderer = JSON() json_renderer.add_adapter(datetime, datetime_adapter) config.add_renderer('json', json_renderer)
Parameters: obj – datetime obj Return type: str, isoformat datetime
-
anyblok_pyramid.adapter.
date_adapter
(obj, request) Format the fields.Date to return String
from pyramid.renderers import JSON from datetime import date json_renderer = JSON() json_renderer.add_adapter(date, date_adapter) config.add_renderer('json', json_renderer)
Parameters: obj – datetime obj Return type: str, isoformat datetime
-
anyblok_pyramid.adapter.
uuid_adapter
(obj, request) Format the fields.UUID to return String
from pyramid.renderers import JSON from uuid import UUID json_renderer = JSON() json_renderer.add_adapter(UUID, uuid_adapter) config.add_renderer('json', json_renderer)
Parameters: obj – uuid obj Return type: str
-
anyblok_pyramid.adapter.
bytes_adapter
(obj, request) Format the fields.Binary to return String
from pyramid.renderers import JSON json_renderer = JSON() json_renderer.add_adapter(bytes, bytes_adapter) config.add_renderer('json', json_renderer)
Parameters: obj – bytes Return type: str
-
anyblok_pyramid.adapter.
decimal_adapter
(obj, request) Format the fields.Decimal to return String
from pyramid.renderers import JSON json_renderer = JSON() json_renderer.add_adapter(Decimal, decimal_adapter) config.add_renderer('json', json_renderer)
Parameters: obj – Decimal Return type: str
anyblok_pyramid.scripts module¶
-
anyblok_pyramid.scripts.
wsgi
() Simple Pyramid wsgi server for development purpose
-
anyblok_pyramid.scripts.
gunicorn_wsgi
() console script function to run anyblok / pyramid with gunicorn
anyblok_pyramid.security module¶
-
anyblok_pyramid.security.
group_finder
(userid, request) Return groups from user ID
Parameters: - userid – the user id (login)
- request – request from pyramid
-
anyblok_pyramid.security.
check_user
(userid, password, request) Return groups from user ID
Parameters: - userid – the user id (login)
- request – request from pyramid
-
anyblok_pyramid.security.
AnyBlokResourceFactory
(resource) Return a factory to get ACL in function of the resource
The factory use the method Pyramid.get_acl to define the real ACL, if the user is not authenticated, the access is denied
Pyramid defined hooks to connect any User model
Parameters: resource – str, resource’s name Return type: class, inherit RootFactory, with ACL in function of resource
-
class
anyblok_pyramid.security.
RootFactory
(request) This RootFactory need to be used with AnyBlokResourceFactory
The goal of the root factory is to add the anyblok registry in the request for AnyBlokResourceFactory