Shopyoapi

Shopyo has some api which eases your life

api.cmd

commandline utilities functions

api.cmd.clean(app)[source]

Deletes shopyo.db and migrations/ if present in current working directory. Deletes all __pycache__ folders starting from current working directory all the way to leaf directory.

Parameters

app (-) –

Returns

Return type

None

api.cmd.collectstatic(target_module=None)[source]

Copies module/static into /static/modules/module. In static it becomes like

static/
     modules/
         box_something/
             modulename
         modulename2
Parameters

target_module (str) – name of module, in alphanumeric-underscore, supports module or box__name/module

Returns

Return type

None

api.cmd.create_box(name)[source]

creates box with box_info.json

Parameters

name (str) – name of box, in alphanumeric-underscore

Returns

Return type

None

api.cmd.create_module(modulename, base_path=None)[source]

creates module with the structure defined in the modules section in docs

Parameters

modulename (str) – name of module, in alphanumeric-underscore

Returns

Return type

None

api.cmd.create_module_in_box(modulename, boxname)[source]

creates module with the structure defined in the modules section in docs in a box

Parameters
  • modulename (str) – name of module, in alphanumeric-underscore

  • boxname (str) – name of box, in alphanumeric-underscore

Returns

Return type

None

api.cmd.initialise()[source]

Create db, migrate, adds default users, add settings

Returns

Return type

None

api.database

api.database.autoload_models()[source]

Auto imports models from modules/ in desired file. Used so that flask_migrate does not miss models when migrating

Returns

Return type

None

api.enhance

api.enhance.base_context()[source]

Used to define global template values

Returns

copy of dictionary

Return type

dict

api.enhance.get_active_theme_dir()[source]
api.enhance.set_setting(key, value)[source]

api.file

api.file.absdiroffile(filepath)[source]

Gives absolute directory of file, normally expects __file__ as param

Parameters

filepath (str) – path of file

Returns

Absolute dir path of file

Return type

str

api.file.delete_file(path)[source]
api.file.get_folders(path)[source]
api.file.trycopy(source, dest, verbose=False)[source]

Non-ecursive copy of folder

Parameters
  • source (str) – source folder path

  • dest (str) – destination folder path

Returns

Return type

None

api.file.trycopytree(source, dest, verbose=False)[source]

Recursive copy of folder

Parameters
  • source (str) – source folder path

  • dest (str) – destination folder path

Returns

Return type

None

api.file.trymkdir(path, verbose=False)[source]

Creates dir at destination

Parameters

path (str) – path with folder already in

Returns

Return type

None

api.file.trymkfile(path, content, verbose=False)[source]

Creates file

Parameters
  • path (str) – path to create file with filename included

  • content (str) – file content

Returns

Return type

None

api.file.unique_filename(fname)[source]

api.forms

api.forms.flash_errors(form)[source]

Auto flash errors from WKHtml forms Reqwires base module or similar notification mechanism

Parameters

form (WKHtml form) –

Returns

Return type

None

api.html

Used on flash flash(notify_success(‘mail sent!’))

api.html.notify(message, alert_type='primary')[source]
Used with flash

flash(notify(‘blabla’))

Parameters
  • message (str) – message to be displayed

  • alert_type (str) – bootstrap class

Returns

Return type

None

api.html.notify_danger(message)[source]
api.html.notify_info(message)[source]
api.html.notify_success(message)[source]
api.html.notify_warning(message)[source]

api.info

api.info.printinfo()[source]

prints Shopyo copyright in ASCII art font

api.module

class api.module.ModuleHelp(dunderfile, dundername)[source]

Bases: object

context()[source]
get_self_static(filename)[source]
method(methodname)[source]
redirect_url(url, **kwargs)[source]
render(filename, **kwargs)[source]

.render(‘file.html’) renders file.html found in module/templates/module/file.html