Skip to content

Commit

Permalink
manifest to include *.rst in sdists
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Nov 29, 2010
1 parent 0ba6b04 commit ad36781
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 57 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
@@ -0,0 +1 @@
include *.rst
42 changes: 34 additions & 8 deletions README.rst
@@ -1,20 +1,46 @@
=========================================
jquery.ui.dynatree widget for YAFOWIL
=========================================
==================================
jquery.dynatree widget for YAFOWIL
==================================

A widget for YAFOWIL providing an dynatree function on a text input.
A tree-widget for yafowil utilizing the jQuery plugin `jquery.dynatree.js
<http://wwwendt.de/tech/dynatree/index.html>`_ (at
`google-code <http://code.google.com/p/dynatree/>`_).

Usage
=====

TODO

Example Application
===================

To run the example application run the buildout coming with this package
(right beside setup.py) with a python 2.6.

To run the example application and tests coming with this package run
`bootstrap <http://python-distribute.org/bootstrap.py>`_ (Python 2.6 or 2.7)
with a buildout like so::

[buildout]
parts = gunicorn

[tests]
recipe = zc.recipe.testrunner
eggs =
yafowil.widget.dynatree[test]

[gunicorn]
recipe = zc.recipe.egg:scripts
eggs =
${test:eggs}
gunicorn

Start the application with::

./bin/gunicorn yafowil.widget.dynatree.example:app
./bin/gunicorn yafowil.widget.dynatree.example:app

and connect with your webbrowser to ``http://localhost:8000/``

Run the tests with::

./bin/tests


Contributors
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -4,6 +4,8 @@
version = '1.0'
shortdesc = 'Autocomplete Widget for YAFOWIL - Yet Another Form Widget Library (Python, Web)'
longdesc = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
longdesc += open(os.path.join(os.path.dirname(__file__), 'HISTORY.rst')).read()
longdesc += open(os.path.join(os.path.dirname(__file__), 'LICENSE.rst')).read()
tests_require = ['interlude', 'lxml', 'yafowil.webob', 'gunicorn', 'simplejson']

setup(name='yafowil.widget.dynatree',
Expand Down
19 changes: 14 additions & 5 deletions src/yafowil/widget/dynatree/widget.py
Expand Up @@ -5,21 +5,30 @@
from yafowil.common import input_generic_renderer
from yafowil.utils import tag

def build_inline_dynatree(tree, selected):
if tree is None: return ''
li = ''
for key in tree:
title, subtree = tree[key]
li += tag('li', title, '\n', build_inline_dynatree(subtree, selected),
**{'id': key})
return tag('ul', li)

def dynatree_renderer(widget, data):
data.attrs['input_field_type'] = 'text'
result = input_generic_renderer(widget, data)
source = widget.attrs['source']
if callable(source):
source = source(widget, data)
if isinstance(source, (list, tuple)):
source = '|'.join(source)
if isinstance(source, dict):
source_type = 'local'
widget.attrs['localtree']
elif isinstance(source, basestring):
source_type = 'remote'
result += tag('div', source,
**{'class': 'dynatree-source hiddenStructure'})
else:
raise ValueError, 'resulting source must be tuple/list or string'
result += tag('div', source,
**{'class': 'dynatree-source hiddenStructure'})
raise ValueError, 'resulting source must be [o]dict or string'
params = [('%s,%s' % (_, widget.attrs[_])) for _ in ['delay', 'minLength']]
params.append('type,%s' % source_type)
result += tag('div', '|'.join(params),
Expand Down
63 changes: 19 additions & 44 deletions src/yafowil/widget/dynatree/widget.txt
Expand Up @@ -5,52 +5,27 @@ Import requirements
>>> import yafowil.widget.dynatree
>>> from yafowil.base import factory

Render plain widget, source is string.
::
>>> widget = factory('dynatree', name='root',
... props={'source': 'http://www.foo.bar/baz'})
>>> print prettyxml(widget())
<div class="yafowil-widget-dynatree">
<input id="input-root" name="root" type="text"/>
<div class="dynatree-source hiddenStructure">http://www.foo.bar/baz</div>
<div class="dynatree-params hiddenStructure">delay,300|minLength,1|type,remote</div>
</div>
<BLANKLINE>

Render plain widget, source is list.
::
>>> widget = factory('dynatree', name='root',
... props={'source': ['foo', 'bar']})
>>> print prettyxml(widget())
<div class="yafowil-widget-dynatree">
<input id="input-root" name="root" type="text"/>
<div class="dynatree-source hiddenStructure">foo|bar</div>
<div class="dynatree-params hiddenStructure">delay,300|minLength,1|type,local</div>
</div>
<BLANKLINE>
A test tree::

Render plain widget, source is callable.
::
>>> from yafowil.widget.dynatree.widget import build_inline_dynatree
>>> tree = {'animal': ('Animals', {
... 'mammal': ('Mammals', {
... 'elephant': ('Elephant', None),
... 'ape': ('Ape', None),
... 'horse': ('Horse', None),
... }),
... 'bird': ('Birds', {
... 'duck': ('Duck', None),
... 'swan': ('Swan', None),
... 'turkey': ('Turkey', None),
... 'hummingbird': ('Hummingbird', None),
... }),
... })}

>>> def test_source(widget, data):
... return 'http://from.callable/'
>>> widget = factory('dynatree', name='root',
... props={'source': test_source})
>>> print prettyxml(widget())
<div class="yafowil-widget-dynatree">
<input id="input-root" name="root" type="text"/>
<div class="dynatree-source hiddenStructure">http://from.callable/</div>
<div class="dynatree-params hiddenStructure">delay,300|minLength,1|type,remote</div>
</div>
<BLANKLINE>
Test inline tree renderer separate::

Render widget, invalid source type.
::
>>> widget = factory('dynatree', name='root',
... props={'source': None})
>>> widget()
Traceback (most recent call last):
...
ValueError: resulting source must be tuple/list or string
>>> html = build_inline_dynatree(tree, [])
>>> print prettyxml(html)



0 comments on commit ad36781

Please sign in to comment.