Shopyo api#
Shopyo has some api which eases your life
api.assets#
- api.assets.get_static(boxormodule, filename)[source]#
Generates url for static file, depending on debug mode being on or not
- Parameters
boxormodule (String) – box or module name e.g. box__default/auth or someothermodule/
filename (String) – path of the file inside the box or module
- Return type
URL for static file
api.constants#
api.database#
api.email#
This file email.py contains functions for sending text and html rendered emails asynchronously
- api.email.send_async_email(to, subject, template, from_email=None, **kwargs)[source]#
Sends email anachronously i.e the function is non blocking. Assume email template is valid i.e it can be rendered using flask’ render_template function and both .html and .txt email template files exits
- Parameters
to (String) – recipient of the email
subject (String) – subject of the email
template (String) – template file path to be used in email body
from_email (String, optional) – sender of the email. If not set MAIL_DEFAULT_SENDER is used from config.
api.enhance#
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.trycopy(source, dest, verbose=False)[source]#
Non-ecursive copy of folder
- Parameters
source (str) – source folder path
dest (str) – destination folder path
- 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
- Return type
None
- api.file.trymkdir(path, verbose=False)[source]#
Creates dir at destination
- Parameters
path (str) – path with folder already in
- 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
- Return type
None
- api.file.tryrmcache(dir_name, verbose=False)[source]#
removes all __pycache__ starting from directory dir_name all the way to leaf directory
- Parameters
dir_name (string) – path from where to start removing pycache
- api.file.tryrmfile(path, verbose=False)[source]#
tries to remove file path and output message to stdin or stderr. Path must point to a file
- Parameters
path (string) – path of the file to remove
- Returns
returns true upon successful removal false otherwise
- Return type
bool
api.forms#
api.html#
Used on flash flash(notify_success(‘mail sent!’))
api.models#
DB-related helper utilities. Taken from database.py file at https://github.com/cookiecutter-flask/cookiecutter-flask
- class api.models.CRUDMixin[source]#
Bases:
object
Mixin that adds convenience methods for CRUD (create, read, update, delete) operations.
- classmethod create(**kwargs)[source]#
Create a new record and save it in the database.
- Returns
returns the created record
- Return type
DB Class Object
- delete(commit=True)[source]#
Remove the record from the database.
- Parameters
commit (bool, optional) – flag whether to commit. Defaults to True.
- Returns
returns the updated record if committed, None otherwise
- Return type
Db Class object
- class api.models.PkModel(**kwargs: Any)[source]#
Bases:
api.models.YoModel
Base model class that includes CRUD convenience methods, plus adds a ‘primary key’ column named ‘id’.
- classmethod create(**kwargs)#
Create a new record and save it in the database.
- Returns
returns the created record
- Return type
DB Class Object
- delete(commit=True)#
Remove the record from the database.
- Parameters
commit (bool, optional) – flag whether to commit. Defaults to True.
- Returns
returns the updated record if committed, None otherwise
- Return type
Db Class object
- classmethod get_by_id(record_id)[source]#
Get record by ID.
- Parameters
record_id (int) – ID of record to get
- Returns
object identified by record_id if any, None otherwise
- Return type
DB Class object
- id = Column(None, Integer(), table=None, primary_key=True, nullable=False)#
- metadata = MetaData()#
- query: t.ClassVar[Query]#
A SQLAlchemy query for a model. Equivalent to
db.session.query(Model)
. Can be customized per-model by overridingquery_class
.Warning
The query interface is considered legacy in SQLAlchemy. Prefer using
session.execute(select())
instead.
- query_class#
alias of
flask_sqlalchemy.query.Query
- registry = <sqlalchemy.orm.decl_api.registry object>#
- save(commit=True)#
Save the record.
- Parameters
commit (bool, optional) – flag whether to commit. Defaults to True.
- Returns
returns the record saved to db session
- Return type
Db Class object
- update(commit=True, **kwargs)#
Update specific fields of a record
- Parameters
commit (bool, optional) – flag whether to commit. Defaults to True.
- Returns
returns the updated record if committed, None otherwise
- Return type
Db Class object
- class api.models.YoModel(**kwargs: Any)[source]#
Bases:
api.models.CRUDMixin
,sqlalchemy.orm.decl_api.Model
Base model class that includes CRUD convenience methods.
- classmethod create(**kwargs)#
Create a new record and save it in the database.
- Returns
returns the created record
- Return type
DB Class Object
- delete(commit=True)#
Remove the record from the database.
- Parameters
commit (bool, optional) – flag whether to commit. Defaults to True.
- Returns
returns the updated record if committed, None otherwise
- Return type
Db Class object
- metadata = MetaData()#
- query: t.ClassVar[Query]#
A SQLAlchemy query for a model. Equivalent to
db.session.query(Model)
. Can be customized per-model by overridingquery_class
.Warning
The query interface is considered legacy in SQLAlchemy. Prefer using
session.execute(select())
instead.
- query_class#
alias of
flask_sqlalchemy.query.Query
- registry = <sqlalchemy.orm.decl_api.registry object>#
- save(commit=True)#
Save the record.
- Parameters
commit (bool, optional) – flag whether to commit. Defaults to True.
- Returns
returns the record saved to db session
- Return type
Db Class object
- update(commit=True, **kwargs)#
Update specific fields of a record
- Parameters
commit (bool, optional) – flag whether to commit. Defaults to True.
- Returns
returns the updated record if committed, None otherwise
- Return type
Db Class object