dp-tornado

MVC Web Application Framework with Tornado, Python 2 and 3

Environment Setup

Virtualenv:

$ pip install virtualenv
$ virtualenv ./venv
$ . ./venv/bin/activate

Install dp-tornado:

$ pip install dp-tornado

Run

Startup:

$ dp4p init app_dir
$ dp4p run app_dir

or:

$ dp4p init --path app_dir --template=bbs
$ dp4p run --path app_dir --template=bbs

or:

$ mkdir app_dir
$ cd app_dir
$ dp4p init
$ dp4p run

with Docker:

$ docker pull why2pac/dp4p:latest-py34  # py27, py34, py35, pypy27
$ docker run --name "dp4p-example" -d -p 8080:52848 -v "$(pwd)/app_dir:/data/app" why2pac/dp4p:latest-py34

Documentation

MVC

Warning

This package is not documented yet.

engine.model — Model of MVC

Warning

This package is not documented yet.

The model directly manages the data, logic, and rules of the application. <Wikipedia>

Here is a foo_bar model example:

from dp_tornado.engine.model import Model as dpModel

class FooBarModel(dpModel):
    def func1(self):
        """
        assert self.helper.foo.func1(10, 20) == None
        """
        return None

    def func2(self, a):
        """
        assert self.helper.foo.func2(10) == 10
        """
        return a

    def func3(self, a, b):
        """
        assert self.helper.foo.func3(10, 20) == 30
        """
        return a + b
File/Class Invoke rules
  • /model/__init__.py, DO NOT IMPLEMENT ANY CODE IN THIS FILE
  • /model/blog/__init__.py, BlogModel > model.blog
  • /model/blog/admin/__init__.py, AdminModel > model.blog.admin
  • /model/blog/post.py, PostModel > model.blog.post
  • /model/blog/view.py, ViewModel > model.blog.view
  • /model/foo_bar.py, FooBarModel > model.foo_bar
Method Invoke rules
  • /model/foo.py, def func1(self): model.foo.func1()
  • /model/foo.py, def func2(self, a): model.foo.func2(a)
  • /model/foo.py, def func3(self, a, b): model.foo.func3(a, b)
class dp_tornado.engine.model.InValueModelConfig(driver=None, database=None, host=None, user=None, password=None, port=None, path=None, pure=None)[source]

Bases: object

