{ "info": { "author": "codeix", "author_email": "samuel.riolo@biel-bienne.ch", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: Zope Public License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": ".. role:: python(code)\n :language: python\n\n\n\n.. image:: https://travis-ci.org/bielbienne/bst.pygasus.demo.svg?branch=master\n :target: https://travis-ci.org/bielbienne/bst.pygasus.demo\n\n.. contents::\n\nIntroduction\n============\n\nPygasus is a new Python 3 framework to build web applications with\n`Sencha ExtJS `_. Pygasus is designed to be full\ncustomizable for your project. \n\nbst.pygasus and all corresponding submodules are licensed under the ZPL 2.1, see LICENSE.txt for details.\n\nArchitecture\n------------\n\n.. figure:: docs/architecture.png\n :alt: Architecture\n\n yellow modules are planned to be developed in the near future\n\nThe various packages are:\n\nbst.extjs.core\n The core package of the framework that assembles all required packages together.\n\nbst.extjs.datamanager\n The datamanager manages data coming from the client and data sent to the client's browser.\n\nbst.extjs.i18n\n This package handles the translation for multilingual sites and applications.\n\nbst.extjs.scaffolding\n Scaffolding is a package to generate standard models, stores, views and grids for ExtJS. \n\nbst.extjs.security\n This package provide a default login mask and a pluggable authentication. In the future we also plan to\n implement a role based permission model.\n\nbst.extjs.session\n This package creates a cookie on client browsers and provides a server side session store.\n\nbst.extjs.wsgi\n The layer needed to let the application work as a WSGI server.\n\nbst.extjs.resources\n This package is responsible to share all needed static resources with the client.\n\n\nGetting started\n===============\n\nRecommendation\n--------------\n\nThe ZCA (Zope component Architectur) is a main element in this framework. If you are not familiar with it, we recommend you first learn its basics. You can follow the links at the bottom of this page. Also other external libraries are already well documented, which is why we didn't want to do that twice.\n\nBuildout\n--------\n\nWe recommend to setup up a buildout for your project. First it will install all required dependencies and the scripts needed to run a server. The boostrap file can be downloaded at https://bootstrap.pypa.io/bootstrap-buildout.py.\n\nFile structure:\n\n.. code::\n\n buildout\n \u251c\u2500\u2500 bootstrap.py\n \u251c\u2500\u2500 buildout.cfg\n \u251c\u2500\u2500 etc\n \u2502 \u251c\u2500\u2500 deploy.ini.in\n \u2502 \u2514\u2500\u2500 site.zcml.in\n \u2514\u2500\u2500 dev\n \u2514\u2500\u2500 myproject\n\nbuildout.cfg\n\n.. code:: ini\n\n [buildout]\n \n extends = \n https://raw.githubusercontent.com/bielbienne/bst.pygasus.demo/master/sources.cfg\n https://raw.githubusercontent.com/bielbienne/bst.pygasus.demo/master/versions.cfg\n \n develop = dev/myproject \n parts =\n app\n zcml\n lingua\n \n extensions = mr.developer\n auto-checkout =\n js.extjs\n bst.pygasus.core\n bst.pygasus.wsgi\n bst.pygasus.scaffolding\n bst.pygasus.datamanager\n bst.pygasus.resources\n bst.pygasus.security\n bst.pygasus.session\n bst.pygasus.i18n\n bst.pygasus.demo\n \n [debug_ini]\n recipe = collective.recipe.template\n input = etc/deploy.ini.in\n output = ${buildout:parts-directory}/etc/${:outfile}\n outfile = debug.ini\n \n [zcml]\n recipe = collective.recipe.template\n input = etc/site.zcml.in\n output = ${buildout:parts-directory}/etc/${:outfile}\n outfile = site.zcml\n \n [app]\n recipe = zc.recipe.egg:script\n arguments=\"${debug_ini:output}\"\n eggs =\n bst.pygasus.wsgi\n myproject\n\n [lingua]\n unzip = true\n recipe = zc.recipe.egg\n eggs =\n lingua\n bst.pygasus.i18n\n\netc/deploy.ini.in\n\n.. code:: ini\n\n [zcml]\n path = ${zcml:output}\n\n [app:main]\n use = egg:bst.pygasus.wsgi#main\n\n [server:debug]\n use = egg:waitress#http\n host = 127.0.0.1\n port = 5000\n threadpool_workers = 1\n threadpool_spawn_if_under = 1\n threadpool_max_requests = 0\n\netc/site.zcml.in\n\n.. code:: xml\n\n \n \n \n\nRun your buildout. (You must first create your own project as shown in next part)\n\n.. code:: bash\n\n $ cd buildout\n $ python3 boostrap.py\n $ ./bin/buildout\n\n\nCreate an application\n---------------------\n\nProposed File Structure\n~~~~~~~~~~~~~~~~~~~~~~~\n\nWe propose the following file structure inside your python egg:\n\n.. code::\n\n \u251c\u2500\u2500 app\n \u2502 \u251c\u2500\u2500 application.js\n \u2502 \u251c\u2500\u2500 controller\n \u2502 \u2502 \u251c\u2500\u2500 Card.js\n \u2502 \u2502 \u2514\u2500\u2500 Main.js\n \u2502 \u251c\u2500\u2500 resources\n \u2502 \u2502 \u2514\u2500\u2500 css\n \u2502 \u2502 \u2514\u2500\u2500 styles.css\n \u2502 \u2514\u2500\u2500 view\n \u2502 \u251c\u2500\u2500 CardView.js\n \u2502 \u2514\u2500\u2500 MainView.js\n \u251c\u2500\u2500 configure.zcml\n \u251c\u2500\u2500 extjs.py\n \u251c\u2500\u2500 handler.py\n \u251c\u2500\u2500 __init__.py\n \u251c\u2500\u2500 locales\n \u2502 \u251c\u2500\u2500 bb.extjs.demo.pot\n \u2502 \u2514\u2500\u2500 fr\n \u2502 \u2514\u2500\u2500 LC_MESSAGES\n \u2502 \u251c\u2500\u2500 bst.pygasus.demo.mo\n \u2502 \u2514\u2500\u2500 bst.pygasus.demo.po\n \u251c\u2500\u2500 model.py\n \u2514\u2500\u2500 schema.py\n\n\nsetup configure.zcml\n~~~~~~~~~~~~~~~~~~~~\n\n.. code:: xml\n\n \n \n \n \n \n \n \n \n \n\n\nCreate an application context (extjs.py)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n from fanstatic import Library\n from fanstatic import Resource\n from bst.pygasus.core import ext\n \n library = Library('demo', 'app')\n\n class DemoContext(ext.ApplicationContext):\n \n title = 'Demo'\n application = 'bst.pygasus.demo.Application'\n namespace = 'bst.pygasus.demo'\n resources = Resource(library, 'application.js',\n depends=[ext.extjs_resources])\n\n\nRegister additional ExtJS paths (extjs.py)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nExtJS needs to know where additional ExtJS-Classes can be loaded. This is why each namespace used in ExtJS needs to be registred. In this example we regstister two namespaces for 'bst.pygasus.demo.view' and 'bst.pygasus.demo.controller'. The path usually begins with 'fanstatic', followed by your library name (e.g. \"demo\") ( :python:`Library('demo', 'app')` ) and then, at the end, a subdirectory.\n\n.. code:: python\n\n class ViewClassPathMapping(ext.ClassPathMapping):\n namespace = 'bst.pygasus.demo.view'\n path = 'fanstatic/demo/view'\n\n class ViewClassPathMapping(ext.ClassPathMapping):\n namespace = 'bst.pygasus.demo.contoller'\n path = 'fanstatic/demo/controller'\n\n\nDefine a schema (schema.py)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWith this schema different ExtJS-Classes like form, store or model, are auto generated on the fly. Look at the package bst.pygasus.scaffolding for the supported types and class generation. Feel free to extend this with your own generators of ExtJS classes for your project. This schema will also be used to transform json to a python model or vice versa.\n\n.. code:: python\n\n from bst.pygasus.core import ext\n \n from zope import schema\n from zope.interface import Interface\n \n @ext.scaffolding('Card', 'Magic the Gathering')\n class ICard(Interface):\n id = schema.Id(title='ID', required=False)\n \n name = schema.TextLine(title='Name', required=True)\n\n costs = schema.Int(title='Costs', required=False)\n\n publication = schema.Date(title='Publication', required=True)\n\n\nCreate a Model (model.py)\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe model is used to transfer data from the server to client and back.\n\n.. code:: python\n\n from bst.pygasus.core import ext\n from bst.pygasus.demo import schema\n from zope.schema.fieldproperty import FieldProperty\n\n class Card(ext.Model):\n ext.schema(schema.ICard)\n \n id = FieldProperty(ICard['id'])\n name = FieldProperty(ICard['name'])\n costs = FieldProperty(ICard['costs'])\n publication = FieldProperty(ICard['publication'])\n\n\nCreate a handler for CRUD requests (handler.py)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe handler for an definded model provides the CRUD operations. Now it is up to you to implement whatever you need in these methods.\n\n.. code:: python\n\n class CardHandler(ext.AbstractModelHandler):\n ext.adapts(model.Card, IRequest)\n \n def get(self, model, batch):\n start, limit = self.slice()\n property, direction = self.sort()\n \n return cardIndexer.search_index(start, limit, property, direction)\n \n def create(self, model, batch):\n model.id = cardIndexer.get_next_id()\n cardIndexer.extend_index(model)\n \n return [model], 1\n \n def update(self, model, batch):\n cardIndexer.update_index(model)\n \n return [model], 1\n \n def delete(self, model, batch):\n cardIndexer.reduce_index(model)\n \n return [model], 1\n\n\n\ni18n (Internationalization)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nUsually you define a domain name for each package. In order to do that you create an instance of MessageFactory in the __init__.py file:\n\n.. code:: python\n\n from zope.i18nmessageid import MessageFactory\n\n _ = MessageFactory('bst.pygasus.demo')\n\nNow you can use translation messages anywhere you want to translate a string to multiple languages:\n\n.. code:: python\n\n publication = schema.Date(title=_('publication_title', default='Publication'), required=True)\n\n\nIf you want use translations in ExtJS, it works similar to translations in python. Simply write a variable at the top of the file and pass the domain name in the MessageFactory:\n\n.. code:: javascript\n\n var _ = i18n('bst.pygasus.demo');\n\n Ext.define('bst.pygasus.demo.view.MainView', {\n extend: 'Ext.container.Viewport',\n \n ....\n\nNow you can translate messages with the variable defined anywhere in the class:\n\n.. code:: javascript\n\n items: [{\n xtype: 'button',\n action: 'save',\n text: _('tr_save', 'Save'),\n },\n\n\nYou can use the lingua package to crawl translation from python and ExtJS files and generate a .pot file with it. This application is already installed by buildout. After generating a .pot file you can use different kinds of gettext tools to merge and build the final .po and .mo files for each language:\n\n.. code:: bash\n\n ./bin/pot-create \u2013d -o .pot \n\n\nUsing Scaffolding\n~~~~~~~~~~~~~~~~~\n\nScaffolding provides default ExtJS-classes that can be directly used. Use the the \"required\" attribute to load a scaffolding class. In follow example we have defined the xtype to \"DisplayCard\". This will generate a read only view with all fields from the schema ICard.\n\n.. code:: javascript\n\n Ext.define('bst.pygasus.demo.view.CardView', {\n extend: 'Ext.window.Window',\n \n requires: [\n 'scaffolding.display.Card'\n ],\n \n itemId: 'cardView',\n layout: 'vbox',\n \n initComponent: function() {\n var me = this;\n \n me.items = [{\n xtype: 'DisplayCard',\n itemId: 'displayCard',\n title: '',\n maxWidth: '500'\n },\n {\n xtype: 'button',\n text: 'Delete',\n action: 'delete'\n }];\n \n me.bodyPadding = '5 5 5 5';\n \n me.callParent(arguments);\n }\n \n });\n\nAs an another example we use buffered store from scaffolding:\n\n.. code:: javascript\n\n Ext.define('bst.pygasus.demo.controller.Main', {\n extend: 'Ext.app.Controller',\n \n requires: [\n 'scaffolding.bufferedstore.Card'\n ],\n \n ....\n\n\n\nDemo application\n----------------\nWe have a demo application that you can easily install with a buildout file. If you are interested, please follow the instruction at `bst.pygasus.demo `_.\n\n\nExternal References\n===================\n\n* http://zopeinterface.readthedocs.org/en/latest/\n* http://zopecomponent.readthedocs.org/en/latest/\n* https://www.python.org/dev/peps/pep-0333/\n* https://pypi.python.org/pypi/martian\n* https://pypi.python.org/pypi/zc.buildout/2.4.0\n* http://grok.zope.org/documentation/tutorial/grok-poller-tutorial/adapters\n* http://www.fanstatic.org/en/latest/\n\n\nAbout us\n========\nWe are the IT Services of Biel/Bienne, Switzerland.\nhttp://foss.biel-bienne.ch/blog/\n\nChangelog\n=========\n\n1.0.1 (2015-08-19)\n------------------\n\n- Use complete MANIFEST.in\n\n\n1.0 (2015-08-03)\n----------------\n\n- Initial public release [codeix]", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bielbienne/bst.pygasus.core", "keywords": "pygasus web framework extjs", "license": "ZPL 2.1", "maintainer": null, "maintainer_email": null, "name": "bst.pygasus.core", "package_url": "https://pypi.org/project/bst.pygasus.core/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/bst.pygasus.core/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/bielbienne/bst.pygasus.core" }, "release_url": "https://pypi.org/project/bst.pygasus.core/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "Pygasus web framework working with ExtJs", "version": "1.0.1" }, "last_serial": 1684014, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "b085f2e1063eb7ef81e3c30c1ecc8349", "sha256": "ba6b15c881ee1b7a2d651c4a9ef10b01a00da4ffb41bc5a266bc3a55d50610a9" }, "downloads": -1, "filename": "bst.pygasus.core-1.0.tar.gz", "has_sig": false, "md5_digest": "b085f2e1063eb7ef81e3c30c1ecc8349", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13800, "upload_time": "2015-08-03T17:09:41", "url": "https://files.pythonhosted.org/packages/a7/23/5b2a1101a34d471d980096dda6705d6d5df8fa759678bc2c88381eb8f353/bst.pygasus.core-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "dbdf4e49df65722b78cc953da5fe6244", "sha256": "372f32eac9c26c1060269cff981a63cf643154b52607fc891bc0a5195f6cf62c" }, "downloads": -1, "filename": "bst.pygasus.core-1.0.1.tar.gz", "has_sig": true, "md5_digest": "dbdf4e49df65722b78cc953da5fe6244", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 77475, "upload_time": "2015-08-19T13:43:41", "url": "https://files.pythonhosted.org/packages/d2/6a/0932efa5cc40d0d2ad3ff6e80e60c480cda748ea819e22b706ce0a0bd2ca/bst.pygasus.core-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dbdf4e49df65722b78cc953da5fe6244", "sha256": "372f32eac9c26c1060269cff981a63cf643154b52607fc891bc0a5195f6cf62c" }, "downloads": -1, "filename": "bst.pygasus.core-1.0.1.tar.gz", "has_sig": true, "md5_digest": "dbdf4e49df65722b78cc953da5fe6244", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 77475, "upload_time": "2015-08-19T13:43:41", "url": "https://files.pythonhosted.org/packages/d2/6a/0932efa5cc40d0d2ad3ff6e80e60c480cda748ea819e22b706ce0a0bd2ca/bst.pygasus.core-1.0.1.tar.gz" } ] }