Skip to content

Commit a499db9

Browse files
committed
merge
2 parents 4f45f63 + 700eaca commit a499db9

40 files changed

Lines changed: 2379 additions & 1062 deletions

CHANGES.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
0.9.2
2+
-----
3+
4+
Small change to work with pyramid_formalchemy 0.2
5+
add italian translations [amleczko]
6+
17
0.9.1
28
-----
3-
- add italian translations [amleczko]
9+
10+
Add some improvements to avoid failures with FF4
11+
412

513
0.9
614
---

bootstrap.py

100644100755
File mode changed.

buildout.cfg

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
[buildout]
22
newest = false
33
parts = eggs
4-
develop = . ../FormAlchemy
4+
develop = . ../FormAlchemy ../pyramid_formalchemy
55

66
[eggs]
77
recipe = zc.recipe.egg
88
eggs =
9+
Mako>=0.3.6
910
zope.schema
1011
fa.jquery
1112
WebOb
1213
PasteScript
1314
Pylons
15+
pyramid_formalchemy
1416
rstctl
1517
Sphinx
18+
lingua
1619
nose
17-
20+
interpreter = python

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# built documents.
4646
#
4747
# The short X.Y version.
48-
version = '0.1'
48+
version = '0.9'
4949
# The full version, including alpha/beta/rc tags.
5050
release = version
5151

fa/jquery/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@
2222

2323
from forms import Tabs
2424
from forms import Accordion
25+
from forms import MultiFieldSet
2526

2627
try:
2728
from fa.jquery.pylons import relation
2829
from fa.jquery.pylons import relations
2930
except ImportError:
3031
pass
3132

33+
try:
34+
from fa.jquery.pyramid import relation
35+
from fa.jquery.pyramid import relations
36+
except ImportError:
37+
pass
38+
3239
def includeme(config):
40+
config.add_translation_dirs('fa.jquery:locale/')
3341
config.add_static_view('jquery', 'fa.jquery:jquery-ui')
3442
config.override_asset(
3543
to_override="pyramid_formalchemy:templates/admin/",
@@ -38,3 +46,7 @@ def includeme(config):
3846
to_override="pyramid_formalchemy:templates/forms/",
3947
override_with="fa.jquery:templates/forms/")
4048

49+
config.add_route('markup_parser', '/markup_parser.html',
50+
view='fa.jquery.pyramid.markup_parser',
51+
)
52+

fa/jquery/app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import simplejson
88
from testing import *
99

10-
config.engine = TemplateEngine()
10+
engine = config.engine = TemplateEngine()
1111

1212
class Demo(object):
1313

@@ -43,6 +43,12 @@ def __call__(self, environ, start_response):
4343
obj.context['selectable'] = 'f'
4444
obj.context['selectables'] = ['b', 'c']
4545
fs = Form.bind(obj, data=req.POST or None)
46+
fs.engine = engine
47+
48+
fs1.engine = engine
49+
fs2.engine = engine
50+
fs3.engine = engine
51+
fs4.engine = engine
4652

