-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ported django-kombu to sqlalchemy using haridsv's template
- Loading branch information
Ask Solem
committed
Oct 27, 2010
0 parents
commit 2ad8b41
Showing
15 changed files
with
392 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.DS_Store | ||
*.pyc | ||
*~ | ||
*.sqlite | ||
*.sqlite-journal | ||
settings_local.py | ||
local_settings.py | ||
.*.sw[po] | ||
dist/ | ||
*.egg-info | ||
doc/__build/* | ||
build/ | ||
locale/ | ||
pip-log.txt | ||
devdatabase.db | ||
.directory | ||
bundle_version.gen | ||
celeryd.log | ||
celeryd.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Ask Solem <[email protected]> | ||
Tareque Hossain | ||
Flavio [FlaPer87] Percoco Premoli <[email protected]> | ||
Petar Radosevic <[email protected]> | ||
Tomaž Muraus <[email protected]> | ||
Peter Hoffmann <[email protected]> | ||
David Ziegler <[email protected]> | ||
David Clymer <[email protected]> | ||
Pascal Hartig <[email protected]> | ||
Marcin Lulek (ergo) <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
t================ | ||
Change history | ||
================ | ||
|
||
0.1.0 | ||
===== | ||
|
||
* Initial port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Installation | ||
============ | ||
|
||
You can install ``ghettoq`` either via the Python Package Index (PyPI) | ||
or from source. | ||
|
||
To install using ``pip``,:: | ||
|
||
$ pip install ghettoq | ||
|
||
|
||
To install using ``easy_install``,:: | ||
|
||
$ easy_install ghettoq | ||
|
||
|
||
If you have downloaded a source tarball you can install it | ||
by doing the following,:: | ||
|
||
$ python setup.py build | ||
# python setup.py install # as root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Copyright (c) 2009, Ask Solem | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
Neither the name of Ask Solem nor the names of its contributors may be used | ||
to endorse or promote products derived from this software without specific | ||
prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | ||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
include AUTHORS | ||
include Changelog | ||
include INSTALL | ||
include LICENSE | ||
include MANIFEST.in | ||
include README | ||
include THANKS | ||
include TODO | ||
include setup.cfg | ||
recursive-include djkombu * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
README.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
=================================================== | ||
kombu-sqlalchemy - Kombu transport using SQLAlchemy | ||
=================================================== | ||
|
||
:version: 0.9.0 | ||
|
||
Introduction | ||
============ | ||
|
||
This package enables you to use SQLAlchemy as the message store | ||
for `Kombu`_. | ||
|
||
|
||
``kombu-sqlalchemy`` contains a single transport, | ||
``sqlakombu.transport.Transport``, which is used like this:: | ||
|
||
>>> from kombu.connection import BrokerConnection | ||
>>> c = BrokerConnection(transport="sqlakombu.transport.Transport") | ||
|
||
|
||
.. _`Kombu`: http://pypi.python.org/pypi/kombu | ||
|
||
Installation | ||
============ | ||
|
||
You can install ``kombu-sqlalchemy`` either via the Python Package Index (PyPI) | ||
or from source. | ||
|
||
To install using ``pip``,:: | ||
|
||
$ pip install kombu-sqlalchemy | ||
|
||
|
||
To install using ``easy_install``,:: | ||
|
||
$ easy_install kombu-sqlalchemy | ||
|
||
|
||
If you have downloaded a source tarball you can install it | ||
by doing the following,:: | ||
|
||
$ python setup.py build | ||
# python setup.py install # as root | ||
|
||
License | ||
======= | ||
|
||
This software is licensed under the ``New BSD License``. See the ``LICENSE`` | ||
file in the top distribution directory for the full license text. | ||
|
||
.. # vim: syntax=rst expandtab tabstop=4 shiftwidth=4 shiftround | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Thanks to Rajesh Dhawan and other authors of django-queue-service | ||
for the database model implementation. | ||
See http://code.google.com/p/django-queue-service/. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
See http://github.com/ask/ghettoq/issues/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[nosetests] | ||
verbosity = 1 | ||
detailed-errors = 1 | ||
with-coverage = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import os | ||
import codecs | ||
|
||
try: | ||
from setuptools import setup, find_packages, Command | ||
except ImportError: | ||
from ez_setup import use_setuptools | ||
use_setuptools() | ||
from setuptools import setup, find_packages, Command | ||
|
||
from distutils.command.install_data import install_data | ||
from distutils.command.install import INSTALL_SCHEMES | ||
import sys | ||
|
||
import sqlakombu | ||
|
||
packages, data_files = [], [] | ||
root_dir = os.path.dirname(__file__) | ||
if root_dir != '': | ||
os.chdir(root_dir) | ||
src_dir = "sqlakombu" | ||
|
||
install_requires = [] | ||
|
||
|
||
def osx_install_data(install_data): | ||
|
||
def finalize_options(self): | ||
self.set_undefined_options("install", ("install_lib", "install_dir")) | ||
install_data.finalize_options(self) | ||
|
||
|
||
def fullsplit(path, result=None): | ||
if result is None: | ||
result = [] | ||
head, tail = os.path.split(path) | ||
if head == '': | ||
return [tail] + result | ||
if head == path: | ||
return result | ||
return fullsplit(head, [tail] + result) | ||
|
||
|
||
for scheme in INSTALL_SCHEMES.values(): | ||
scheme['data'] = scheme['purelib'] | ||
|
||
SKIP_EXTENSIONS = [".pyc", ".pyo", ".swp", ".swo"] | ||
|
||
|
||
def is_unwanted_file(filename): | ||
for skip_ext in SKIP_EXTENSIONS: | ||
if filename.endswith(skip_ext): | ||
return True | ||
return False | ||
|
||
|
||
for dirpath, dirnames, filenames in os.walk(src_dir): | ||
# Ignore dirnames that start with '.' | ||
for i, dirname in enumerate(dirnames): | ||
if dirname.startswith("."): | ||
del dirnames[i] | ||
for filename in filenames: | ||
if filename.endswith(".py"): | ||
packages.append('.'.join(fullsplit(dirpath))) | ||
elif is_unwanted_file(filename): | ||
pass | ||
else: | ||
data_files.append([dirpath, [os.path.join(dirpath, f) for f in | ||
filenames]]) | ||
|
||
setup( | ||
name='kombu-sqlalchemy', | ||
version=sqlakombu.__version__, | ||
description=sqlakombu.__doc__, | ||
author=sqlakombu.__author__, | ||
author_email=sqlakombu.__contact__, | ||
url=sqlakombu.__homepage__, | ||
platforms=["any"], | ||
license='BSD', | ||
packages=packages, | ||
data_files=data_files, | ||
zip_safe=False, | ||
test_suite="nose.collector", | ||
install_requires=install_requires, | ||
classifiers=[ | ||
"Development Status :: 4 - Beta", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Intended Audience :: Developers", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
], | ||
long_description=codecs.open('README', "r", "utf-8").read(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Kombu transport using SQLAlchemy as the message store.""" | ||
VERSION = (0, 9, 0) | ||
__version__ = ".".join(map(str, VERSION)) | ||
__author__ = "Ask Solem" | ||
__contact__ = "[email protected]" | ||
__homepage__ = "http://github.com/ask/kombu-sqlalchemy/" | ||
__docformat__ = "restructuredtext" | ||
__license__ = "BSD" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import datetime | ||
|
||
from sqlalchemy import Column, Integer, String, Text, DateTime, \ | ||
Sequence, Boolean, ForeignKey, SmallInteger | ||
from sqlalchemy.orm import relation | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy.schema import MetaData | ||
|
||
metadata = MetaData() | ||
ModelBase = declarative_base(metadata=metadata) | ||
|
||
|
||
class Queue(ModelBase): | ||
__tablename__ = 'kombu_queue' | ||
__table_args__ = {"sqlite_autoincrement": True} | ||
|
||
id = Column(Integer, Sequence('queue_id_sequence'), primary_key=True, | ||
autoincrement=True) | ||
name = Column(String(200), unique=True) | ||
messages = relation("Message", backref='queue', lazy='noload') | ||
|
||
def __init__(self, name): | ||
self.name = name | ||
|
||
def __str__(self): | ||
return "<Queue(%s)>" % (self.name) | ||
|
||
class Message(ModelBase): | ||
__tablename__ = 'kombu_message' | ||
__table_args__ = {"sqlite_autoincrement": True} | ||
|
||
id = Column(Integer, Sequence('message_id_sequence'), primary_key=True, | ||
autoincrement=True) | ||
visible = Column(Boolean, default=True, index=True) | ||
sent_at = Column('timestamp', DateTime, nullable=True, index=True, | ||
onupdate = datetime.datetime.now) | ||
payload = Column(Text, nullable=False) | ||
queue_id = Column(SmallInteger, ForeignKey('ghettoq_queue.id', name='FK_qhettoq_message_queue')) | ||
version = Column(SmallInteger, nullable=False, default=1) | ||
|
||
__mapper_args__ = {'version_id_col': version} | ||
|
||
def __init__(self, payload, queue): | ||
self.payload = payload | ||
self.queue = queue | ||
|
||
def __str__(self): | ||
return "<Message(%s, %s, %s, %s)>" % (self.visible, self.sent_at, self.payload, self.queue_id) | ||
|
Oops, something went wrong.