AtributeError: _request in fa.query Tabs Class

6 views
Skip to first unread message

Sergio Gattas

unread,
Oct 25, 2011, 1:40:19 PM10/25/11
to FormAlchemy
I tried to implement Tabs Class in fa.jquery following the example in
http://www.gawel.org/docs/fa.jquery/modules/fa.jquery.forms.html
but when i render the tabs receive this error: AttributeError:
_request


>>> tabs.render()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
/home/sergio/WorkArea/Codigo/SmD/env/lib/python2.7/site-packages/
pyramid/paster.pyc in <module>()
----> 1 tab.render()

/home/sergio/WorkArea/Codigo/SmD/env/lib/python2.7/site-packages/fa/
jquery/forms.pyc in render(self, *ids, **options)
175 fieldsets=fieldsets,
176 options=dumps(options),
--> 177
F_=get_translator(request=self._request),
178 **kwargs)
179

/home/sergio/WorkArea/Codigo/SmD/env/lib/python2.7/site-packages/fa/
jquery/forms.pyc in __getattr__(self, attr)
99 return self._fs_dict.get(attr)
100 else:
--> 101 raise AttributeError(attr)
102
103 def append(self, id, title, fs):

AttributeError: _request


Regards,

Sergio

Gaël Pasgrimaud

unread,
Oct 25, 2011, 2:01:40 PM10/25/11
to forma...@googlegroups.com
Hi,

On Tue, Oct 25, 2011 at 7:40 PM, Sergio Gattas <gattas...@gmail.com> wrote:
> I tried to implement Tabs Class in fa.jquery following the example in
> http://www.gawel.org/docs/fa.jquery/modules/fa.jquery.forms.html
> but when i render the tabs receive this error: AttributeError:
> _request
>

I've fixed that in the github repository:
https://github.com/FormAlchemy/fa.jquery

fa.jquery has not been released since a long time... The "problem" is
that fa.jquery now use fanstatic to serve js/css resources. It work
fine with pyramid but I need to check/backport that stuff so it can
work with pylons too.

Regards,

Gael

> --
> You received this message because you are subscribed to the Google Groups "FormAlchemy" group.
> To post to this group, send email to forma...@googlegroups.com.
> To unsubscribe from this group, send email to formalchemy...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/formalchemy?hl=en.
>
>

Sergio Gattas

unread,
Oct 25, 2011, 2:12:37 PM10/25/11
to FormAlchemy
Gael, thanks for your help. Just to be clear my example was with
pyramid (last stable version). I will clone the repo and see how it
goes.

Regards,

Sergio

On Oct 25, 3:01 pm, Gaël Pasgrimaud <g...@gawel.org> wrote:
> Hi,
>

Sergio Gattas

unread,
Oct 26, 2011, 10:06:17 AM10/26/11
to FormAlchemy
Gael, i installed the github version as you recommended me but still
have the error. I can render the tabs individually , but cant render
the form Tabs.

Next, my example

>>> fs1
>>> <FieldSet (configured) with ['_job_sdate', '_parent_sdate', 'locked', 'wrongtries', 'temppass', 'can_login', 'name', 'valid', 'lastname', '_email', 'sdate', '_edate', '_gender']>

>>> fs2
>>> <FieldSet (configured) with ['name', 'valid', 'default_fl', 'name_es', 'name_pt', 'users']>

>>> tab = Tabs('my_tabs', ('tab1', 'My first tab', fs1))

>>> tab.append('tab2', 'The second', fs2)

>>> tab.tab1=tab.tab1.bind(User)

>>> tab.tab2.rebind(Job)

>>> tab.tab1.render()
>>> literal(u'\n\n\n\n <div class="fa_field ui-widget">\n <div class="label">\n \n <label class="field_req" for="User-_-_job_sdate">Job ......

>>> tab.tab2.render()
>>> literal(u'\n\n\n\n <div class="fa_field ui-widget">\n <div class="label">\n \n <label class="field_req" for="Job-_-name">Name</label .......

>>> tab.render()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
/home/sergio/WorkArea/Codigo/SmD/env/lib/python2.7/site-packages/
pyramid/paster.pyc in <module>()
----> 1 tab.render()

/home/sergio/WorkArea/Codigo/SmD/env/lib/python2.7/site-packages/fa/
jquery/forms.pyc in render(self, *ids, **options)
175 fieldsets=fieldsets,
176 options=dumps(options),
--> 177
F_=get_translator(request=self._request),
178 **kwargs)
179

/home/sergio/WorkArea/Codigo/SmD/env/lib/python2.7/site-packages/fa/
jquery/forms.pyc in __getattr__(self, attr)
99 return self._fs_dict.get(attr)
100 else:
--> 101 raise AttributeError(attr)
102
103 def append(self, id, title, fs):

AttributeError: _request

>>> tab
>>> <fa.jquery.forms.Tabs at 0xbe542ec>


Thanks in advance,

Sergio

Gaël Pasgrimaud

unread,
Oct 26, 2011, 11:26:18 AM10/26/11
to forma...@googlegroups.com
Hi,

You never use a request here. You must set it.

tab._request = request is ok

tab.bind(model, request=request) work too but bind your tab to only one model

Sergio Gattas

unread,
Oct 27, 2011, 8:28:58 AM10/27/11
to FormAlchemy
Gael, hi. Thanks for your support.

I set the _request and now i can see the tab build.

>>> tab
>>> <fa.jquery.forms.Tabs at 0xc0e17ac>
>>> tab.render()
>>> u'<div id="my_tabs_378403861673">\n<ul>\n<li><a href="#tab1_378403861673">My first tab</a></li>\n<li><a href="#tab2_378403861673">The second</a></li>\n</ul>\n<div id="tab1 .... '

But when i publish this object in the mako tamplate, it looks like a
string and not as object.


Thanks in advance

Sergio

On 26 oct, 12:26, Gaël Pasgrimaud <g...@gawel.org> wrote:
> Hi,
>

Gaël Pasgrimaud

unread,
Oct 27, 2011, 9:07:58 AM10/27/11
to forma...@googlegroups.com
On Thu, Oct 27, 2011 at 2:28 PM, Sergio Gattas <gattas...@gmail.com> wrote:
> Gael, hi. Thanks for your support.
>
> I set the _request and now i can see the tab build.
>
>>>> tab
>>>> <fa.jquery.forms.Tabs at 0xc0e17ac>
>>>> tab.render()
>>>>  u'<div id="my_tabs_378403861673">\n<ul>\n<li><a href="#tab1_378403861673">My first tab</a></li>\n<li><a href="#tab2_378403861673">The second</a></li>\n</ul>\n<div id="tab1 .... '
>
> But when i publish this object in the mako tamplate, it looks like a
> string and not as object.

You need to mark it as safe. ${form.render()|n} in mako if I remember well

Sergio Gattas

unread,
Oct 27, 2011, 10:42:44 AM10/27/11
to FormAlchemy
Work fine.
Thanks a lot for your help.

Sergio

On 27 oct, 10:07, Gaël Pasgrimaud <g...@gawel.org> wrote:
Reply all
Reply to author
Forward
0 new messages