Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
The Last Python Web Framework
Python
branch: master

Merge pull request #1 from agamdua/master

Updated: requirements.txt
latest commit 922ceb4201
@jeffknupp authored
Failed to load latest commit information.
docs The big rename
examples/twooter Update with documentation
images Add README.md
omega simplify; working
tests tests
.gitignore Initial commit
README.md Finish name change
requirements.txt Updated: requirements.txt

README.md

Omega!

Omega - The web platform that "has an app for that"

What is Omega?

Omega is an attempt to bring back innovation to Python web frameworks. Its goal is to be more than a web framework; Omega aims to be a platform on which any type of web application can be built, batteries included. That means Omega ships with support for creating ORM-backed CRUD applications, NoSQL REST APIs, real-time applications using Websockets, and simple, mostly static page applications.

To this end, Omega will include the tools/libraries listed below. Of course, it's still in its infancy, so many of the items below are vaporware.

search

Support for full-text search in web applications. Coming Soon.

kvs

A pure-Python NoSQL database usable as a backing store for a web application. In progress.

queue

A distributed, asychronous task queue for out-of-band/background task execution in web applications. Includes support for cron-like job scheduling. In progress.

log/stat

A centralized logging/metrics server with fully browsable logs and metric reporting. Includes monitoring for metrics like process uptime, request speed, number of exceptions, etc. Coming Soon

settings

A centralized live-settings server capable of providing service discovery capabilities as well as a management frontent for traditional database-backed application settings. Coming Soon

http

A micro web framework with macro capabilities. In progress.

Here are a few examples of the vastly different types of applications you can already build in an instant:

ORM-backed CRUD application

runserver.py

from omega.http.core import create_app
from omega.http.orm import create_engine
from werkzeug import run_simple
from models import Twoot, User

if __name__ == '__main__':
    app = create_app(__name__)
    app.engine(create_engine('sqlite+pysqlite:///db.sqlite3'))
    app.orm_resource(Twoot)
    app.orm_resource(User)
    app.auto_generate_home()
    run_simple('127.0.0.1', 5000, app, use_debugger=True, use_reloader=True)

models.py

import datetime

from omega.http.orm import Model, Column, String, DateTime, Integer, relationship, ForeignKey

class User(Model):
    __tablename__ = 'user'

    id = Column(Integer, primary_key=True)
    user_name = Column(String)
    joined_at = Column(DateTime, default=datetime.datetime.now())

    def __str__(self):
        return self.user_name

class Twoot(Model):
    __tablename__ = 'twoot'

    id = Column(Integer, primary_key=True)
    content = Column(String)
    posted_at = Column(DateTime, default=datetime.datetime.now())
    user_id = Column(Integer, ForeignKey('user.id'))
    user = relationship(User)

This gives you the following, for free:

Homepage

Home page shot

List of objects

Resources shot

By adding a sockets.py file with the following contents (and creating a new route function using the route decorator):

from socketio.namespace import BaseNamespace


class ChatNamespace(BaseNamespace):
    sockets = {}

    def on_chat(self, msg):
        self.emit('chat', msg)

    def recv_connect(self):
        self.sockets[id(self)] = self

    def disconnect(self, *args, **kwargs):
        if id(self) in self.sockets:
            del self.sockets[id(self)]
        super(ChatNamespace, self).disconnect(*args, **kwargs)

    @classmethod
    def broadcast(self, event, message):
        for ws in self.sockets.values():
            ws.emit(event, message)

(in runserver.py):

@app.route('/chat', methods=['POST'])
def chat(request):
    """Route chat posts to the *chat* handler function. Broadcast the message
    to all users."""
    message = '{}: {}'.format(request.form['user'], request.form['message'])
    if message:
        ChatNamespace.broadcast('message', message)
    return Response()

You now have free real-time chat that degrades gracefully via socket.io. Connect two browsers to the root page and type a message in one browser. It will pop up in the chat area of the other browser.

Something went wrong with that request. Please try again.