Re: [web2py] Re: Working with CAS

2011-06-23 Thread sagar nigade
Massimo, Thanks for your reply now  I am working with new version 1.96.4 but
now as given in cas_auth.py

I have update my db.py with

from gluon.contrib.login_methods.cas_auth import CasAuth
auth.define_tables(username=True)
auth.settings.login_form=CasAuth(
urlbase = "http://127.0.0.1:8000/casapp2/default/user/cas
",actions=['login','validate','logout'])

still geting error:

Below is the tracebak

Traceback (most recent call last):
  File "D:\web2py_src_1.96.4\web2py\gluon\restricted.py", line 192, in
restricted
exec ccode in environment
  File "D:/web2py_src_1.96.4/web2py/applications/casapp1/controllers/default.py"
,
line 91, in 
  File "D:\web2py_src_1.96.4\web2py\gluon\globals.py", line 137, in 
self._caller = lambda f: f()
  File "D:/web2py_src_1.96.4/web2py/applications/casapp1/controllers/default.py"
,
line 53, in user
return dict(form=auth())
  File "D:\web2py_src_1.96.4\web2py\gluon\tools.py", line 1069, in __call__
return getattr(self,args[0])()
  File "D:\web2py_src_1.96.4\web2py\gluon\tools.py", line 1631, in login
redirect(cas.login_url(next))
  File "D:\web2py_src_1.96.4\web2py\gluon\contrib\login_methods\cas_auth.py",
line 62, in login_url
current.session.token=self._CAS_login()
  File "D:\web2py_src_1.96.4\web2py\gluon\contrib\login_methods\cas_auth.py",
line 116, in _CAS_login
except ExpatError: pass
NameError: global name 'ExpatError' is not defined




-- Forwarded message --
> From: Massimo Di Pierro 
> Date: Wed, Jun 22, 2011 at 8:38 PM
> Subject: [web2py] Re: Working with CAS
> To: web2py-users 
>
>
> From this error:
>
> giving me err in auth.settings.cas_domains.append
> AttributeError: 'NoneType' object has no attribute 'append'
>
> I believe you are running an old version of web2py that does not
> support the new CAS mechanism. Please try the latest one.
>
> On Jun 22, 9:50 am, sagar  wrote:
> > Hi
> >
> > I am trying to using use cas as given in online document
> >
> > when I  am using this :
> >
> > CAS.login_url='https://www.web2py.com/cas/cas/login'
> > CAS.check_url='https://www.web2py.com/cas/cas/check'
> > CAS.logout_url='https://www.web2py.com/cas/cas/logout'
> > CAS.my_url='http://127.0.0.1:8000/testauth/default/user/login'
> >
> > if not session.token and not request.function=='login':
> > redirect(URL('login'))
> > def login():
> > session.token=CAS.login(request)
> > id,email,name=session.token
> > return dict()
> > def logout():
> > session.token=None
> > CAS.logout()
> >
> > when i doing this come to know that
> > web2py app now has a built-in CAS consumer and provider
> >
> > while trying this(as per given there)
> >
> > auth.settings.cas_domains.append('http://consumer.com')
> > Consumer how to:
> > auth = Auth(db,cas_provider='http://provider.com/providerapp/default/
> > user/cas')
> >
> > giving me err in auth.settings.cas_domains.append
> >
> > AttributeError: 'NoneType' object has no attribute 'append'
> >
> > And while trying this one earliar from your post
> >
> > In app1 db.py
> > from gluon.contrib.login_methods.cas_auth import CasAuth
> > auth.define_tables(username=True)
> > auth.settings.login_form=CasAuth(globals(),urlbase = "http://
> > 127.0.0.1:8000/app2/default/user/login",
> > actions=['login','check','logout'])
> >
> > I got authenticated at app2 but not got redirected to app1.
> >
> > Please help How to get CAS working?
>
>


Re: [web2py] Re: Working with CAS

2011-06-23 Thread sagar nigade
Its done there was some setting issues.

On Thu, Jun 23, 2011 at 1:16 PM, sagar nigade wrote:

> Massimo, Thanks for your reply now  I am working with new version 1.96.4
> but now as given in cas_auth.py
>
> I have update my db.py with
>
> from gluon.contrib.login_methods.cas_auth import CasAuth
> auth.define_tables(username=True)
> auth.settings.login_form=CasAuth(
> urlbase = "http://127.0.0.1:8000/casapp2/default/user/cas
> ",actions=['login','validate','logout'])
>
> still geting error:
>
> Below is the tracebak
>
> Traceback (most recent call last):
>   File "D:\web2py_src_1.96.4\web2py\gluon\restricted.py", line 192, in 
> restricted
>
> exec ccode in environment
>
>   File 
> "D:/web2py_src_1.96.4/web2py/applications/casapp1/controllers/default.py" 
> , 
> line 91, in 
>
>   File "D:\web2py_src_1.96.4\web2py\gluon\globals.py", line 137, in 
>
> self._caller = lambda f: f()
>
>   File 
> "D:/web2py_src_1.96.4/web2py/applications/casapp1/controllers/default.py" 
> , 
> line 53, in user
>
> return dict(form=auth())
>
>   File "D:\web2py_src_1.96.4\web2py\gluon\tools.py", line 1069, in __call__
>
> return getattr(self,args[0])()
>
>   File "D:\web2py_src_1.96.4\web2py\gluon\tools.py", line 1631, in login
>
> redirect(cas.login_url(next))
>
>   File "D:\web2py_src_1.96.4\web2py\gluon\contrib\login_methods\cas_auth.py", 
> line 62, in login_url
>
> current.session.token=self._CAS_login()
>
>   File "D:\web2py_src_1.96.4\web2py\gluon\contrib\login_methods\cas_auth.py", 
> line 116, in _CAS_login
>
> except ExpatError: pass
> NameError: global name 'ExpatError' is not defined
>
>
>
>
> -- Forwarded message --
>> From: Massimo Di Pierro 
>> Date: Wed, Jun 22, 2011 at 8:38 PM
>> Subject: [web2py] Re: Working with CAS
>> To: web2py-users 
>>
>>
>> From this error:
>>
>> giving me err in auth.settings.cas_domains.append
>> AttributeError: 'NoneType' object has no attribute 'append'
>>
>> I believe you are running an old version of web2py that does not
>> support the new CAS mechanism. Please try the latest one.
>>
>> On Jun 22, 9:50 am, sagar  wrote:
>> > Hi
>> >
>> > I am trying to using use cas as given in online document
>> >
>> > when I  am using this :
>>
>> >
>> > CAS.login_url='https://www.web2py.com/cas/cas/login'
>> > CAS.check_url='https://www.web2py.com/cas/cas/check'
>> > CAS.logout_url='https://www.web2py.com/cas/cas/logout'
>> > CAS.my_url='http://127.0.0.1:8000/testauth/default/user/login'
>> >
>> > if not session.token and not request.function=='login':
>> > redirect(URL('login'))
>> > def login():
>> > session.token=CAS.login(request)
>> > id,email,name=session.token
>> > return dict()
>> > def logout():
>> > session.token=None
>> > CAS.logout()
>> >
>> > when i doing this come to know that
>> > web2py app now has a built-in CAS consumer and provider
>> >
>> > while trying this(as per given there)
>> >
>> > auth.settings.cas_domains.append('http://consumer.com')
>> > Consumer how to:
>> > auth = Auth(db,cas_provider='http://provider.com/providerapp/default/
>> > user/cas')
>> >
>> > giving me err in auth.settings.cas_domains.append
>> >
>> > AttributeError: 'NoneType' object has no attribute 'append'
>> >
>> > And while trying this one earliar from your post
>> >
>> > In app1 db.py
>> > from gluon.contrib.login_methods.cas_auth import CasAuth
>> > auth.define_tables(username=True)
>> > auth.settings.login_form=CasAuth(globals(),urlbase = "http://
>> > 127.0.0.1:8000/app2/default/user/login",
>> > actions=['login','check','logout'])
>> >
>> > I got authenticated at app2 but not got redirected to app1.
>> >
>> > Please help How to get CAS working?
>>
>>
>
>


[web2py] Re: The multi-tenant feature and validators ...

2011-06-23 Thread rif
I used this feature like this:

db._common_fields.append(Field('request_tenant',default=auth.user_id,writable=False,readable=False))

so every user would have it's own data.

It seeams that IS_IN_DB is not aware of the request_tenant and also if you 
mark a filed as unique it will be unique across accounts. So it will say 
some data is not unique even if I have not entered it before but someone 
else did. 


[web2py] Re: web2py and async monkey patching

2011-06-23 Thread graeme
Thanks for the reply.

So what anyserver.py does with gevent is not recommended? It calls
monkey.patch_all() which patches threading to use green threads.

Is this something that ought to work but is just untested? web2py is
pure python so the monkey patching should make thread locals into
greenlet locals, right? If that is so, then is the testing something I
could do myself, or does it need to be done by someone who knows the
internals of web2py?

Graeme

On Jun 23, 8:10 am, Massimo Di Pierro 
wrote:
> I am not sure this does not break the new internal web2py design that
> uses thread locals.
> I would not use async unless we have tested this more.
>
> Massimo
>
> On Jun 22, 6:44 pm, graeme  wrote:
>
>
>
>
>
>
>
> > I can see that anyserver.py uses monkey patching to make the standard
> > library cooperative with gevent.
>
> > Could the same be done with eventlet and with Gunicorn (with eventlet,
> > gevent or both)?
>
> > Eventlet has the advantages of being (AFAIK) pure python, and can
> > monkey patch psycopg as well as the standard library.
>
> > Has anyone measured whether it is significantly more memory efficient
> > to run web2py on green threads?
>
> > My use case is that I will have long running controllers (while
> > fetching data from web services). I would like it to be memory
> > efficient, but I am nt* looking for massive scalability or extreme
> > speed. I do not want it to be trivial to DOS (so I need either threads
> > or green threads to handle the long running controllers).


[web2py] Legacy database adaptation in web2py, best way?

2011-06-23 Thread DanielB
So we have a legacy database that has a suboptimal structure, but we
cannot change it right now.
What we want is to create a business layer in-between web2py and this
database so that web2py thinks it is using a much better database
structure in order for the development in web2py to be what we want
the end result to be when the database is finally restructured.

By defining a sort of virtual model in web2py (that is more how we
want the final database to look like) we can use the benefit of
creating forms very easily in web2py, and then just forward the
results to the business layer and let it take care of the real
database.

But problems arise when the web2py forms etc. assumes that the model
really has a physical database behind it, for instance the CRUD forms
where the crud.update gathers info on the record from database and
puts it in the form automatically. We want this of course but the
web2py model has no real database.

One way of doing this would be to use SQLFORM.factory and manually
inserting all the values into the inputs like so:
inputs = form.elements('input')
inputs[0]['_value'] = user.name
inputs[1]['_value'] = user.email
...
but this sort of manual work seems unnecessary for big forms

Another problem I had with CRUD forms in my case is that I really want
to make the if .accepts() call myself so that I can then call the
business layer with the database related stuff, but it seems the CRUD
forms do this call automatically?
In the case of SQLFORM.factory forms I can make the .accepts myself

Do any of you have experience in these kinds of problems? Is there a
painless way to do it?
I would be most thankful for any tips regarding this


[web2py] Running web2py on Jython

2011-06-23 Thread Richard
Hi,

has anyone running a reasonably current version of web2py running on
Jython 2.5.x? I need help with this.

>From reading the available information on the web I gained the
impression that Jython 2.5 is a fully supported platform. Wikipedia
says "web2py since v1.64.0 runs unmodified on Java with Jython 2.5,
without any known limitation". The Official (3rd Ed.) web2py Book
seems to support this claim, although the installation instructions
seem to be a bit outdated (zxJDBC is included in the 2.5.x Jython
install Jar, no need to install it separately).

The problem is, my experiences so far are very different. Here is the
reason why I am asking for help. I am facing a situation where I want
to have web2py running on a Linux host on which  I have no admin
rights. The problem is that this machine has only Python 2.4
installed. Although web2py claims to be running on Python 2.4, it
really doesn't out of the box. A backported hashlib module would have
to be additionally installed. This doesn't seem to be a viable option
for me, given my limited admin rights on this machine. A Jython
install on the other hand should pose no problem. The additional gain
of this approach is, Jython 2.5 is an officially supported Python
version (2.5.2), Python 2.4 is not.

I can only try this next week for real, but I did some preliminary
tests on my local machine during the last few days. I tried on Windows
XP with Jython 2.5.0/ 2.5.1/ 2.5.2. I tested on an old (but updated)
Ubuntu installation with Jython 2.5.2. I tested on a Linux VM running
on Virtualbox 4.0.8. The consistent result for me was that the current
web2py releases don't work on Jython. For example with R-1.90.2 and
later the welcome app shows immediately (on first access) a ticket.
Root cause has something to do with the sqlite driver
('com.ziclix.python.sql.PyConnection' object has no attribute
'create_function'). Even older versions seem to raise exceptions with
tracebacks shown in the Jython console, hinting to 'rocket' and
'multithreading'. Details available upon request.

The most 'recent' version of web2py that seems to be running with
Jython 2.5.x seems to be 1.85.2 (hg commit #907). Even #918 seems to
be working fine. Later versions don't. I diffed the sources, but
somehow couldn't make sense of it.

So that is where I am standing now. What I am doing wrong? I seem to
be quite alone with my experiences since Google didn't provide
pointers to fellow sufferers. To reiterate my question: Has anyone
running a reasonably current version of web2py running on Jython
2.5.x?

Regards,
Richard


[web2py] ekjaa

2011-06-23 Thread Massimo Di Pierro
How is behind it?

http://www.ekjaa.org/

Really good job!

massimo


[web2py] Re: The multi-tenant feature and validators ...

2011-06-23 Thread Massimo Di Pierro
Please open a ticket and I will fix it.

On Jun 23, 5:19 am, rif  wrote:
> I used this feature like this:
>
> db._common_fields.append(Field('request_tenant',default=auth.user_id,writab 
> le=False,readable=False))
>
> so every user would have it's own data.
>
> It seeams that IS_IN_DB is not aware of the request_tenant and also if you
> mark a filed as unique it will be unique across accounts. So it will say
> some data is not unique even if I have not entered it before but someone
> else did.


[web2py] Re: web2py and async monkey patching

2011-06-23 Thread Massimo Di Pierro
The test is easy:

def index():
import time
from gluon import current
print current.request.uuid
sleep(10)
print current.request.uuid
return 'done!'

call this action twice from console within less then 10 seconds from
each other what is the output?
if it looks
A
B
A
B
than the monkey patching is correct if it looks like
A
B
B
B
then it is not. If it looks like
A
A
B
B
then we are not testing right. A,B are uuids.

massimo





On Jun 23, 5:22 am, graeme  wrote:
> Thanks for the reply.
>
> So what anyserver.py does with gevent is not recommended? It calls
> monkey.patch_all() which patches threading to use green threads.
>
> Is this something that ought to work but is just untested? web2py is
> pure python so the monkey patching should make thread locals into
> greenlet locals, right? If that is so, then is the testing something I
> could do myself, or does it need to be done by someone who knows the
> internals of web2py?
>
> Graeme
>
> On Jun 23, 8:10 am, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > I am not sure this does not break the new internal web2py design that
> > uses thread locals.
> > I would not use async unless we have tested this more.
>
> > Massimo
>
> > On Jun 22, 6:44 pm, graeme  wrote:
>
> > > I can see that anyserver.py uses monkey patching to make the standard
> > > library cooperative with gevent.
>
> > > Could the same be done with eventlet and with Gunicorn (with eventlet,
> > > gevent or both)?
>
> > > Eventlet has the advantages of being (AFAIK) pure python, and can
> > > monkey patch psycopg as well as the standard library.
>
> > > Has anyone measured whether it is significantly more memory efficient
> > > to run web2py on green threads?
>
> > > My use case is that I will have long running controllers (while
> > > fetching data from web services). I would like it to be memory
> > > efficient, but I am nt* looking for massive scalability or extreme
> > > speed. I do not want it to be trivial to DOS (so I need either threads
> > > or green threads to handle the long running controllers).


[web2py] Re: Running web2py on Jython

2011-06-23 Thread Massimo Di Pierro
I have not tried in some time.What errors do you get?

On Jun 23, 3:50 am, Richard  wrote:
> Hi,
>
> has anyone running a reasonably current version of web2py running on
> Jython 2.5.x? I need help with this.
>
> From reading the available information on the web I gained the
> impression that Jython 2.5 is a fully supported platform. Wikipedia
> says "web2py since v1.64.0 runs unmodified on Java with Jython 2.5,
> without any known limitation". The Official (3rd Ed.) web2py Book
> seems to support this claim, although the installation instructions
> seem to be a bit outdated (zxJDBC is included in the 2.5.x Jython
> install Jar, no need to install it separately).
>
> The problem is, my experiences so far are very different. Here is the
> reason why I am asking for help. I am facing a situation where I want
> to have web2py running on a Linux host on which  I have no admin
> rights. The problem is that this machine has only Python 2.4
> installed. Although web2py claims to be running on Python 2.4, it
> really doesn't out of the box. A backported hashlib module would have
> to be additionally installed. This doesn't seem to be a viable option
> for me, given my limited admin rights on this machine. A Jython
> install on the other hand should pose no problem. The additional gain
> of this approach is, Jython 2.5 is an officially supported Python
> version (2.5.2), Python 2.4 is not.
>
> I can only try this next week for real, but I did some preliminary
> tests on my local machine during the last few days. I tried on Windows
> XP with Jython 2.5.0/ 2.5.1/ 2.5.2. I tested on an old (but updated)
> Ubuntu installation with Jython 2.5.2. I tested on a Linux VM running
> on Virtualbox 4.0.8. The consistent result for me was that the current
> web2py releases don't work on Jython. For example with R-1.90.2 and
> later the welcome app shows immediately (on first access) a ticket.
> Root cause has something to do with the sqlite driver
> ('com.ziclix.python.sql.PyConnection' object has no attribute
> 'create_function'). Even older versions seem to raise exceptions with
> tracebacks shown in the Jython console, hinting to 'rocket' and
> 'multithreading'. Details available upon request.
>
> The most 'recent' version of web2py that seems to be running with
> Jython 2.5.x seems to be 1.85.2 (hg commit #907). Even #918 seems to
> be working fine. Later versions don't. I diffed the sources, but
> somehow couldn't make sense of it.
>
> So that is where I am standing now. What I am doing wrong? I seem to
> be quite alone with my experiences since Google didn't provide
> pointers to fellow sufferers. To reiterate my question: Has anyone
> running a reasonably current version of web2py running on Jython
> 2.5.x?
>
> Regards,
> Richard


[web2py] Re: I created a little app to be able to share some files over the net without authentication

2011-06-23 Thread szimszon
Update of the app:


Changelog

110623 

   - generating MD5Sum with hashlib for uploaded files 
   - little design change 




Re: [web2py] Running web2py on Jython

2011-06-23 Thread Pierre Thibault
2011/6/23 Richard 

> Hi,
>
> has anyone running a reasonably current version of web2py running on
> Jython 2.5.x? I need help with this.
>
>
Hello Richard,

Yes, I did a try but I didn't wanted to go very far with that. I was just
curious about giving it a try.

I had a problem with the database stuff I remember. I think this is the same
issue that you have.

web2py is no longer working with Python 2.4. Python 2.4 is old stuff now.

Here I wrote about using SQLite with Jython. I think this can help:
http://pierrethibault.posterous.com/?tag=jython&page=2
-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2) 


[web2py] Re: Legacy database adaptation in web2py, best way?

2011-06-23 Thread Anthony
On Thursday, June 23, 2011 7:15:34 AM UTC-4, DanielB wrote: 
>
> Another problem I had with CRUD forms in my case is that I really want 
> to make the if .accepts() call myself so that I can then call the 
> business layer with the database related stuff, but it seems the CRUD 
> forms do this call automatically? 
> In the case of SQLFORM.factory forms I can make the .accepts myself

 
If you want to do your own "if form.accepts()" calls but also want it to 
handle the database stuff, you can use SQLFORM instead of Crud (see 
http://web2py.com/book/default/chapter/07#SQLFORM). You can also use the 
various Crud _onvalidation settings to specify actions to take between 
validation and acceptance (see 
http://web2py.com/book/default/chapter/07#Settings).
 
Anthony


[web2py] How do I apply placeholder text to web2py forms?

2011-06-23 Thread Carl
I'm using custom forms in my views using this format:
{{=form.custom.widget.first_name}}

I'd like to use HTML's placeholder attribute to input tags: e.g.,


Today: what are the ways to enable this? Obviously happy to drop the
{{=form.custom.widget.first_name}} format and use something else.

Tomorrow: might it be a good idea to add placeholder attribute to
db.Field() in a similar fashion to how 'label' has already been added?


[web2py] response.write to transport index of the proper tabs from controller to the jQuery UI tabs plugin

2011-06-23 Thread Richard Vézina
Hello,

In order to get the proper tabs to render the validators message in case
they have been triggered I would like to know if I use response.write(TABS
INDEX) could be a option??

Here my set up :

*VIEW*

@import
"{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/themes/base/jquery.ui.all.css')}}";







$(function() {
var $tabs = $( "#tabs" ).tabs();
$tabs.tabs('select', {{response.write()}});
return false;
});









{{=T('folder').capitalize()}}
{{=T('volume').capitalize()}}
{{=T('tome').capitalize()}}
{{=T('report').capitalize()}}




{{=LOAD(c='ref',f='create_fvte',args='ref_fnaregistry',extension='load',ajax=False,ajax_trap=False,target='one')}}




{{=LOAD(c='ref',f='create_fvte',args='ref_vregistry',extension='load',ajax=False,ajax_trap=False,target='two')}}




{{=LOAD(c='ref',f='create_fvte',args='ref_tregistry',extension='load',ajax=False,ajax_trap=False,target='three')}}




{{=LOAD(c='ref',f='create_fvte',args='ref_eregistry',extension='load',ajax=False,ajax_trap=False,target='four')}}





*CONTROLLER*
def creation():
"""
Empty function for make it works the jQuery tabs plugin for ref_*
tables.
"""
a = None
return dict(a=a)

@auth.requires_login()
def create_fvte():
table = request.args(0)#.replace('.load','')
if auth.has_membership(auth.id_group('admin')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('technician')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('technician_c')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
else:
return dict(form=None)
if form.accepts(request.vars, session):
session.flash = T('form accepted')
if table == 'ref_fnaregistry':
redirect(URL(c='ref', f='creation#tabs-2'))
elif table == 'ref_vregistry':
redirect(URL(c='ref', f='creation#tabs-3'))
elif table == 'ref_tregistry':
redirect(URL(c='ref', f='creation#tabs-4'))
#elif table == 'ref_eregistry':
#redirect(URL(c='ref', f='creation#tabs-2'))
elif form.errors:
response.flash = T('form has errors')
#if table == 'ref_fnaregistry':
#redirect(URL(c='ref', f='creation#tabs-1'))
#elif table == 'ref_vregistry':
#redirect(URL(c='ref', f='creation#tabs-2'))
if table == 'ref_tregistry':
response.write(2)
#redirect(URL(c='ref', f='creation#tabs-3'))
#elif table == 'ref_eregistry':
#redirect(URL(c='ref', f='creation#tabs-4'))
else:
response.flash = T('please fill out the form')
return dict(form=form)


I try to avoid ajax=True,ajax_trap=False option of LOAD() cause they seem to
conflict with the official jQuery UI Tabs plugin (loading pretty slow,
reload after submit with triggered validator even worse and try to load the
entire site before loading only my proper form).

I may not completly understand usage of component...

Thanks to help.

Richard


[web2py] Re: How do I apply placeholder text to web2py forms?

2011-06-23 Thread Massimo Di Pierro
form.element(_id='...')['_placeholder']='...'

On Jun 23, 9:24 am, Carl  wrote:
> I'm using custom forms in my views using this format:
> {{=form.custom.widget.first_name}}
>
> I'd like to use HTML's placeholder attribute to input tags: e.g.,
> 
>
> Today: what are the ways to enable this? Obviously happy to drop the
> {{=form.custom.widget.first_name}} format and use something else.
>
> Tomorrow: might it be a good idea to add placeholder attribute to
> db.Field() in a similar fashion to how 'label' has already been added?


[web2py] Re: Befuddled by SQLTABLE linkto

2011-06-23 Thread DenesL
Hi Cliff,

the id field is handled as a special case inside SQLTABLE and the
linkto can only affect the _href portion of the anchor (A helper), not
the visible part.

But you can still do it:

rows=db(...).select(...)
t=SQLTABLE(rows)
for n,row in enumerate(rows):
  t[1][n][0][0] = A('Edit',_href=URL(r=request,args=[n]))

you can play with the values in row to customize it.

t[1] if the table's body
t[1][n] is the n-th row
t[1][n][0] is the first TD on that row
t[1][n][0][0] is the content (in this case the id value).



On Jun 22, 2:49 pm, Cliff  wrote:
> I'm not new to programming, but I am relatively new to Python and just
> starting my web2py journey.
>
> I have SQLTABLE working with one small exception.  For the edit link,
> I would like to replace the record id with the word "Edit."
>
> I have read the discussions in this group about using represent and
> other methods.  Represent seems to be the simplest way to go, but I
> cannot get it to work.
>
> Could someone point me to a working example?  From there I can
> probably figure it out.
>
> Thanks


[web2py] spawning response.flash in plugin_wiki page

2011-06-23 Thread blackthorne
is this possible?
how would you implement a change to make it work?

thanks


Re: [web2py] response.write to transport index of the proper tabs from controller to the jQuery UI tabs plugin

2011-06-23 Thread Anthony
I don't think you want to call response.write in your controller -- it 
appends text to the response body, so you would be adding the text before 
the rest of the response body is rendered by the view. You also shouldn't 
need to call response.write from within the view, because you can just do 
{{=whatever_you_want_to_write}}.
 
Instead, you should be able to just pass a variable to the view. In your 
controller, return dict(form=form, tab=tab), and in your view, {{=tab}}.
 
Anthony

On Thursday, June 23, 2011 10:36:39 AM UTC-4, Richard wrote:

> Hello, 
>
> In order to get the proper tabs to render the validators message in case 
> they have been triggered I would like to know if I use response.write(TABS 
> INDEX) could be a option??
>
> Here my set up :
>
> *VIEW*
>  
> @import 
> "{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/themes/base/jquery.ui.all.css')}}";
> 
>
>  src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/js/jquery-1.4.4.min.js')}}">
>  src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.core.js')}}">
>  src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.widget.js')}}">
>  src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.tabs.js')}}">
> 
> $(function() {
> var $tabs = $( "#tabs" ).tabs();
> $tabs.tabs('select', {{response.write()}});
> return false;
> });
> 
>
>
> 
> 
> 
> 
> 
> 
> {{=T('folder').capitalize()}}
> {{=T('volume').capitalize()}}
> {{=T('tome').capitalize()}}
> {{=T('report').capitalize()}}
> 
> 
> 
> 
> {{=LOAD(c='ref',f='create_fvte',args='ref_fnaregistry',extension='load',ajax=False,ajax_trap=False,target='one')}}
> 
> 
> 
> 
> {{=LOAD(c='ref',f='create_fvte',args='ref_vregistry',extension='load',ajax=False,ajax_trap=False,target='two')}}
> 
> 
> 
> 
> {{=LOAD(c='ref',f='create_fvte',args='ref_tregistry',extension='load',ajax=False,ajax_trap=False,target='three')}}
> 
> 
> 
> 
> {{=LOAD(c='ref',f='create_fvte',args='ref_eregistry',extension='load',ajax=False,ajax_trap=False,target='four')}}
> 
> 
>
> 
>
> *CONTROLLER*
>  def creation():
> """
> Empty function for make it works the jQuery tabs plugin for ref_* 
> tables.
> """
> a = None
> return dict(a=a)
> 
> @auth.requires_login()
> def create_fvte():
> table = request.args(0)#.replace('.load','')
> if auth.has_membership(auth.id_group('admin')):
> crud.settings.formstyle='divs'
> form = crud.create(db[table])
> for i in range(0,len(form[0])):
> if len(form[0][i][2][0]) > 0:
> form[0][i][0].append(SPAN((helpicon(), 
> SPAN(form[0][i][2][0])),_class='tooltip'))
> del(form[0][i][2])
> elif auth.has_membership(auth.id_group('technician')):
> crud.settings.formstyle='divs'
> form = crud.create(db[table])
> for i in range(0,len(form[0])):
> if len(form[0][i][2][0]) > 0:
> form[0][i][0].append(SPAN((helpicon(), 
> SPAN(form[0][i][2][0])),_class='tooltip'))
> del(form[0][i][2])
> elif auth.has_membership(auth.id_group('technician_c')):
> crud.settings.formstyle='divs'
> form = crud.create(db[table])
> for i in range(0,len(form[0])):
> if len(form[0][i][2][0]) > 0:
> form[0][i][0].append(SPAN((helpicon(), 
> SPAN(form[0][i][2][0])),_class='tooltip'))
> del(form[0][i][2])
> else:
> return dict(form=None)
> if form.accepts(request.vars, session):
> session.flash = T('form accepted')
> if table == 'ref_fnaregistry':
> redirect(URL(c='ref', f='creation#tabs-2'))
> elif table == 'ref_vregistry':
> redirect(URL(c='ref', f='creation#tabs-3'))
> elif table == 'ref_tregistry':
> redirect(URL(c='ref', f='creation#tabs-4'))
> #elif table == 'ref_eregistry':
> #redirect(URL(c='ref', f='creation#tabs-2'))
> elif form.errors:
> response.flash = T('form has errors')
> #if table == 'ref_fnaregistry':
> #redirect(URL(c='ref', f='creation#tabs-1'))
> #elif table == 'ref_vregistry':
> #redirect(URL(c='ref', f='creation#tabs-2'))
> if table == 'ref_tregistry':
> response.write(2)
> #redirect(URL(c='ref', f='creation#tabs-3'))
> #elif table == 'ref_eregistry':
> #redirect(URL(c='ref', f='creation#tabs-4'))
> else:
> response.flash = T('please fill out the form')
> return dict(form=form)
>
>
> I try to avoid ajax=True,ajax_trap=False option of LOAD() cause they seem 
> to conflict with the official jQuery UI Tabs plugin (loading pretty slow, 
> reload after submit with triggered validator even worse and try to load the 

Re: [web2py] response.write to transport index of the proper tabs from controller to the jQuery UI tabs plugin

2011-06-23 Thread Richard Vézina
Hello Anthony,

I can't use a var like you suggest since it popup in the component for
noting...

I am using session.MYVAR that seems to work... But I don't find the way to
get session vars in jQuery I try like this :


$(function() {
var $tabs = $( "#tabs" ).tabs();
var test1 = "{{=session.test1}}"; # OR like this :
<%{{=session.test1}}%> and with and without quote or double quote...
$tabs.tabs('select',  test1);
return false;
});


If I can get my variable value in jQuery do you think it a go work around?

Richard

On Thu, Jun 23, 2011 at 11:09 AM, Anthony  wrote:

> I don't think you want to call response.write in your controller -- it
> appends text to the response body, so you would be adding the text before
> the rest of the response body is rendered by the view. You also shouldn't
> need to call response.write from within the view, because you can just do
> {{=whatever_you_want_to_write}}.
>
> Instead, you should be able to just pass a variable to the view. In your
> controller, return dict(form=form, tab=tab), and in your view, {{=tab}}.
>
> Anthony
>
> On Thursday, June 23, 2011 10:36:39 AM UTC-4, Richard wrote:
>
>> Hello,
>>
>> In order to get the proper tabs to render the validators message in case
>> they have been triggered I would like to know if I use response.write(TABS
>> INDEX) could be a option??
>>
>> Here my set up :
>>
>> *VIEW*
>>  
>> @import "{{=URL('static','plugin_**added/jquery-ui-1.8.9.custom/**
>> development-bundle/themes/**base/jquery.ui.all.css')}}";
>> 
>>
>> > src="{{=URL('static','plugin_**added/jquery-ui-1.8.9.custom/**
>> js/jquery-1.4.4.min.js')}}">
>>