{
"info": {
"author": "Christian Scholz",
"author_email": "cs@comlounge.net",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities"
],
"description": ".. _intro:\n\n=========================\nIntroduction and Tutorial\n=========================\n\nSetting up resources\n====================\n\nHere is an example on how to use it with CSS resources. \n\nFirst we setup some resources::\n\n from quantumcore.resources import CSSResourceManager, css_from_pkg_stream\n from quantumcore.resources import JSResourceManager, js_from_pkg_stream, jst_from_pkg_stream\n \n r1 = css_from_pkg_stream(__name__, \n 'static/css/screen.css', \n merge=True, \n auto_reload=True)\n r2 = css_from_pkg_stream(__name__, \n 'static/css/addons.css', \n merge=True, \n auto_reload=True)\n r3 = css_from_pkg_stream(__name__, \n 'static/css/print.css', \n merge=True, \n name=\"print\",\n auto_reload=True)\n css_manager = CSSResourceManager([r1,r2,r3], \n prefix_url=\"/css\", \n auto_reload=True)\n\n # JS\n js_manager = JSResourceManager([ \n js_from_pkg_stream(__name__, \n 'static/js/jquery.json-2.2.min.js', \n merge=True, prio=2),\n js_from_pkg_stream(__name__, \n 'static/js/jquery.cookie.js', \n merge=True, \n minimize_method=\"jsmin\",\n prio=3), \n ], prefix_url=\"/js\", auto_reload=True)\n\nThis defines two CSS and two JS resources. \n\nInstantiating resources\n***********************\n\nA resource corresponds to one file on the filesystem. Here we use a shortcut called ``js_from_pkg_stream`` and ``css_from_pkg_stream`` to load a file from a package. \n\nMandatory common parameters for those functions are:\n\n* The ``__name__`` is being used for identifying the filename inside a package.\n* The path is the path inside the package the ``__name__`` belongs to.\n\nOptional arguments are:\n\n* ``merge`` defines if the resource is allowed to be merged with other similar resources. Default is ``True``.\n* With ``prio`` you can define the order of the resources inside a resource manager. Resources with lower numbers are loaded first. Default is ``1``.\n* ``name`` is an optional name under which resources can be clustered together. Resources with the same name can be retrieved together then. It defaults to ``\"\"``. In the example the first two CSS resources will be retrieved together because they both have the same empty name. \n* ``processors`` define an optional list of processor functions which take the resource contents as input and output another (e.g. compressed) version.\n* ``auto_reload`` defines whether the resource can be reloaded or not. Note that this must be set in the Resource and the Resource Manager.\n\nCSS specific parameters\n-----------------------\n\n* ``media`` fdefines the media type to be used for this stylesheet, e.g. ``print`` or ``screen``. It can be a string or a list of strings. Default is ``['screen', 'projection']``.\n\nJS specific parameters\n----------------------\n\n* ``minimize_method`` is either ``\"jsmin\"`` or ``None`` and if the first is given then the JavaScript code will also be minified, meaning the removal of whitespaces and shortening of variables.\n\nInstantiating the Resource Classes\n----------------------------------\n\nIn case you have a string you can also directly instantiating the ``CSSResource`` or\n``JSResource`` class::\n\n r = CSSResource(\n source = u'my CSS',\n minimize_method = None, \n media = ['projection', 'screen'],\n type_ = u'text/css',\n ... \n )\n \n r = JSResource(\n source = u'my JS',\n minimize_method = None, \n type_ = u'text/css',\n ... \n )\n \nExcept ``__name__`` and ``filename`` all the above mentioned parameters apply.\n\n\nResource Managers\n*****************\n\nIn the example above we have seen resource managers like this::\n\n css_manager = CSSResourceManager([r1,r2,r3], \n prefix_url=\"/css\", \n auto_reload=True)\n \n js_manager = JSResourceManager([.....],\n prefix_url=\"/js\", \n auto_reload=True)\n \nThey handle all the CSS and JS files used in a project eventually grouped into clusters.\n\nBoth versions take a ``prefix_url`` under which they are served later on. This defines which URLs will be computed by the manager instance.\n\nOptional parameters are:\n\n* ``no_merge`` can be ``True`` or ``False`` and defines whether the resources are merged into clusters or not.\n* ``auto_reload`` defines whether the manager should test if resources have been changed and should be reloaded. This only works if the resources have ``auto_reload`` set to ``True`` as well.\n\nWe can also add resources later::\n\n css_manager.append(resource3)\n js_manager.append(resource4)\n\nNow we can pass this resource object to a template, e.g. to a Chameleon template::\n\n template.render(js_manager = js_manager, css_manager = css_manager)\n\nThe template code then looks like this::\n\n \n \n\nThis will render links to all the unnamed clusters (means resources with no ``name`` parameter\ngiven). You can also render links to all resources with a certain name like this::\n\n \n\nwill render all resources with ``name='ie'``.\n\nIn the resulting HTML this will look similar to this::\n\n \n \n\n \n\nAs you can see the resources are clustered together into files if possible. Moreover a cache key is given to each resource link which will change if the contents change.\n\n\nServing resources\n*****************\n\nTo serve those files we have to pass the URL to the resource registry. Inside a WSGI app this might look like this::\n\n\n def __call__(self, environ, start_response):\n path = environ['PATH_INFO'].split(\"/\")\n\n if path[1]==\"css\":\n css_manager.render_wsgi(environ, start_response)\n elif path[1]==\"js\":\n js_manager.render_wsgi(environ, start_response)\n\n\nThis will take the path inside the WSGI environment and check if it matches one of the generated URLs.\n\nWithout WSGI it might look like this::\n\n code, data, headers = resources.render(url)\n \n\n``data`` is an iterator with the merged and minimized CSS file, ``code`` is the return code, usually ``200 Ok``. \n``headers`` is a list of ``(key, value)`` tuples.\n\n\n\n\n\n\n\n\n\nChange history\n**************\n\n0.6 - (unreleased)\n******************\n\n* fixed naming bug: if resources have different names and different prios they only have been sorted\n by priority. This led to merge errors as the name kept changing while trying to merge.\n Now they are sorted by name first and priority then.\n\n\n0.5 - (2010/04/06)\n******************\n\ninitial release\n\n\nDownload\n********",
"description_content_type": null,
"docs_url": null,
"download_url": "UNKNOWN",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "http://quantumcore.org",
"keywords": "resources web manager registry css js javascript templates quantumcore",
"license": "MIT",
"maintainer": null,
"maintainer_email": null,
"name": "quantumcore.resources",
"package_url": "https://pypi.org/project/quantumcore.resources/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/quantumcore.resources/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "http://quantumcore.org"
},
"release_url": "https://pypi.org/project/quantumcore.resources/0.5.4/",
"requires_dist": null,
"requires_python": null,
"summary": "A resource manager for CSS and JS",
"version": "0.5.4"
},
"last_serial": 798351,
"releases": {
"0.5.1dev": [
{
"comment_text": "",
"digests": {
"md5": "014878789ba74ad01b9c2359d0315dab",
"sha256": "ffde98aac3680dd7534af85ae1326a519dabe1c194ea25d2ecf52828c107381a"
},
"downloads": -1,
"filename": "quantumcore.resources-0.5.1dev.tar.gz",
"has_sig": false,
"md5_digest": "014878789ba74ad01b9c2359d0315dab",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25448,
"upload_time": "2010-04-06T15:50:48",
"url": "https://files.pythonhosted.org/packages/31/15/b9f3c969eed42898461e8eca915a50a861fb875e970c542e70d7331d23d6/quantumcore.resources-0.5.1dev.tar.gz"
}
],
"0.5.2dev": [
{
"comment_text": "",
"digests": {
"md5": "289e6097764924dae9a3c897addc5a8c",
"sha256": "8c4b1a94eeb0e0506a81111bee05b1c4b2dc1a4c84819026f8fd5876eb06da38"
},
"downloads": -1,
"filename": "quantumcore.resources-0.5.2dev.tar.gz",
"has_sig": false,
"md5_digest": "289e6097764924dae9a3c897addc5a8c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25508,
"upload_time": "2010-04-06T15:54:00",
"url": "https://files.pythonhosted.org/packages/32/4d/08fa69175c0180696996b6baf01fb383f2d767ff08cde637ea0b07c362ac/quantumcore.resources-0.5.2dev.tar.gz"
}
],
"0.5.3dev": [
{
"comment_text": "",
"digests": {
"md5": "e334c4ed1dd2f91a3d2604a9f543442e",
"sha256": "b92a6e554e77b25a6506bc62e597ef2e37188ebebbf0cca58f3b044d0f320566"
},
"downloads": -1,
"filename": "quantumcore.resources-0.5.3dev.tar.gz",
"has_sig": false,
"md5_digest": "e334c4ed1dd2f91a3d2604a9f543442e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25485,
"upload_time": "2010-04-06T16:05:41",
"url": "https://files.pythonhosted.org/packages/19/c2/18b547717cf08ede2c0026faf1c7634dc975df79b21af76b95ae1d0a81c3/quantumcore.resources-0.5.3dev.tar.gz"
}
],
"0.5.4": [
{
"comment_text": "",
"digests": {
"md5": "b9362e6b72e9f26cde4c88c4feb4f7b6",
"sha256": "288d6260fe3446e8e03e1e3a1a7209c91051b0571cf9c41d8c60cded9ef01ca0"
},
"downloads": -1,
"filename": "quantumcore.resources-0.5.4.tar.gz",
"has_sig": false,
"md5_digest": "b9362e6b72e9f26cde4c88c4feb4f7b6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 26720,
"upload_time": "2010-12-28T17:21:20",
"url": "https://files.pythonhosted.org/packages/c6/bd/3f1eef09059118dca4e397ac24d96d84c855756873e6baf9e31bca76e018/quantumcore.resources-0.5.4.tar.gz"
}
],
"0.5dev": [
{
"comment_text": "",
"digests": {
"md5": "c314d2f87e6141e279e4791a34a4e4fd",
"sha256": "e9e2ba75edfba9d827f349cae0bbf3bae6caa996dd99ab024410b5a5a839f73a"
},
"downloads": -1,
"filename": "quantumcore.resources-0.5dev.tar.gz",
"has_sig": false,
"md5_digest": "c314d2f87e6141e279e4791a34a4e4fd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25432,
"upload_time": "2010-04-06T15:47:41",
"url": "https://files.pythonhosted.org/packages/7f/19/bf2d67908e9f638c3154d1a65a8c619cd396c4ee4f6e21811bb7e7cb9a49/quantumcore.resources-0.5dev.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "b9362e6b72e9f26cde4c88c4feb4f7b6",
"sha256": "288d6260fe3446e8e03e1e3a1a7209c91051b0571cf9c41d8c60cded9ef01ca0"
},
"downloads": -1,
"filename": "quantumcore.resources-0.5.4.tar.gz",
"has_sig": false,
"md5_digest": "b9362e6b72e9f26cde4c88c4feb4f7b6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 26720,
"upload_time": "2010-12-28T17:21:20",
"url": "https://files.pythonhosted.org/packages/c6/bd/3f1eef09059118dca4e397ac24d96d84c855756873e6baf9e31bca76e018/quantumcore.resources-0.5.4.tar.gz"
}
]
}