Pytavia is a framework based on Flask focused on a nice integration between Python and MongoDB. The goal is to get MongoDB and python apps running easily, supporting REST and event based apps.
Pytavia was created in Jakarta formally known as Batavia , hence Pytavia. Enjoy, also : It’s BSD licensed!

Pytavia HTTP / REST

import json
import time
import pymongo

from pytavia_stdlib  import utils
from pytavia_core    import database 
from pytavia_core    import config 
from pytavia_stdlib  import idgen 

from rest_api_controller import module1 

from flask import request
from flask import render_template
from flask import Flask
from flask import session
from flask import make_response
from flask import redirect
from flask import url_for
from flask import flash

from flask_wtf.csrf import CSRFProtect
from flask_wtf.csrf import CSRFError
# Main app configurations
app             = Flask( __name__, config.G_STATIC_URL_PATH )
app.secret_key  = config.G_FLASK_SECRET

@app.route("/v1/api/api-v1", methods=["GET"])
def api_v1():
    params = request.args.to_dict()
    response = module1.module1(app).process( params )
    return response.stringify_v1()
# end def


Event based Programming

import json
import time
import pymongo
import sys
import urllib.parse
import base64

from pytavia_stdlib      import utils
from pytavia_core        import database
from pytavia_core        import config
from pytavia_core        import pytavia_events
from pytavia_stdlib      import idgen

from event_handler       import customer_evt_handler
from event_loop_executor import event_loop_proc

class server_event_handler(pytavia_events.pytavia_events):

    def __init__(self, params):
        pytavia_events.pytavia_events.__init__( self, params )
   # end def

    def register_handlers(self, params):
            "handler_name" : "INSERT_DB_QUEUE_WORKFLOW_PROCESS",
            "collection"   : "db_queue_workflow_process",
            "handler"      : customer_evt_handler.customer_evt_handler({}),
            "query_filter" : []
    # end def

    def start(self, params):
            "event_loop_wait"    : 60,
            "event_loop_execute" : event_loop_proc.event_loop_proc({})
    # end 

# end class

seh = server_event_handler({})


What’s in the Box ?


Multi-threaded event based programming right out of the box


Easy MongoDB integration


All awesome and existing Flask features


Event based programming and REST API’s in a single framework


Built in debugger and easy to support

Hello there

If your looking for some code examples or some sample applications please visit the following github to check for the latest updates. Updates on the way .

> pytavia — baseline framework code


Found a bug? Have a good idea for improving Pytavia? Head over to Pytavia’s github page and create a new ticket or fork. If you just want to chat with fellow developers just contact us via the contact us email and we can get on a chat to discuss ideas and ways to make Pytavia great.