4753
tabs = Tabs('my_tabs',
4854
('tab1', 'My first tab', fs1),

fa/jquery/forms.py

Lines changed: 78 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,46 @@
44
from utils import templates
55
from random import random
66

7-
class Tabs(object):
8-
"""Display FieldSet using http://jqueryui.com/demos/tabs/:
7+
class MultiFieldSetProperty(property):
8+
9+
def __init__(self, name):
10+
self.__name__ = '_' + name
11+
12+
def __get__(self, instance, klass):
13+
if instance is None:
14+
return klass
15+
return getattr(instance, self.__name__)
16+
17+
def __set__(self, instance, value):
18+
setattr(instance, self.__name__, value)
19+
for fs in instance._fs_dict.values():
20+
setattr(fs, self.__name__[1:], value)
21+
22+
class MultiFieldSet(object):
23+
"""Display more than one FieldSet:
924
1025
.. sourcecode:: python
1126
1227
>>> from testing import *
13-
>>> tabs = Tabs('my_tabs',
14-
... ('tab1', 'My first tab', fs1),
15-
... footer='<input type="submit" name="%(id)s" />')
16-
>>> tabs.append('tab2', 'The second', fs2)
17-
>>> tabs.tab1 = tabs.tab1.bind(obj1)
18-
>>> tabs.tab2.rebind(obj2)
19-
>>> print tabs.render(selected=2) #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
20-
<div id="my_tabs_...">
21-
<ul>
22-
<li><a href="#tab1_...">My first tab</a></li>
23-
<li><a href="#tab2_...">The second</a></li>
24-
</ul>
25-
<div id="tab1_...">...
26-
</div>
27-
<div id="tab2_...">...
28-
</div>
28+
>>> fs = MultiFieldSet('my_fieldsets',
29+
... ('fs1', '', fs1))
30+
>>> fs.append('fs2', 'Second fieldset', fs2)
31+
>>> fs.fs1 = fs.fs1.bind(obj1)
32+
>>> fs.fs2.rebind(obj2)
33+
>>> print fs.render() #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
34+
<div id="my_fieldsets_...">
35+
<fieldset id="fs1_...">
36+
<div>
37+
...
2938
</div>
30-
<script type="text/javascript">
31-
jQuery.fa.tabs('my_tabs_...', {"selected": 2});
32-
</script>
33-
<BLANKLINE>
34-
39+
</fieldset>
40+
<fieldset id="fs2_...">
41+
<legend><a href="#fs2_...">Second fieldset</a></legend>
42+
<div>
43+
...
44+
3545
"""
36-
engine = None
37-
template = templates.get_template('/forms/tabs.mako')
46+
template = templates.get_template('/forms/multifieldset.mako')
3847
def __init__(self, id, *fieldsets, **options):
3948
if not isinstance(id, basestring):
4049
raise TypeError('id must be a string. got %r' % (id,))
@@ -43,6 +52,10 @@ def __init__(self, id, *fieldsets, **options):
4352
self._fs_dict = {}
4453
self._bound_pk = None
4554
self._options = options
55+
self._readonly = False
56+
self._engine = None
57+
self._focus = False
58+
self._original_cls = None
4659
for fs in fieldsets:
4760
if not isinstance(fs, (tuple, list)) or len(fs) != 3:
4861
raise ValueError('A form is defined by (id, title, form) got %r' % (fs,))
@@ -55,15 +68,11 @@ def jsonify(self):
5568
fields.append((f.key, f.model_value))
5669
return dict(fields)
5770

58-
def _get_bound_pk(self):
59-
for fs in self._fs:
60-
return fs._bound_pk
61-
62-
def _set_bound_pk(self, value):
63-
for fs in self._fs:
64-
fs._bound_pk = value
65-
66-
_bound_pk = property(_get_bound_pk, _set_bound_pk)
71+
_bound_pk = MultiFieldSetProperty('_bound_pk')
72+
_request = MultiFieldSetProperty('_request')
73+
focus = MultiFieldSetProperty('focus')
74+
engine = MultiFieldSetProperty('engine')
75+
readonly = MultiFieldSetProperty('readonly')
6776

6877
@property
6978
def model(self):
@@ -90,13 +99,6 @@ def __getattr__(self, attr):
9099
else:
91100
raise AttributeError(attr)
92101

93-
def __setattr__(self, attr, fs):
94-
if attr.startswith('_') or attr in ('engine', 'readonly'):
95-
object.__setattr__(self, attr, fs)
96-
else:
97-
fs.__name__ = attr
98-
self._fs_dict[attr] = fs
99-
100102
def append(self, id, title, fs):
101103
"""add a fieldset to tabs"""
102104
fs.__name__ = id
@@ -167,14 +169,47 @@ def render(self, *ids, **options):
167169
fieldsets.append(dict(id=id, title=title, fs=fs))
168170
kwargs = dict(footer='', header='')
169171
kwargs.update(self._options)
170-
return self.template.render(id=self._id,
172+
return self.template.render_unicode(id=self._id,
171173
rid=str(random())[2:],
172174
fieldsets=fieldsets,
173175
options=dumps(options),
174176
**kwargs)
175177

176-
class Accordion(Tabs):
178+
179+
class Tabs(MultiFieldSet):
180+
"""Display FieldSet using http://jqueryui.com/demos/tabs/:
181+
182+
.. sourcecode:: python
183+
184+
>>> from testing import *
185+
>>> tabs = Tabs('my_tabs',
186+
... ('tab1', 'My first tab', fs1),
187+
... footer='<input type="submit" name="%(id)s" />')
188+
>>> tabs.append('tab2', 'The second', fs2)
189+
>>> tabs.tab1 = tabs.tab1.bind(obj1)
190+
>>> tabs.tab2.rebind(obj2)
191+
>>> print tabs.render(selected=2) #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
192+
<div id="my_tabs_...">
193+
<ul>
194+
<li><a href="#tab1_...">My first tab</a></li>
195+
<li><a href="#tab2_...">The second</a></li>
196+
</ul>
197+
<div id="tab1_...">...
198+
</div>
199+
<div id="tab2_...">...
200+
</div>
201+
</div>
202+
<script type="text/javascript">
203+
jQuery.fa.tabs('my_tabs_...', {"selected": 2});
204+
</script>
205+
<BLANKLINE>
206+
207+
"""
208+
template = templates.get_template('/forms/tabs.mako')
209+
210+
class Accordion(MultiFieldSet):
177211
"""Work like :class:`~fa.jquery.forms.Tabs` but use
178212
http://jqueryui.com/demos/accordion/
179213
"""
180214
template = templates.get_template('/forms/accordion.mako')
215+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Selectmenu
2+
----------------------------------*/
3+
.ui-selectmenu { display: block; display: inline-block; position: relative; height: 2.2em; vertical-align: middle; text-decoration: none; overflow: hidden; zoom: 1; }
4+
.ui-selectmenu-icon { position:absolute; right:6px; margin-top:-8px; top: 50%; }
5+
.ui-selectmenu-menu { padding:0; margin:0; list-style:none; position:absolute; top: 0; display: none; overflow: auto; z-index: 1005;} /* z-index: 1005 to make selectmenu work with dialog */
6+
.ui-selectmenu-open { display: block; }
7+
.ui-selectmenu-menu-popup { margin-top: -1px; }
8+
.ui-selectmenu-menu-dropdown { }
9+
.ui-selectmenu-menu li { padding:0; margin:0; display: block; border-top: 1px dotted transparent; border-bottom: 1px dotted transparent; border-right-width: 0 !important; border-left-width: 0 !important; font-weight: normal !important; }
10+
.ui-selectmenu-menu li a,.ui-selectmenu-status { line-height: 1.4em; display: block; padding: .405em 1em; outline:none; text-decoration:none; }
11+
.ui-selectmenu-menu li.ui-state-disabled a { cursor: default; }
12+
.ui-selectmenu-menu li.ui-selectmenu-hasIcon a,
13+
.ui-selectmenu-hasIcon .ui-selectmenu-status { padding-left: 20px; position: relative; margin-left: 5px; }
14+
.ui-selectmenu-menu li .ui-icon, .ui-selectmenu-status .ui-icon { position: absolute; top: 1em; margin-top: -8px; left: 0; }
15+
.ui-selectmenu-status { line-height: 1.4em; }
16+
.ui-selectmenu-open li.ui-selectmenu-item-focus a { }
17+
.ui-selectmenu-open li.ui-selectmenu-item-selected { }
18+
.ui-selectmenu-menu li span,.ui-selectmenu-status span { display:block; margin-bottom: .2em; }
19+
.ui-selectmenu-menu li .ui-selectmenu-item-header { font-weight: bold; }
20+
.ui-selectmenu-menu li .ui-selectmenu-item-content { }
21+
.ui-selectmenu-menu li .ui-selectmenu-item-footer { opacity: .8; }
22+
/* for optgroups */
23+
.ui-selectmenu-menu .ui-selectmenu-group { font-size: 1em; }
24+
.ui-selectmenu-menu .ui-selectmenu-group .ui-selectmenu-group-label { line-height: 1.4em; display:block; padding: .6em .5em 0; font-weight: bold; }
25+
.ui-selectmenu-menu .ui-selectmenu-group ul { margin: 0; padding: 0; }
26+
/* IE6 workaround (dotted transparent borders) */
27+
* html .ui-selectmenu-menu li { border-color: pink; filter:chroma(color=pink); width:100%; }
28+
* html .ui-selectmenu-menu li a { position: relative }

fa/jquery/jquery-ui/fa.jquery.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fa/jquery/jquery-ui/fa.jquery.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)