class dp_tornado.engine.model.Model(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.engine.Engine, dp_tornado.engine.loader.Loader

begin(dsn_or_conn)[source]
static caching(*args, **kwargs)[source]
static clear_cached(method, *args, **kwargs)[source]
close(proxy)[source]
commit(proxy, return_connection=True)[source]
execute(sql, bind=None, dsn_or_conn=None)[source]
static renew_cached(method, *args, **kwargs)[source]
rollback(proxy, return_connection=True)[source]
row(sql, bind=None, dsn_or_conn=None, *args, **kwargs)[source]
rows(sql, bind=None, dsn_or_conn=None, *args, **kwargs)[source]
static run_alone(*args, **kwargs)[source]
scalar(sql, bind=None, dsn_or_conn=None)[source]
class dp_tornado.engine.model.ModelProxy(connection, transaction)[source]

Bases: object

close()[source]
commit(return_connection=True)[source]
connection
execute(sql, bind=None, dsn_or_conn=None)[source]
rollback(return_connection=True)[source]
row(sql, bind=None, dsn_or_conn=None)[source]
rows(sql, bind=None, dsn_or_conn=None)[source]
scalar(sql, bind=None, dsn_or_conn=None)[source]
transaction
class dp_tornado.engine.model.ModelSingleton[source]

Bases: dp_tornado.engine.engine.Engine, dp_tornado.engine.singleton.Singleton

begin(dsn_or_conn, cache=False)[source]
close(proxy)[source]
commit(proxy, return_connection=True)[source]
engine(config_dsn, cache=False)[source]
engines
execute(sql, bind=None, dsn_or_conn=None, cache=False)[source]
getconn(config_dsn, cache=False)[source]
rollback(proxy, return_connection=True)[source]
row(sql, bind=None, dsn_or_conn=None, cache=False, *args, **kwargs)[source]
rows(sql, bind=None, dsn_or_conn=None, cache=False, *args, **kwargs)[source]
scalar(sql, bind=None, dsn_or_conn=None, cache=False)[source]

engine.view — View of MVC

Warning

This package is not documented yet.

A view can be any output representation of information, such as a chart or a diagram. <Wikipedia>

Here is a view example:

from dp_tornado.engine.controller import Controller

class FooBarController(Controller):
    def get(self):
        self.render('index.html')
class dp_tornado.engine.view.Dummy[source]

Bases: object

class dp_tornado.engine.view.View[source]

Bases: dp_tornado.engine.singleton.Singleton

static finish(controller, chunk=None)[source]
static render(controller, template_name, kwargs=None)[source]
static render_string(controller, template_name, kwargs=None, encode=True)[source]
static write(controller, chunk)[source]

engine.controller — Controller of MVC

Warning

This package is not documented yet.

Controller Accepts input and converts it to commands for the model or view. <Wikipedia>

Here is a foo_bar controller example:

from dp_tornado.engine.controller import Controller

class FooBarController(Controller):
    def get(self):
        self.finish('done')
Directory/File and URL Mapping rules
  • /controller/__init__.py, StarterController > /
  • /controller/blog/__init__.py, BlogController > /blog
  • /controller/blog/admin/__init__.py, AdminController > /blog/admin
  • /controller/blog/post.py, PostController > /blog/post
  • /controller/blog/view.py, ViewController > /blog/view
  • /controller/foo_bar.py, FooBarController > /foo_bar
Class/Method and URL Mapping rules
  • /controller/foo.py, def get(self): GET /foo
  • /controller/foo.py, def get(self, a): GET /foo/{path}
  • /controller/foo.py, def get(self, a, b): GET /foo/{path}/{path}
  • /controller/foo.py, def get(self, a, b=None): GET /foo/{path}/{path} and GET /foo/{path}
  • /controller/foo.py, def post(self): POST /foo
  • /controller/foo.py, def put(self): PUT /foo
  • /controller/foo.py, def delete(self): DELETE /foo
  • /controller/foo.py, def head(self): HEAD /foo
  • /controller/foo.py, def patch(self): PATCH /foo
class dp_tornado.engine.controller.Controller(application, request, **kwargs)[source]

Bases: dp_tornado.engine.engine.Engine

Base class for HTTP request.

cookie(name, value=None, **kwargs)[source]
finish(chunk=None)[source]
finish_with_error(status_code, message='An error has occurred')[source]
get_argument(name, default=None, strip=True, cast=None, fmt=None, lrange=None, delimiter=None, value=None, **ext)[source]
get_session_value(name, expire_in=None, sessionid=None)[source]
get_session_value_ttl(name)[source]
get_sessionid()[source]
get_user_agent(parsed=True, user_agent=None)[source]
initialize(prefix, parent=None)[source]
m17n_lang(lang=None)[source]
prefixize(url)[source]
redirect(url, prefixize=False, permanent=False, status=None, safe=False)[source]
remote_ip
render(template_name, kwargs=None)[source]
render_string(template_name, kwargs=None)[source]
request
request_uri(*args, **kwargs)[source]
static route(path)[source]
session(name, value=None, expire_in=<dp_tornado.engine.controller.NoneValue object>)[source]
set_header(name, value)[source]
set_session_value(name, value, expire_in=<dp_tornado.engine.controller.NoneValue object>)[source]
set_sessionid(sessionid=None)[source]
write(chunk)[source]
class dp_tornado.engine.controller.NoneValue[source]

Bases: object

INI

Warning

This package is not documented yet.

Config

Warning

This package is not documented yet.

Here is a foo_bar config example:

from dp_tornado.engine.config import Config


class FooBarConfig(Config):
    def index(self):
        self.conf.value_str = 'string'
        self.conf.value_int = 10
        self.conf.value_dict = {
            'foo': 100,
            'bar': {
                'baz': 200,
                'baf': 300
            }
        }

        self.conf.databases = {
            'drv_sqlite_name': {
                'driver': 'sqlite'
            },
            'drv_mysql_name': {
                'driver': 'mysql+cymysql',
                'database': '',
                'host': '127.0.0.1',
                'port': 3306,
                'user': 'root',
                'password': '',
                'pool_size': 1,
                'charset': 'utf8'
            }
        }

        self.conf.caches = {
            'drv_sqlite_name': {
                'driver': 'memory',
                'identifier': 'dp_test_sqlite'
            },
            'drv_redis_name': {
                'driver': 'redis',
                'host': '127.0.0.1',
                'port': 6379,
                'password': None,
                'maxconn': 256
            }
        }

File/Class Invoke rules

  • /config/__init__.py, DO NOT IMPLEMENT ANY CODE IN THIS FILE
  • /config/blog/__init__.py, BlogConfig > config.blog
  • /config/blog/admin/__init__.py, AdminConfig > config.blog.admin
  • /config/blog/post.py, PostConfig > config.blog.post
  • /config/blog/view.py, ViewConfig > config.blog.view
  • /config/foo_bar.py, FooBarConfig > config.foo_bar

Config Invoke rules

  • /config/foo_bar.py, self.conf.value_str: config.foo_bar.value_str == ‘string’
  • /config/foo_bar.py, self.conf.value_int: config.foo_bar.value_int == 10
  • /config/foo_bar.py, self.conf.value_dict: config.foo_bar.value_dict.foo == 100
  • /config/foo_bar.py, self.conf.value_dict: config.foo_bar.value_dict.bar.baz == 200
  • /config/foo_bar.py, self.conf.value_dict: config.foo_bar.value_dict.bar.baf == 300
  • /config/foo_bar.py, self.conf.databases: ‘foo_bar/drv_sqlite_name’
  • /config/foo_bar.py, self.conf.databases: ‘foo_bar/drv_mysql_name’
  • /config/foo_bar.py, self.conf.databases: ‘foo_bar/drv_sqlite_name’
  • /config/foo_bar.py, self.conf.databases: ‘foo_bar/drv_redis_name’

Helper

Here is a foo_bar helper example:

from dp_tornado.engine.helper import Helper as dpHelper

class FooHelper(dpHelper):
    def func1(self):
        """
        assert self.helper.foo.func1(10, 20) == None
        """
        return None

    def func2(self, a):
        """
        assert self.helper.foo.func2(10) == 10
        """
        return a

    def func3(self, a, b):
        """
        assert self.helper.foo.func3(10, 20) == 30
        """
        return a + b

File/Class Invoke rules

  • /helper/__init__.py, DO NOT IMPLEMENT ANY CODE IN THIS FILE
  • /helper/blog/__init__.py, BlogHelper > helper.blog
  • /helper/blog/admin/__init__.py, AdminHelper > helper.blog.admin
  • /helper/blog/post.py, PostHelper > helper.blog.post
  • /helper/blog/view.py, ViewHelper > helper.blog.view
  • /helper/foo_bar.py, FooBarHelper > helper.foo_bar

Method Invoke rules

  • /helper/foo.py, def func1(self): helper.foo.func1()
  • /helper/foo.py, def func2(self, a): helper.foo.func2(a)
  • /helper/foo.py, def func3(self, a, b): helper.foo.func3(a, b)

helper.datetime — Manipulate datetime

Warning

This package is not documented yet.

class dp_tornado.helper.datetime.DatetimeHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

convert(auto=None, datetime=None, timezone=None, timestamp=None, yyyymmdd=None, yyyymmddhhiiss=None, ms=False)[source]
from_datetime(datetime, timezone=None)[source]
from_timestamp(timestamp, timezone=None, ms=False)[source]
now(timezone=None)[source]
transform(anonymous)[source]
tuple(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
helper.datetime.date — Manipulate date

Warning

This package is not documented yet.

class dp_tornado.helper.datetime.date.DateHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

convert(auto=None, datetime=None, timezone=None, timestamp=None, yyyymmdd=None, yyyymmddhhiiss=None, ms=False)[source]
day(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
from_datetime(datetime, timezone=None)[source]
from_timestamp(timestamp, timezone=None, ms=False)[source]
mmdd(auto=None, datetime=None, timezone=None, timestamp=None, ms=False, concat='')[source]
month(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
now(timezone=None)[source]
tuple(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
weekday(auto=None, datetime=None, timezone=None, timestamp=None, ms=False, isoweekday=True)[source]
year(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
yyyymmdd(auto=None, datetime=None, timezone=None, timestamp=None, ms=False, concat='')[source]
helper.datetime.time — Manipulate time

Warning

This package is not documented yet.

class dp_tornado.helper.datetime.time.TimeHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

convert(auto=None, datetime=None, timezone=None, timestamp=None, yyyymmdd=None, yyyymmddhhiiss=None, ms=False)[source]
hhii(auto=None, datetime=None, timezone=None, timestamp=None, ms=False, concat='')[source]
hhiiss(auto=None, datetime=None, timezone=None, timestamp=None, ms=False, concat='')[source]
hour(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
minute(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
second(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
tuple(auto=None, datetime=None, timezone=None, timestamp=None, ms=False)[source]
helper.datetime.timestamp — Manipulate timestamp

Warning

This package is not documented yet.

class dp_tornado.helper.datetime.timestamp.TimestampHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

convert(auto=None, datetime=None, timezone=None, timestamp=None, yyyymmdd=None, yyyymmddhhiiss=None, ms=False)[source]
from_datetime(datetime, ms=False)[source]
mktime(year=1970, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, ms=False)[source]
now(ms=False)[source]
to_datetime(*args, **kwargs)[source]
tommorow(auto=None, timestamp=None, datetime=None, timezone=None, yyyymmdd=None, yyyymmddhhiiss=None, ms=False)[source]
yesterday(auto=None, timestamp=None, datetime=None, timezone=None, yyyymmdd=None, yyyymmddhhiiss=None, ms=False)[source]
helper.datetime.timezone — Manipulate timezone

Warning

This package is not documented yet.

class dp_tornado.helper.datetime.timezone.TimezoneHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

localize(datetime, timezone)[source]
normalize(datetime, timezone)[source]
tzinfo_from_datetime(datetime)[source]
tzinfo_from_zone(zone)[source]
zone_from_datetime(datetime)[source]
zone_from_tzinfo(zone)[source]

helper.io — IO

Warning

This package is not documented yet.

class dp_tornado.helper.io.IoHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.io.file — File

Warning

This package is not documented yet.

class dp_tornado.helper.io.file.FileHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

compare(*files)[source]
remove(files_or_dirs=None, files=None, dirs=None)[source]
write(path, content, mode='w')[source]
helper.io.file.zip — ZIP

Warning

This package is not documented yet.

class dp_tornado.helper.io.file.zip.ZipHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

archive(destfile, srcfiles, mode='w', compression=0, allowZip64=False)[source]
unarchive(srcfile, destpath, mode='r', compression=0, allowZip64=False)[source]
helper.io.path — Path

Warning

This package is not documented yet.

class dp_tornado.helper.io.path.PathHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

browse(path, fullpath=True, recursive=False, appendpath=None, conditions=None)[source]
cwd()[source]
dirname(path)[source]
ext(path, dot='.')[source]
is_dir(path)[source]
is_file(path)[source]
join(path, *paths)[source]
mkdir(path, mode=None)[source]
split(path)[source]
helper.io.path.sys — SYS

Warning

This package is not documented yet.

class dp_tornado.helper.io.path.sys.SysHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

append(x)[source]
insert(i, x)[source]
helper.io.image — Image

Warning

This package is not documented yet.

class dp_tornado.helper.io.image.ImageHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

border(src, options=None, **o_kwargs)[source]
colorize(src, options=None, **o_kwargs)[source]
compare(i1, i2, error=0)[source]
crop(src, options=None, **o_kwargs)[source]
execute(src, fn, options=None, **kwargs)[source]
load(src, options=None, **kwargs)[source]
manipulate(src, options=None, **kwargs)[source]
radius(src, options=None, **o_kwargs)[source]
resize(src, options=None, **o_kwargs)[source]
save(src, options=None, **o_kwargs)[source]
size(src, options=None, **o_kwargs)[source]
helper.io.image.mode — Image Mode

Warning

This package is not documented yet.

class dp_tornado.helper.io.image.mode.ModeHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

center
fill
modes
resize

helper.locale — Localization

Warning

This package is not documented yet.

class dp_tornado.helper.locale.LocaleHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.locale.country — Country

Warning

This package is not documented yet.

class dp_tornado.helper.locale.country.CountryHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

available_countries
south_korea
helper.locale.korea — Korea

Warning

This package is not documented yet.

class dp_tornado.helper.locale.korea.KoreaHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

readable_phone_number(number, separator='-')[source]
validate_phone_number(number)[source]
weekday(w, short=False, isoweekday=True)[source]

helper.misc — Miscellaneous functions

Warning

This package is not documented yet.

class dp_tornado.helper.misc.MiscHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.misc.performance — Performance

Warning

This package is not documented yet.

class dp_tornado.helper.misc.performance.PerformanceHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

start(log_prefix='Time', enabled=True)[source]
class dp_tornado.helper.misc.performance.PerformanceMeasurement(log_prefix, enabled)[source]

Bases: object

lap(log_suffix='Lap', with_print=True)[source]
stop(log_suffix='Stop', with_print=True)[source]
helper.misc.system — System

Warning

This package is not documented yet.

class dp_tornado.helper.misc.system.SystemHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

py_version
helper.misc.type — Type

Warning

This package is not documented yet.

class dp_tornado.helper.misc.type.TypeHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

array
bool
dict
float
int
long
numeric
string
helper.misc.type.check — Type Checking

Warning

This package is not documented yet.

class dp_tornado.helper.misc.type.check.CheckHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

array(val)[source]
dict(val)[source]
numeric(val)[source]
string(val)[source]

helper.numeric — Manipulate numeric

class dp_tornado.helper.numeric.NumericHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

extract_numbers(string)[source]
from_xxx(x)[source]
int(a, raise_exception=True)[source]
long(a, raise_exception=True)[source]
number_format(value, tsep=', ', dsep='.')[source]
to_xxx(x)[source]
xxx
helper.numeric.cast — Type Cast

Warning

This package is not documented yet.

class dp_tornado.helper.numeric.cast.CastHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

float(a, raise_exception=False)[source]
int(a, raise_exception=False)[source]
long(a, raise_exception=False)[source]
helper.numeric.math — Math

Warning

This package is not documented yet.

class dp_tornado.helper.numeric.math.MathHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

ceil(x)[source]
floor(x)[source]
round(number, ndigits=None)[source]

helper.security — Security

Warning

This package is not documented yet.

class dp_tornado.helper.security.SecurityHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.security.crypto — Crypto

Warning

This package is not documented yet.

class dp_tornado.helper.security.crypto.CryptoHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

decrypt(encrypted, key=None, raw=False, encode=True, pad=True)[source]
encrypt(plain, randomized=False, expire_in=0, key=None, raw=False, encode=True, pad=True)[source]
helper.security.crypto.file — Encryption or Decryption for File

Warning

This package is not documented yet.

class dp_tornado.helper.security.crypto.file.FileHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.security.web — Web

Warning

This package is not documented yet.

class dp_tornado.helper.security.web.WebHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.security.web.csrf — CSRF Protection

Warning

This package is not documented yet.

class dp_tornado.helper.security.web.csrf.CsrfHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

generate_token(controller, token_length=32, token_expire_in=43200)[source]
verify_token(controller, key='csrf', value=None)[source]

helper.serialization — Serialization

Warning

This package is not documented yet.

class dp_tornado.helper.serialization.SerializationHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

deserialize(text, method='json', encoding='utf8', raise_exception=False)[source]

Alias of helper.string.serialization.deserialize

serialize(obj, method='json', beautify=False, raise_exception=False)[source]

Alias of helper.string.serialization.serialize

helper.serialization.json — JSON

Warning

This package is not documented yet.

class dp_tornado.helper.serialization.json.JsonHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

parse(text, encoding='utf8', raise_exception=False)[source]

Alias of helper.string.serialization.json.parse

stringify(obj, beautify=False, raise_exception=False)[source]

Alias of helper.string.serialization.json.stringify

helper.string — Manipulate string

Warning

This package is not documented yet.

class dp_tornado.helper.string.StringHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

ascii_letters
ascii_lowercase
ascii_uppercase
digits
printable
punctuation
whitespace
helper.string.cast — Type Cast

Warning

This package is not documented yet.

class dp_tornado.helper.string.cast.CastHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

string(s, preserve_none=True)[source]
unicode(s, preserve_none=True)[source]
helper.string.check — Check

Warning

This package is not documented yet.

class dp_tornado.helper.string.check.CheckHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

alphabet(s, add=None)[source]
alphanumeric(s, add=None)[source]
alphanumericpunc(s, add=None)[source]
exist_repeated_text(s, criteria=3)[source]
numeric(s, add=None)[source]
helper.string.random — Random

Warning

This package is not documented yet.

class dp_tornado.helper.string.random.RandomHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

numeric(length)[source]
string(length)[source]
helper.string.serialization — Serialization

Warning

This package is not documented yet.

class dp_tornado.helper.string.serialization.SerializationHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

deserialize(text, method='json', encoding='utf8', raise_exception=False)[source]
serialize(obj, method='json', beautify=False, raise_exception=False)[source]
helper.string.serialization.json — JSON

Warning

This package is not documented yet.

class dp_tornado.helper.string.serialization.json.JsonHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

parse(text, encoding='utf8', raise_exception=False)[source]
stringify(obj, beautify=False, raise_exception=False)[source]

helper.validator — Validators

Warning

This package is not documented yet.

class dp_tornado.helper.validator.ValidatorHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.validator.email — E-Mail Validator

Warning

This package is not documented yet.

class dp_tornado.helper.validator.email.EmailHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

validate(e)[source]
helper.validator.form — Form Validator

Warning

This package is not documented yet.

class dp_tornado.helper.validator.form.FormHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

validate(controller, fields, error_res='json')[source]
helper.validator.phone — Phone Validator

Warning

This package is not documented yet.

class dp_tornado.helper.validator.phone.PhoneHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

validate(p, locale=None)[source]
helper.validator.url — URL Validator

Warning

This package is not documented yet.

class dp_tornado.helper.validator.url.UrlHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

validate(url)[source]

helper.web — Web

Warning

This package is not documented yet.

class dp_tornado.helper.web.WebHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.web.aws — AWS

Warning

This package is not documented yet.

class dp_tornado.helper.web.aws.AwsHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

helper.web.aws.dynamodb — AWS DynamoDB

Warning

This package is not documented yet.

class dp_tornado.helper.web.aws.dynamodb.DynamodbHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

client(access_key_id, secret_access_key, region_name)[source]
resource(access_key_id, secret_access_key, region_name)[source]
helper.web.aws.dynamodb.table — AWS DynamoDB Table

Warning

This package is not documented yet.

class dp_tornado.helper.web.aws.dynamodb.table.TableHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

create(access_key_id, secret_access_key, region_name, table_name, index_columns, read_capacity_units=1, write_capacity_units=1, wait_until_exists=True, **kwargs)[source]
describe(access_key_id, secret_access_key, region_name, table_name, wait_until_exists=True)[source]
get(access_key_id, secret_access_key, region_name, table_name, wait_until_exists=False)[source]
remove(access_key_id, secret_access_key, region_name, table_name, wait_until_not_exists=True)[source]
status(access_key_id, secret_access_key, region_name, table_name)[source]
wait_until(access_key_id, secret_access_key, region_name, table_name, exists, repeat=25, repeated=0, before_status=None)[source]
helper.web.aws.dynamodb.table.column — AWS DynamoDB Table - Column

Warning

This package is not documented yet.

class dp_tornado.helper.web.aws.dynamodb.table.column.ColumnHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

binary
number
string
helper.web.aws.dynamodb.table.indexing — AWS DynamoDB - Indexing

Warning

This package is not documented yet.

class dp_tornado.helper.web.aws.dynamodb.table.indexing.IndexingHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

hash
partition
range
sort
helper.web.aws.dynamodb.item — AWS DynamoDB Item

Warning

This package is not documented yet.

class dp_tornado.helper.web.aws.dynamodb.item.ItemHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

get(access_key_id, secret_access_key, region_name, table_name, keys)[source]
put(access_key_id, secret_access_key, region_name, table_name, items, overwrite_by_pkeys=None)[source]
query(access_key_id, secret_access_key, region_name, table_name, count=False, **kwargs)[source]
remove(access_key_id, secret_access_key, region_name, table_name, keys, overwrite_by_pkeys=None)[source]
scan(access_key_id, secret_access_key, region_name, table_name, count=False, **kwargs)[source]
helper.web.aws.s3 — AWS S3

Warning

This package is not documented yet.

class dp_tornado.helper.web.aws.s3.S3Helper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

browse(access_key_id, secret_access_key, region_name, bucket_name, prefix)[source]
copy(access_key_id, secret_access_key, region_name, src_bucket_name, src_key, dest_bucket_name, dest_key, copied_check=True)[source]
download(access_key_id, secret_access_key, region_name, bucket_name, src, dest, **kwargs)[source]
exists(key, access_key_id, secret_access_key, region_name, bucket_name)[source]
generate_presigned_post(access_key_id, secret_access_key, region_name, bucket_name, key, success_action_redirect=None, content_length_range=None, max_content_length=None, expires_in=6000, acl=None)[source]
remove(access_key_id, secret_access_key, region_name, bucket_name, key=None, prefix=None, deleted_check=True)[source]
upload(access_key_id, secret_access_key, region_name, bucket_name, src, dest, uploaded_check=True, ExtraArgs=None)[source]
helper.web.email — E-Mail

Warning

This package is not documented yet.

class dp_tornado.helper.web.email.EmailHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

send(*args, **kwargs)[source]
username_from_email(email)[source]
validate(e)[source]
helper.web.form — Form

Warning

This package is not documented yet.

class dp_tornado.helper.web.form.FormHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

validate(controller, fields, error_res='json')[source]
helper.web.html — HTML

Warning

This package is not documented yet.

class dp_tornado.helper.web.html.HtmlHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

escape(s, quote=False)[source]
strip_tags(text)[source]
strip_xss(s, whitelist=None)[source]
unescape(text)[source]
validate(s)[source]
helper.web.http — HTTP

Warning

This package is not documented yet.

class dp_tornado.helper.web.http.HttpHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

request(req_type, res_type, url, data=None, json=None, raise_exception=False, session=None, **kwargs)[source]
request_delete(res_type, url, raise_exception=False, session=None, **kwargs)[source]
request_get(res_type, url, data=None, raise_exception=False, session=None, **kwargs)[source]
request_head(res_type, url, raise_exception=False, session=None, **kwargs)[source]
request_options(res_type, url, raise_exception=False, session=None, **kwargs)[source]
request_patch(res_type, url, data=None, raise_exception=False, session=None, **kwargs)[source]
request_post(res_type, url, data=None, json=None, raise_exception=False, session=None, **kwargs)[source]
request_put(res_type, url, data=None, raise_exception=False, session=None, **kwargs)[source]
helper.web.http.get — HTTP - Get

Warning

This package is not documented yet.

class dp_tornado.helper.web.http.get.GetHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

html(url, data=None, **kwargs)[source]
json(url, data=None, **kwargs)[source]
raw(url, data=None, **kwargs)[source]
text(url, data=None, **kwargs)[source]
helper.web.http.post — HTTP - Post

Warning

This package is not documented yet.

class dp_tornado.helper.web.http.post.PostHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

html(url, data=None, json=None, **kwargs)[source]
json(url, data=None, json=None, **kwargs)[source]
raw(url, data=None, json=None, **kwargs)[source]
text(url, data=None, json=None, **kwargs)[source]
helper.web.http.put — HTTP - Put

Warning

This package is not documented yet.

class dp_tornado.helper.web.http.put.PutHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

html(url, data=None, **kwargs)[source]
json(url, data=None, **kwargs)[source]
raw(url, data=None, **kwargs)[source]
text(url, data=None, **kwargs)[source]
helper.web.http.delete — HTTP - Delete

Warning

This package is not documented yet.

class dp_tornado.helper.web.http.delete.DeleteHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

html(url, **kwargs)[source]
json(url, **kwargs)[source]
raw(url, **kwargs)[source]
text(url, **kwargs)[source]
helper.web.http.patch — HTTP - Patch

Warning

This package is not documented yet.

class dp_tornado.helper.web.http.patch.PatchHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

html(url, data=None, **kwargs)[source]
json(url, data=None, **kwargs)[source]
raw(url, data=None, **kwargs)[source]
text(url, data=None, **kwargs)[source]
helper.web.url — URL

Warning

This package is not documented yet.

class dp_tornado.helper.web.url.UrlHelper(category=None, path_prefix=None)[source]

Bases: dp_tornado.engine.helper.Helper

build(url=None, query=None)[source]
decode(*args, **kwargs)[source]
encode(*args, **kwargs)[source]
join(*args)[source]
parse(e)[source]
quote(e, safe='', **kwargs)[source]
unquote(e, **kwargs)[source]
validate(e)[source]
class dp_tornado.helper.web.url.UrlParse(request=None, scheme='', netloc='', path='', params=None, query=None, framgment='')[source]

Bases: object

build()[source]

Scheduler

Warning

This package is not documented yet.

Schema

Schema module provides auto-generate relational database model as object based.

File/Class Invoke rules

  • /schema/__init__.py, DO NOT IMPLEMENT ANY CODE IN THIS FILE
  • /schema/blog/__init__.py, BlogSchema > schema.blog
  • /schema/blog/articles.py, ArticlesSchema > schema.blog.articles
  • /schema/blog/comments.py, CommentsSchema > schema.blog.comments

Table migration(create or alter) will be executed by invoking .migrate() method manually. For example, you can migrate comments table with invoking schema.blog.comments.migrate() method.

There are 2 types of schema. One is __dsn__ specifier and another one is table describer. __init__.py file of each directory must be __dsn__ specifier. and child .py files are must be table describer.

Here is a __dsn__ specifier example (/schema/blog/__init__.py):

from dp_tornado.engine.schema import Schema as dpSchema


class BlogSchema(dpSchema):
    __dsn__ = 'tests.model_test/drv_mysql_test'

and Here is a table describer example (/schema/blog/comments.py):

from dp_tornado.engine.schema import Table as dpTable
from dp_tornado.engine.schema import Schema as dpSchema
from dp_tornado.engine.schema import Attribute as dpAttribute

class CommentsSchema(dpSchema):
    __table_name__ = 'comments'

    __engine__ = 'InnoDB'
    __charset__ = 'utf8'

    comment_id = dpAttribute.field(dpAttribute.DataType.BIGINT, ai=True, pk=True, nn=True, un=True, comment='Comment ID')
    article_id = dpAttribute.field(dpAttribute.DataType.BIGINT, nn=True, un=True, comment='Parent Article ID')
    author = dpAttribute.field(dpAttribute.DataType.VARCHAR(32), nn=True, comment='Author')
    comment = dpAttribute.field(dpAttribute.DataType.VARCHAR(128), nn=True, comment='Comment')

    primary_key = dpAttribute.index(dpAttribute.IndexType.PRIMARY, 'comment_id')

    idx_articles_author_and_comment = dpAttribute.index(dpAttribute.IndexType.INDEX, ('author', 'comment'))
    idx_articles_comment = dpAttribute.index(dpAttribute.IndexType.INDEX, 'comment')

    fk_comments_article_id = dpAttribute.foreign_key(('article_id', dpSchema.field().blog.articles, 'article_id'))

Cache

Warning

This package is not documented yet.

M17n

Warning

This package is not documented yet.

Vars

Warning

This package is not documented yet.

Logging

Warning

This package is not documented yet.

Testing

Testing module provides unittest by pre-defined testing syntax. You can define testing syntax as method docstring, `.. test::` indicates the beginning of testing syntaxes.

Run Test:

$ dp4p test --path=./example

Available syntax:

  • expect(criteria)
  • expect(priority, rules)
  • !expect(criteria)
  • !expect(priority, rules)
rules:
    controller:
        code, text, json, args(arguments separated by /), params(query string, form values)
    model, helper:
        int, long, bool, str, json, args (arguments by list), kwargs (arguments by dict)
from dp_tornado.engine.controller import Controller as dpController
from dp_tornado.engine.model import Model as dpModel
from dp_tornado.engine.helper import Helper as dpHelper

class FooController(dpController):
    def get(self):
        """
            .. test::
                expect(
                    1,
                    code=200,
                    text='foo==bar',
                    params={'foo': 'bar'})
        """
        foo = self.get_argument('foo')

        if foo == 'bar':
            return self.finish('foo==bar')

        self.finish('done')

    def post(self):
        """
            .. test::
                expect(code=400, params={'foo': 'bar'})
        """
        foo = self.get_argument('foo')

        if foo == 'bar':
            return self.finish_with_error(400)

        self.finish('done')

class FooController(dpController):
    def get(self):
        """
            Test with params and expect json value.

            .. test::
                expect(json="{'foo':'bar'}", params={'foo': 'bar'})
        """
        foo = self.get_argument('foo')
        return self.finish({'foo': bar)

class FooController(dpController):
    def get(self):
        """
            Test with params and expect json value.

            .. test::
                expect(json={'foo':'bar'}, params={'foo': 'bar'})
        """
        foo = self.get_argument('foo')
        return self.finish({'foo': bar)

class FooModel(dpModel):
    def foobar(self, foo):
        """
            Test with kwargs arguments.

            .. test::
                expect(int=100, kwargs={'foo': 'bar'})
        """
        if foo == 'bar':
            return int(100)

        return 0

class FooModel(dpModel):
    def foobar(self, foo):
        """
            Test with kwargs arguments.

            .. test::
                expect(long=100, kwargs={'foo': 'bar'})
                expect(long=0, kwargs={'foo': 'foo'})
                !expect(long=0, kwargs={'foo': 'bar'})
        """
        if foo == 'bar':
            if self.e.helper.misc.system.py_version <= 2:
                return long(100)
            else:
                return int(100)


        if self.e.helper.misc.system.py_version <= 2:
            return long(0)
        else:
            return int(0)

class FooHelper(dpHelper):
    def foobar(self, foo, bar):
        """
            Test with args arguments.

            .. test::
                expect(bool=True, args={'foo': 'bar'})
                !expect(bool=False, args={'foo': 'bar'})
        """
        foo = self.get_argument('foo')

        if foo == 'bar':
            return True

        return False