Skip to main content

Mother is a framework written in python and based on twisted. It is designed to make developpement of web applications easy and fast.

It provides following functionalities among others:
  • simple url mapping to code,

  • handle multi content-types (html, JSON, …),

  • integration with Tentacles ORM,

  • allow use of templating tools (currently, only Mako is supported)

Example:

UUID = '7c772000-8f12-4594-9730-9e4de53d55d1'

from mother          import routing
from mother.callable import callback, Callable
from mother.template import Static, Template

@callback(url=routing.ROOT)
def root(**kwargs):
       return """
               <html>
                       <head>
                               <title>Welcome to Mother Sample Application</title>
                       </head>
                       <body>
                               This is the homepage of <b>Mother Sample Application</b>.<br/>
                               <br>
                               <em>You are welcome to watch my source code to see how to build your first
                               <strong>Mother</strong> application</em>.
                       </body>
               </html>
       """

@callback(url='/foo', content_type='text/plain')
def foo(**kwargs):
       return 'foo:: plain text'

@callback(url='/foo', content_type='application/json')
def foo(**kwargs):
       return ['foo', 'json tree']

@callback(url='/foo', content_type='text/html')
def foo(**kwargs):
       return '<html><body><b>foo</b>:: html content</body></html>'

@callback
def bar(age, **args):
       try:
               age = int(age)
       except:
               return routing.HTTP_404('age MUST be integer')

       return 'the captain is %d years old' % age

class Captain(Callable):
       def __init__(self, **kwargs):
               super(Captain, self).__init__(**kwargs)
               self._age = 54

       # special methods GET, POST, PUT, DELETE are directly mapped to '/sample/captain' url
       def GET(self, **kwargs):
               return 'Captain::GET'

       # You can also expose non-special class/instance methods with the callback modified
       # Here we learn a new @callback option, named 'method'
       #
       @callback
       def age(self, **kwargs):
               return self._age

       # Here we discover a new @callback argument, named 'method'
       # taking either a string among 'GET', 'POST','PUT','DELETE' or a list of these
       #
       # This argument set HTTP method(s) callback is accessible through (default is GET)
       @callback(url='/setage', method='POST')
       def age_post(self, age, **kwargs):
               try:
                       self._age = int(age)
               except:
                       return routing.HTTP_404('age MUST be integer')

               return routing.HTTP_200('')

@callback
def hello(**kwargs):
       return 'hello'

URLS = {
       # expose function
       '/hel-lo'                                                       : hello,
       # expose static content (directory)
       '/static'             : Static('static-content/'),
       # expose template file
       # NOTES
       #   . template files MUST be stored in a templates/ sub-directory
       #   . Mako is the only available template engine at present
       '/template'                                             : Template('sample.html', title='template sample title',
                                      content="""You\'re viewing a template sample page, rendered with <em>Mako</em>""")
}

Release files for mother-webapps-framework 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mother-webapps-framework 0.1.0
File Size Uploaded
mother-webapps-framework-0.1.0.tar.gz 42.4 kB Details

Release files / mother-webapps-framework-0.1.0.tar.gz

Download URL mother-webapps-framework-0.1.0.tar.gz
Size 42.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bef5a88e61161a931d7ee2e90a00450b26f3b1a92ce0924754b60ffa584834b6
BLAKE2b-256 checksum
How to use checksums
4a3c09875a9549c688d9893725c4e0bc7c08bbe032cb1641a051f158ef486bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page