Check-in [b2ea003738]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added a doctest. Added author and setup information.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b2ea003738c9ee1fe841e7ac56b08740774953ea
User & Date: yusuke 2010-10-24 01:19:28
Context
2010-10-24
03:12
rename a file check-in: 4a7afc2e29 user: yusuke tags: trunk, 0.1dev
01:19
Added a doctest. Added author and setup information. check-in: b2ea003738 user: yusuke tags: trunk
2010-10-23
23:28
Made the logic simply. Added tests. check-in: 0d51a24c5d user: yusuke tags: trunk
Changes

Added README.rst.





























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
===========
gaedeferred
===========

What's this
-----------

gaedeferred attempts to make deferred chain on Google Appengine. The design of
the deferred chain is inspired by Twisted. Because of no support for callback
and errback on taskqueue.

How to use
----------

First of all, please ensure that the google library exists on sys.path. Then
follow bellow steps::

    >>> from google.appengine.ext import deferred
    >>> from gaedeferred import Deferred

    Setup test environment. (These steps are meanless for actual use, just for doctest)
    >>> import sys
    >>> sys.path.insert(0, '.')
    >>> from tests.test_deferred import value, increase, must_be
    >>> from tests.conftest import mimic_defer
    >>> deferred.defer = mimic_defer

    >>> d = Deferred(value, 5)
    >>> d.addCallback(increase, 10)

    An alias exists for addCallback
    >>> d.next(must_be, 15)

    The deferred to be executed on an asynchronous task.
    >>> deferred.defer(d)

How to test
-----------

Like this.:: bash

  $ py.test --appengine=${your appengine path} --doctest-glob='*.rst'

Dependencies
------------

* py.test
  It is used for testing.

To do
-----

* deferred list

Questions and Bug Reports
-------------------------

* Site
  https://chiselapp.com/user/jbking/repository/gaedeferred/

* Or, cantact me.
  MURAOKA Yusuke <yusuke.muraoka@gmail.com>

Changes to gaedeferred/__init__.py.

























1
2
3
4
5
6
7
























import logging
from sys import exc_info
from pickle import loads
from google.appengine.ext import deferred

class Failure(deferred.Error):
    def __init__(self, exc_value=None, exc_type=None):
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
The MIT License

Copyright (c) 2010 MURAOKA Yusuke <yusuke.muraoka@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

import logging
from sys import exc_info
from pickle import loads
from google.appengine.ext import deferred

class Failure(deferred.Error):
    def __init__(self, exc_value=None, exc_type=None):

Changes to setup.py.

1
2
3
4
5
6
7
8
9
10
11





12
13
14
15

16
17
18
19
20
21
22

23
24
25
26
from setuptools import setup, find_packages
import sys, os

version = '0.1'

setup(name='gaedeferred',
      version=version,
      description="",
      long_description="""\
""",
      classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers





      keywords='',
      author='MURAOKA Yusuke',
      author_email='yusuke.muraoka@gmail.com',
      url='',

      license='',
      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
      include_package_data=True,
      zip_safe=True,
      install_requires=[
          # -*- Extra requirements: -*-
      ],

      entry_points="""
      # -*- Entry points: -*-
      """,
      )

<





|
|
|
|
>
>
>
>
>
|


<
>
|
|





>




1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
26
27
28
29
30
31
from setuptools import setup, find_packages


version = '0.1'

setup(name='gaedeferred',
      version=version,
      description="A deferred library on taskqueue for Google Appengine",
      long_description=file("README.rst").read(),
      classifiers=["Development Status :: 3 - Alpha",
                   "Environment :: Web Environment",
                   "Intended Audience :: Developers",
                   "License :: OSI Approved :: MIT License",
                   "Programming Language :: Python :: 2.5",
                   "Topic :: Software Development :: Libraries :: Python Modules"
                  ],
      keywords='appengine gae deferred',
      author='MURAOKA Yusuke',
      author_email='yusuke.muraoka@gmail.com',

      url='https://chiselapp.com/user/jbking/repository/gaedeferred/',
      license='MIT License',
      packages=find_packages(exclude=['tests']),
      include_package_data=True,
      zip_safe=True,
      install_requires=[
          # -*- Extra requirements: -*-
      ],
      test_requires=['py'],
      entry_points="""
      # -*- Entry points: -*-
      """,
      )

Added tests/__init__.py.

Changes to tests/conftest.py.

























1
2
3
4
5
6
7
























from os import path, sys
sys.path.insert(0, path.join(*path.split(path.abspath(path.dirname(__file__)))[:-1]))

import py

def mimic_defer(obj, *args, **kwargs):
    obj(*args, **kwargs)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
The MIT License

Copyright (c) 2010 MURAOKA Yusuke <yusuke.muraoka@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from os import path, sys
sys.path.insert(0, path.join(*path.split(path.abspath(path.dirname(__file__)))[:-1]))

import py

def mimic_defer(obj, *args, **kwargs):
    obj(*args, **kwargs)

Changes to tests/test_deferred.py.

























1
2
3
4
5
6
7
























from gaedeferred import Deferred, Failure

def value(value=0):
    return value

def increase(result, value=1):
    return result + value
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
The MIT License

Copyright (c) 2010 MURAOKA Yusuke <yusuke.muraoka@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from gaedeferred import Deferred, Failure

def value(value=0):
    return value

def increase(result, value=1):
    return result + value