API#

Authentication#

Auth is a module that provides a simple authentication system for Flask.

auth base class#

Auth with other ways(e.g. github, etc)#

Blueprints#

This section lists our Blueprint APIs. A Blueprint is a way to organize a group of related views and other codes. Rather than registering views and other code directly with an application, they are registered with a blueprint. Then the blueprint is registered with the application when it is available in the factory function.

For more information see Modular Applications with Blueprints

Authentication#

Index#

Posts#

Config#

Exception#

exception breeze.exc.BreezeException(message)[source]#

Base class for all Breeze exceptions inherited from Exception

Attr

message (str): the exception message

exception breeze.exc.EmptyError(message)[source]#

Exception raised when a object is empty. inherited from breeze.exc.BreezeException

exception breeze.exc.InvalidUsage(message)[source]#

Exception raised when a user does not have permission to perform an action. inherited from breeze.exc.BreezeException

exception breeze.exc.PermissionError(message)[source]#

Exception raised when a user does not have permission to perform an action. inherited from breeze.exc.BreezeException

Models#

class breeze.models.Post(**kwargs)[source]#

Posts table on db

inherited from flask_sqlalchemy.SQLAlchemy

Methods

save(): save post to db delete(): delete post from db update(): update post from db

delete()[source]#

Delete post from db

save()[source]#

Save post to db

class breeze.models.Tag(**kwargs)[source]#
class breeze.models.User(**kwargs)[source]#

Users table on db

inherited from flask_sqlalchemy.SQLAlchemy

Raises

breeze.exc.EmptyError: if password is empty then raise this exception breeze.exc.PermissionError: if user not have permission to perform an action then raise this exception

Methods

save(): save user to db delete(): delete user from db update(): update user from db

Attributes

username (str): user username email (str): user email password (str): user password profile_image (str): user profile image

this is a url to the image and by default it is a gravatar image

check_password(password)[source]#

Check user password

Args

password (hash): User password to confirm delete

Returns

bool: True if password is correct, False otherwise

delete(confirm_password)[source]#

Delete user from db

Args

confirm_password (str): user password to confirm delete

Raises

breeze.exc.PermissionError

save()[source]#

Save user to db

Raises

breeze.exc.EmptyError

Utils#

breeze.utils.check_hash(hash, password)[source]#

Checks if a password matches a hash.

Args

password (str): password to check hash (bytes): hash to check

Returns

bool: True if the password matches the hash, False otherwise

Parameters
  • hash (bytes) –

  • password (str) –

Return type

Optional[bool]

breeze.utils.gen_random_string(length)[source]#

Generates a random string.

Args

length (int): length of the string

Returns

str: random string

Parameters

length (int) –

Return type

str

breeze.utils.get_current_time()[source]#

Returns the current time in UTC.

Returns

datetime.datetime

Return type

datetime

breeze.utils.get_image_from_gravatar(email)[source]#

Gets an image from gravatar.

first, this function Generate md5 of the user’s email and next returned this hash with gravatar URL

if this URL is not found(404) gravatar shows the default avatar else show self users avatar from gravatar

Args

email (str): email to get the image from gravatar

Returns

str: url to the image

Parameters

email (str) –

Return type

str

breeze.utils.normalise(string)[source]#

Normalise a string.

Args

string (str): input string

Returns

str: normalised string

Parameters

string (Optional[Union[str, bytes]]) –

Return type

str

breeze.utils.normalise_email(email)[source]#

check and normalise user emails

pattern:

a regex pattern to check for normalised email,

part of the pattern is the email domain:

  1. username(*username*@domain.ex)
    can be digested or litter::

    breeze1234

  2. domain(username@*domain*.ex)
    can be only litters::

    email

  3. extension(username@domain.*extension*)
    can only litter with 2, 3 or 4 length::

    com or io or wiki

if the user’s email matches the pattern return email

Args

email (str): input email

Returns

str: normalized email bool: flase if email is invalid or None

Parameters

email (Optional[str]) –

Return type

Union[str, bool]

breeze.utils.string_to_hash(string)[source]#

Converts a string to a hash.

Args

string (str): input string

Returns

str: hash of the string

Parameters

string (str) –

Return type

str