gws.base.web.action

Handle dynamic assets.

An asset is a file located in a global or project-specific assets directory.

In order to access a project asset, the user must have read permission for the project itself.

When the Web application receives a webAsset request with a path argument, it first checks the project-specific assets directory, and then the global dir.

If the file is found, and its name matches gws.base.template.manager.TEMPLATE_TYPES, a respective Template object is generated on the fly and rendered. The renderer is passed a TemplateArgs object as an argument. The gws.Response object returned from rendering is passed back to the user.

If the file is not a template and matches the allowMime/denyMime filter, its content is returned to the user.

Source code: gws.base.web.action

Module Contents

class gws.base.web.action.TemplateArgs(*args, **kwargs)

Bases: gws.TemplateArgs

Asset template arguments.

project: gws.Project | None

Current project.

projects: list[gws.Project]

List of user projects.

req: gws.WebRequester

Requester object.

user: gws.User

Current user.

params: dict

Request parameters.

localeUid: str

Locale uid

class gws.base.web.action.Config

Bases: gws.base.action.Config

class gws.base.web.action.Props

Bases: gws.base.action.Props

class gws.base.web.action.AssetRequest(*args, **kwargs)

Bases: gws.Request

Command request.

path: str
class gws.base.web.action.AssetResponse(*args, **kwargs)

Bases: gws.Request

Command request.

content: str
mime: str
class gws.base.web.action.FileRequest(*args, **kwargs)

Bases: gws.Request

Command request.

preview: bool = False
modelUid: str
fieldName: str
featureUid: str
class gws.base.web.action.Object

Bases: gws.base.action.Object

Web action

api_asset(req: gws.WebRequester, p: AssetRequest) AssetResponse

Return an asset under the given path and project

http_asset(req: gws.WebRequester, p: AssetRequest) gws.ContentResponse
download(req: gws.WebRequester, p) gws.ContentResponse
file(req: gws.WebRequester, p: FileRequest) gws.ContentResponse
sys_asset(req: gws.WebRequester, p: AssetRequest) gws.ContentResponse