[web2py] Get a error when I click on - admin (currently running) --> Clean button

2011-10-26 Thread Rahul
Hi All,
  Not sure if this issue with 1.99.2 is reported -

When I am running web2py on my local (Windows 7, IE9 or Firefox
latest)  and going to Installed applications and do the below -

admin (currently running)
Click --> Clean button

I get the below ticket -

Traceback (most recent call last):  File "D:\WEB2PY\web2py\gluon
\restricted.py", line 194, in restrictedexec ccode in environment
File "D:/WEB2PY/web2py/applications/admin/controllers/default.py",
line 1225, in   File "D:\WEB2PY\web2py\gluon\globals.py", line
149, in self._caller = lambda f: f()  File "D:/WEB2PY/
web2py/applications/admin/controllers/default.py", line 280, in
cleanupclean = app_cleanup(app, request)  File "D:\WEB2PY\web2py
\gluon\admin.py", line 117, in app_cleanupif f[:1]!='.':
recursive_unlink(os.path.join(path,f))  File "D:\WEB2PY\web2py\gluon
\fileutils.py", line 132, in recursive_unlink
os.unlink(f)WindowsError: [Error 32] The process cannot access the
file because it is being used by another process: 'D:/WEB2PY/web2py/
applications/admin/sessions/127.0.0.1-58ea1938-a028-420b-
aa3f-732661b8789d'


Code listing
127.128.129.130.131.132.133.134.135.136. if
os.path.isdir(f):for s in os.listdir(f):
recursive_unlink(os.path.join(f,s))os.rmdir(f)elif
os.path.isfile(f):os.unlink(f)def cleanpath(path):"""

 Variables
os.unlink


global os

f

'D:/WEB2PY/web2py/applications/admin/sessions/127.0.0.1-58ea1938-
a028-420b-aa3f-732661b8789d'

Thanks Rahul D


[web2py] track_changes(True) fails outside web2py

2011-10-26 Thread seongjoo
Importing track_changes has no problem in a python module outside of web2py.

from gluon.custom_import import track_changes


But after the successful import, below fails

track_changes(True)


The error message and the essence of traceback are as below:

...\gluon\custom_import.pyc in __init__(self, web2py_path)


self.__web2py_path_os_path_sep = self.web2py_path + os.path_sep


TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'


It seems that getting web2py_path fails somehow. I believe the path is 
correctly specified since importing track_changes is successful. 


[web2py] Re: add foreign key to auth_user

2011-10-26 Thread Alex
I did what you said but I still have an error...

db.define_table('tableX', )
auth.settings.extra_fields['auth_user'] = [Field('myFK_id', 'reference
tableX')]
auth.define_tables()

InternalError: (1072, u"Key column 'myFK_id' doesn't exist in table")

Why ?

On Oct 26, 7:37 am, Cliff  wrote:
> Why not define tableX before auth.define_tables?
>
> I'm doing that with a table and it seems to work.  Caveat: there's no
> controller for that table so it only gets exposed to the site owner.
>
> On Oct 25, 8:44 am, Massimo Di Pierro 
> wrote:
>
> > this will work
>
> > auth.settings.extra_fields['auth_user'] = [Field('myFK_id', 'reference
> > tableX')]
>
> > You cannot use db.tableX because that is not yet defined.
> > On Oct 25, 12:20 am, Alex  wrote:
>
> > > Hi,
> > > I have a simple question : I would like to add a foreign key to the
> > > table auth_user, but I don't know how to do that.
> > > I can add a text field easily. For example :
>
> > > auth = Auth(db)
> > > auth.settings.extra_fields['auth_user'] = [Field('city')]
> > > auth.define_tables()
>
> > > But if I do this, it doesn't work:
>
> > > auth = Auth(db)
> > > auth.settings.extra_fields['auth_user'] = [Field('myFK_id',
> > > db.tableX)]
> > > auth.define_tables()
>
> > > db.define_table('tableX', .)
>
> > > I can't find anything on the Web...
>
>


[web2py] Re: Web2Py on GAE > very slow

2011-10-26 Thread howesc
i will write something up for you soon


[web2py] Re: Domain Masking and Internet Explorer

2011-10-26 Thread horridohobbyist
Thanks. Very interesting.

Richard

On Oct 26, 7:34 pm, Anthony  wrote:
> The way your domain masking works is that a frameset is set up at the
> masking URL (stressrelief.co.nr), and your actual site is placed inside a
> frame. In that case, apparently IE doesn't pass the session cookie back to
> your application. Seehttp://adamyoung.net/IE-Blocking-iFrame-Cookies.
>
> It's probably not a good idea to use domain masking anyway (the address bar
> won't show any of your internal URLs -- nothing can be bookmarked). Just
> set up the DNS for your domain to point to your server.
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, October 26, 2011 6:35:24 PM UTC-4, horridohobbyist wrote:
>
> > Okay, I've made it easier to investigate. I've obtained a free domain
> > name with domain masking...
>
> > stressrelief.co.nr points tohttp://67.213.70.251/welcome/default/index
>
> > The first URL prevents login. The second URL does not. It's the
> > standard web2py Welcome app -- login is "richard...@hotmail.com",
> > password "Ranger".
>
> > web2py is installed on Ubuntu with the usual Apache configuration:
>
> > 
> >   WSGIDaemonProcess web2py user=www-data group=www-data
> >   WSGIProcessGroup web2py
> >   WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
>
> >   
> >     AllowOverride None
> >     Order Allow,Deny
> >     Deny from all
> >     
> >       Allow from all
> >     
> >   
>
> >   AliasMatch ^/([^/]+)/static/(.*) \
> >            /home/www-data/web2py/applications/$1/static/$2
> >   
> >     Options -Indexes
> >     Order Allow,Deny
> >     Allow from all
> >   
>
> >   
> >   Deny from all
> >   
>
> >   
> >   Deny from all
> >   
>
> >   CustomLog /var/log/apache2/access.log common
> >   ErrorLog /var/log/apache2/error.log
> > 
>
> > Richard
>
> > On Oct 26, 3:06 pm, horridohobbyist  wrote:
> > > I've discovered an issue, but I'm not sure if it is specific to
> > > web2py. It might be...
>
> > > I used domain forwarding with masking on stressrelief.drsommers.com to
> > > point tohttp://goodsexnetwork.com/stressrelief.  On Internet
> > > Explorer, this hinders the login function -- when you enter username/
> > > password, the browser simply throws you back to the login page (with
> > > no error message).
>
> > > I've gone back to domain forwarding without masking, and now it works
> > > fine.
>
> > > If you want to investigate, you should use domain forwarding with
> > > masking on the welcome app.
>
> > > Note that this issue is IE-specific. I've had no problem with Firefox,
> > > Chrome, Safari, or Opera.
>
> > > Richard


[web2py] Re: Domain Masking and Internet Explorer

2011-10-26 Thread Anthony
The way your domain masking works is that a frameset is set up at the 
masking URL (stressrelief.co.nr), and your actual site is placed inside a 
frame. In that case, apparently IE doesn't pass the session cookie back to 
your application. See http://adamyoung.net/IE-Blocking-iFrame-Cookies.

It's probably not a good idea to use domain masking anyway (the address bar 
won't show any of your internal URLs -- nothing can be bookmarked). Just 
set up the DNS for your domain to point to your server.

Anthony

On Wednesday, October 26, 2011 6:35:24 PM UTC-4, horridohobbyist wrote:
>
> Okay, I've made it easier to investigate. I've obtained a free domain 
> name with domain masking... 
>
> stressrelief.co.nr points to http://67.213.70.251/welcome/default/index 
>
> The first URL prevents login. The second URL does not. It's the 
> standard web2py Welcome app -- login is "richard...@hotmail.com", 
> password "Ranger". 
>
> web2py is installed on Ubuntu with the usual Apache configuration: 
>
>  
>   WSGIDaemonProcess web2py user=www-data group=www-data 
>   WSGIProcessGroup web2py 
>   WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py 
>
>
> AllowOverride None 
> Order Allow,Deny 
> Deny from all 
>  
>   Allow from all 
>  
>
>
>   AliasMatch ^/([^/]+)/static/(.*) \ 
>/home/www-data/web2py/applications/$1/static/$2 
>
> Options -Indexes 
> Order Allow,Deny 
> Allow from all 
>
>
>
>   Deny from all 
>
>
>
>   Deny from all 
>
>
>   CustomLog /var/log/apache2/access.log common 
>   ErrorLog /var/log/apache2/error.log 
>  
>
> Richard 
>
> On Oct 26, 3:06 pm, horridohobbyist  wrote: 
> > I've discovered an issue, but I'm not sure if it is specific to 
> > web2py. It might be... 
> > 
> > I used domain forwarding with masking on stressrelief.drsommers.com to 
> > point tohttp://goodsexnetwork.com/stressrelief.  On Internet 
> > Explorer, this hinders the login function -- when you enter username/ 
> > password, the browser simply throws you back to the login page (with 
> > no error message). 
> > 
> > I've gone back to domain forwarding without masking, and now it works 
> > fine. 
> > 
> > If you want to investigate, you should use domain forwarding with 
> > masking on the welcome app. 
> > 
> > Note that this issue is IE-specific. I've had no problem with Firefox, 
> > Chrome, Safari, or Opera. 
> > 
> > Richard



[web2py] Re: xml view of dict() with attributes

2011-10-26 Thread villas
@Kmax,  nice solution!


[web2py] Re: Domain Masking and Internet Explorer

2011-10-26 Thread horridohobbyist
Okay, I've made it easier to investigate. I've obtained a free domain
name with domain masking...

stressrelief.co.nr points to http://67.213.70.251/welcome/default/index

The first URL prevents login. The second URL does not. It's the
standard web2py Welcome app -- login is "richardeng2...@hotmail.com",
password "Ranger".

web2py is installed on Ubuntu with the usual Apache configuration:


  WSGIDaemonProcess web2py user=www-data group=www-data
  WSGIProcessGroup web2py
  WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py

  
AllowOverride None
Order Allow,Deny
Deny from all

  Allow from all

  

  AliasMatch ^/([^/]+)/static/(.*) \
   /home/www-data/web2py/applications/$1/static/$2
  
Options -Indexes
Order Allow,Deny
Allow from all
  

  
  Deny from all
  

  
  Deny from all
  

  CustomLog /var/log/apache2/access.log common
  ErrorLog /var/log/apache2/error.log


Richard

On Oct 26, 3:06 pm, horridohobbyist  wrote:
> I've discovered an issue, but I'm not sure if it is specific to
> web2py. It might be...
>
> I used domain forwarding with masking on stressrelief.drsommers.com to
> point tohttp://goodsexnetwork.com/stressrelief.  On Internet
> Explorer, this hinders the login function -- when you enter username/
> password, the browser simply throws you back to the login page (with
> no error message).
>
> I've gone back to domain forwarding without masking, and now it works
> fine.
>
> If you want to investigate, you should use domain forwarding with
> masking on the welcome app.
>
> Note that this issue is IE-specific. I've had no problem with Firefox,
> Chrome, Safari, or Opera.
>
> Richard


[web2py] Re: SQLFORM.grid collection of posts

2011-10-26 Thread Anthony
Nice. Thanks.

[web2py] Re: list of usernames

2011-10-26 Thread Anthony
That's what I was thinking. list: type fields are good if you just need to 
store a list of things associated with a given record and retrieve the list 
when the record is retrieved, but they aren't necessarily easy or efficient 
for querying the data (depending on the application). If you really want to 
stick with the list: fields, I suppose you could do a select to get the 
Julia records, and then use some Python code to further filter the records 
based on status. You might also be able to create either a computed or 
virtual field that concatenates name and status into a new list, and query 
that. Depending on how many records you're dealing with, though, it might 
be more efficient to go with a more normalized data structure.

Anthony

On Wednesday, October 26, 2011 5:38:41 PM UTC-4, Archibald Linx wrote:
>
> Dear Anthony, 
>
> I have asked the question on Stackoverflow and it seems it is a bad 
> database structure ;) Sorry. 
>
> See : http://stackoverflow.com/questions/7908024/sql-query-list-fields 
>
> I will put the status information somewhere else. Maybe in a separate 
> database. I don't know yet. 
>
> Thanks for the help you gave me, 
> Archibald 
>
>
> On 26 oct, 20:35, Archibald Linx  wrote: 
> > Thank you Anthony. 
> > 
> > I don't know about the raw SQL query. I will ask on Stackoverflow and 
> > post the link here. 
> > 
> > Best, 
> > Archibald 
> > 
> > On 26 oct, 19:07, Anthony  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > On Wednesday, October 26, 2011 12:21:33 PM UTC-4, Archibald Linx 
> wrote: 
> > 
> > > > Thank you Anthony ! 
> > 
> > > > Is the length "len" always defined in Python ? 
> > 
> > > No, I think the len() function will fail if you pass None to it, so if 
> you 
> > > were using request.vars, you'd want something like: 
> > 
> > > default=len(request.vars.to) if request.vars.to is not None else 
> [whatever 
> > > you want the default to be otherwise] 
> > 
> > > > I couldn't find much tools in the documentation to query lists of 
> > > > references apart from the "contains" operator. 
> > 
> > > > For example, let's have the following "message" table : 
> > > > id / to  / status 
> > > > 1  / steve,jimmy / 0,2 
> > > > 2  / john,julia  / 1,2 
> > > > 3  / julia,peggy / 0,1 
> > 
> > > > I want to get the rows where "Julia" is in "to" and where her status 
> > > > is "0" (in this particular case, that is row n°3). 
> > > > With the "contains" operator I only know how to get the rows where 
> > > > "Julia" is in "to" (that is row n°2 and n°3). 
> > 
> > > > Should I write raw SQL ? 
> > 
> > > How would you write it in raw SQL?



Re: [web2py] Room and Resource Reservation

2011-10-26 Thread Ismael Serratos
Looking for the same...

2011/10/6 António Ramos 

> Hello, i´d like to suggest this app
>
> Room and Resource(auto, projector etc) Reservation with a nice callendar
> like fullcalendar.
>
> IT think it would be very usefull for an intranet use
>
> Does anyone have something like this in web2py?
>


[web2py] SQLFORM.grid ondelete possible bug

2011-10-26 Thread Bob St John
using 1.99.2

in gluon.sqlhtml.SQLFORM.grid:

line 1489: return ondelete(table,request.args[-2],ret)

I think it should be: return ondelete(table,request.args[-1],ret)

As it is now, ondelete gets (table, table, ret), whereas I believe it
should get (table, record_id, ret) to work properly...

I like this grid method!


[web2py] SQLFORM.grid collection of posts

2011-10-26 Thread Cliff
You can find a digest of posts about SQLFORM.grid here:

https://docs.google.com/document/d/1p-OXDn75Nt2qmXQ0lvjqr4tYIf2PTIQx6hPegT1AV1Q/edit

I know it is not complete, but it may help you get started.

Also there is some good information in the source file: gluon/
sqlhtml,  Just looking at the signature of the grid function is very
instructive.

If you find something I've missed, just let me know.

Cliff Kachinske


[web2py] Re: list of usernames

2011-10-26 Thread Archibald Linx
Dear Anthony,

I have asked the question on Stackoverflow and it seems it is a bad
database structure ;) Sorry.

See : http://stackoverflow.com/questions/7908024/sql-query-list-fields

I will put the status information somewhere else. Maybe in a separate
database. I don't know yet.

Thanks for the help you gave me,
Archibald


On 26 oct, 20:35, Archibald Linx  wrote:
> Thank you Anthony.
>
> I don't know about the raw SQL query. I will ask on Stackoverflow and
> post the link here.
>
> Best,
> Archibald
>
> On 26 oct, 19:07, Anthony  wrote:
>
>
>
>
>
>
>
> > On Wednesday, October 26, 2011 12:21:33 PM UTC-4, Archibald Linx wrote:
>
> > > Thank you Anthony !
>
> > > Is the length "len" always defined in Python ?
>
> > No, I think the len() function will fail if you pass None to it, so if you
> > were using request.vars, you'd want something like:
>
> > default=len(request.vars.to) if request.vars.to is not None else [whatever
> > you want the default to be otherwise]
>
> > > I couldn't find much tools in the documentation to query lists of
> > > references apart from the "contains" operator.
>
> > > For example, let's have the following "message" table :
> > > id / to          / status
> > > 1  / steve,jimmy / 0,2
> > > 2  / john,julia  / 1,2
> > > 3  / julia,peggy / 0,1
>
> > > I want to get the rows where "Julia" is in "to" and where her status
> > > is "0" (in this particular case, that is row n°3).
> > > With the "contains" operator I only know how to get the rows where
> > > "Julia" is in "to" (that is row n°2 and n°3).
>
> > > Should I write raw SQL ?
>
> > How would you write it in raw SQL?


[web2py] Re: Web2py won't connect to MSSQL

2011-10-26 Thread Omi Chiba
CJM,

Can I ask how you set the driver manually ?
I want to try on my machine too.

On Oct 26, 8:18 am, CJM  wrote:
> Thank you Massimo!
>
> The driver did return None and setting the driver manually did the
> trick.
>
> Is this an issue with web2py or did I somehow setup my machine
> incorrectly?
>
> On Oct 25, 6:15 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > try:
>
> > from gluon.dal import MSSQLAdapter
> > print MSSQLAdapter.driver
>
> > My guess isthat it is failing to import pyodbc from dal.py somehow and
> > the driver should should be set to
>
> >    driver = globals().get('pyodbc',None)
>
> > is set to None instead.
>
> > On Oct 25, 10:20 am, CJM  wrote:
>
> > > I'm unable to get web2py to connect to mssql.
>
> > > (Failure to connect, tried 5 times:
> > > 'NoneType' object has no attribute 'connect')
>
> > > My connection string is: db = DAL('mssql://
> > > testUser:password1@localhost/testDB')
>
> > > Environment
> > >   Windows Server 2008 R2, 64-bit operating system
> > >   SQL Server 2008 R2, local.
> > >   Web2py: source code install version 1.99.2 (2011-09-26 06:55:33)
> > > stable.
> > >   pyodbc
> > >   Python 2.7.2
>
> > > I've tested that I can connect using the pyodbc. The following code
> > > works:
>
> > > import pyodbc
> > > cnxn = pyodbc.connect('DRIVER={SQL
> > > Server};SERVER=localhost;DATABASE=testDB;UID=testUser;PWD=password1')
> > > cursor = cnxn.cursor()
> > > cursor.execute("select * from tbUsers")
> > > rows = cursor.fetchall()
> > > for row in rows:
> > >   print row
>
> > > Thanks for your time.
>
> > > Corey.


Re: [web2py] Re: sqlform.grid

2011-10-26 Thread Bruno Rocha
Nice, I see your page. http://ukjazz.net/store/albums

PowerGrid would be a good alternative when you get more records, this is
JSON based and allow Jquery Templates (
http://labs.blouweb.com/PowerGrid/default/withimages)

Is your website already in web2py.com/poweredby ?


[web2py] Re: Ajax sample function does not work on Update form

2011-10-26 Thread Anthony

>
> onkeyup="ajax('/palitan/default/my_function', ['lastname'], 
> 'target');" 
>

Also, note that it is recommended that you create all URLs with the URL 
function:

onkeyup="ajax('{{=URL("default", "my_function")}}', ['lastname'], 
'target');" 


[web2py] Re: sqlform.grid

2011-10-26 Thread peter
Thanks Bruno.

Adding in the css for grid actually spoilt things. I have managed to
get a good looking grid for CDs with graphics using smartform.grid,
but the base.css messes this up. See ukjazz.net/albums for a demo.
This is a slightly confusing table as the column headings our out of
place, however I need them there for sorting. I tried solidtable and
this did not help. I think what I have got is probably as good as I am
going to be able to use whilst still having the other benefits of
using a table. By using the css for the paginator I sorted out the
page number along the bottom.

Peter





On Oct 25, 9:53 pm, Bruno Rocha  wrote:
> The grid css is in base.css, but if you do not want to mess your own css,
> open the file and copy only the grid part. it is commented.
>
>
>
> On Tue, Oct 25, 2011 at 6:46 PM, peter  wrote:
> > I am using and enjoying sqlform.grid. I have the latest version of
> > web2py, however, I think that the css files within my application have
> > become out of date.
>
> > If I have ten pages, then the page numbers appear vertically rather
> > than horizontally at the bottom of the table.
>
> > What css files do I need to copy into my application to keep the css
> > up to date for the grid?
>
> > Thanks
> > Peter- Hide quoted text -
>
> - Show quoted text -


[web2py] web2py.app.booking.w2p??? Booking system??

2011-10-26 Thread Ismael Serratos
Hi! Everybody!! I've been looking for a good booking system example, I
found the web2py.app.booking.w2p  app, but the link is not working.
How could I get it?? Is there any good example??

Thank you




[web2py] Re: Ajax sample function does not work on Update form

2011-10-26 Thread Franklin Freitas
I solved the issue:

if I enter the function on the 'onkeyup' event on the input text like
this:

onkeyup="ajax('my_function', ['argument'], 'target');"

I get the error

But if I used the full path ('/application_name/default/function') it
works fine:


onkeyup="ajax('/palitan/default/my_function', ['lastname'],
'target');"


Thanks for your help, this got me for a few days





On Oct 20, 4:25 pm, Anthony  wrote:
> Can you show some code?
>
>
>
>
>
>
>
> On Thursday, October 20, 2011 3:21:12 PM UTC-4, Franklin Freitas wrote:
>
> > I am using a form very similar to the Ajax sample on chapter 3 to
> > search for customers and once you see the results, you click on the
> > record you want so customer id and name are added to the form fields
> > on my main processing form. This works fine on my "add new" records
> > form.
>
> > I have another page to "update records", similar to the "add new
> > records" page. On this form the Ajax doesn't work, when I call the
> > Ajax function I get in the target div the content of the index page.
> > After trying to see why it would only work in one page and the add and
> > update records pages are similar I found the reason. On the update
> > page there is an id on the url (to be read using request.args(0)) this
> > causes the error, for some reason when there is an argument in that
> > position the Ajax get confused and doesn't return the right results.
>
> > I tried adding a "/21" at the end of my "add new" page url and the
> > Ajax also fails, this confirms that this is the cause of the error. I
> > guess somehow the Ajax gets confused with this
>
> > Has anyone else experience this error ?
>
> > Thanks for your help


[web2py] Domain Masking and Internet Explorer

2011-10-26 Thread horridohobbyist
I've discovered an issue, but I'm not sure if it is specific to
web2py. It might be...

I used domain forwarding with masking on stressrelief.drsommers.com to
point to http://goodsexnetwork.com/stressrelief.  On Internet
Explorer, this hinders the login function -- when you enter username/
password, the browser simply throws you back to the login page (with
no error message).

I've gone back to domain forwarding without masking, and now it works
fine.

If you want to investigate, you should use domain forwarding with
masking on the welcome app.

Note that this issue is IE-specific. I've had no problem with Firefox,
Chrome, Safari, or Opera.

Richard


[web2py] Re: list of usernames

2011-10-26 Thread Archibald Linx
Thank you Anthony.

I don't know about the raw SQL query. I will ask on Stackoverflow and
post the link here.

Best,
Archibald

On 26 oct, 19:07, Anthony  wrote:
> On Wednesday, October 26, 2011 12:21:33 PM UTC-4, Archibald Linx wrote:
>
> > Thank you Anthony !
>
> > Is the length "len" always defined in Python ?
>
> No, I think the len() function will fail if you pass None to it, so if you
> were using request.vars, you'd want something like:
>
> default=len(request.vars.to) if request.vars.to is not None else [whatever
> you want the default to be otherwise]
>
>
>
>
>
>
>
>
>
>
>
> > I couldn't find much tools in the documentation to query lists of
> > references apart from the "contains" operator.
>
> > For example, let's have the following "message" table :
> > id / to          / status
> > 1  / steve,jimmy / 0,2
> > 2  / john,julia  / 1,2
> > 3  / julia,peggy / 0,1
>
> > I want to get the rows where "Julia" is in "to" and where her status
> > is "0" (in this particular case, that is row n°3).
> > With the "contains" operator I only know how to get the rows where
> > "Julia" is in "to" (that is row n°2 and n°3).
>
> > Should I write raw SQL ?
>
> How would you write it in raw SQL?


Re: [web2py] Re: Contribution

2011-10-26 Thread Richard Vézina
I just read the doc... Not sure what I suggest is possible... According to
the doc it would need something like this to work:

auth.has_permission(group_id, 'read', 'table123', field123 == 'something')

This would lead to check if a user as the permission read on table123 when
field123 has the value something...

It would be great if it is possible...

Richard

On Wed, Oct 26, 2011 at 2:03 PM, Richard Vézina  wrote:

> And why the object could not be a query that can return a list of records
> having the state you are looking for??
>
> Richard
>
>
> On Mon, Oct 24, 2011 at 8:25 PM, Triquetra <
> trique...@triquetradevelopment.com> wrote:
>
>> No, I don't think this helps, unless I'm misunderstanding something
>> (which is possible).
>>
>> When using "auth.add_permission(group_id, 'name', 'object',
>> record_id)" the CRUD permissions are only enforced if the object is a
>> table (according to the book).  So, even assuming one could pass a
>> column as the object (to enable field based access control), the
>> web2py access system will not automatically enforce CRUD permissions
>> on this object (like it would with tables or records).  This level of
>> access control would require additional manual enforcement in the
>> controllers.
>>
>> This doesn't help with state based permissions either.  The issue here
>> is that permissions may change depending upon the state of the
>> object.  Workflows are a good example.  If A is in group author and E
>> is in group editor, a workflow may demand that A has full CRUD rights
>> until the article is submitted for editing, then A only has read
>> rights over the SAME record and editor group gets read and update
>> rights only after submission of the article for editing.  Same record,
>> same groups, same users -- different permissions based on the state of
>> the record (which could be indicated by the content of a field).
>>
>> > On Friday, October 21, 2011 3:54:26 PM UTC-4, Triquetra wrote:
>> >
>> > > I'd like to see
>> > > web2py's access control beefed up (thus permitting easy development of
>> > > workflows, among other things).  Specifically, the current web2py RBAC
>> > > has two levels of granularity: table and record (row). This should be
>> >
>> > extended to include field(column), type(controller), and
>> >
>> > > context(state).
>> >
>> > auth.add_permission(group_id, 'name', 'object', record_id)
>> >
>> > In the above, 'object' can be any user-defined object, not just a DB
>> table
>> > (record_id is only relevant if the object is a table). Does that help?
>> >
>> > > Although the type(controller) access control is currently implemented
>> > > via decorators in web2py, this is restricted to coders.
>> >
>> > You don't have to use decorators. You can directly check for permissions
>> via
>> > auth.has_membership() and auth.has_permission().
>>
>
>


[web2py] Re: book 3.2ed

2011-10-26 Thread Archibald Linx
Great :)

Archibald

On 26 oct, 19:02, Anthony  wrote:
> > In this post :
>
> >https://groups.google.com/group/web2py/browse_thread/thread/b81158ca4...
> > it was noted that the possibility of the option "multiple=(0,9)" for
> > the IS_IN_DB validator of "list:reference tag" was undocumented.
>
> I've been compiling a list of undocumented/underdocumented stuff (the item
> above is on it), and Massimo is working through the list for the 4th
> edition of the book.
>
> Anthony


Re: [web2py] Re: Contribution

2011-10-26 Thread Richard Vézina
And why the object could not be a query that can return a list of records
having the state you are looking for??

Richard

On Mon, Oct 24, 2011 at 8:25 PM, Triquetra <
trique...@triquetradevelopment.com> wrote:

> No, I don't think this helps, unless I'm misunderstanding something
> (which is possible).
>
> When using "auth.add_permission(group_id, 'name', 'object',
> record_id)" the CRUD permissions are only enforced if the object is a
> table (according to the book).  So, even assuming one could pass a
> column as the object (to enable field based access control), the
> web2py access system will not automatically enforce CRUD permissions
> on this object (like it would with tables or records).  This level of
> access control would require additional manual enforcement in the
> controllers.
>
> This doesn't help with state based permissions either.  The issue here
> is that permissions may change depending upon the state of the
> object.  Workflows are a good example.  If A is in group author and E
> is in group editor, a workflow may demand that A has full CRUD rights
> until the article is submitted for editing, then A only has read
> rights over the SAME record and editor group gets read and update
> rights only after submission of the article for editing.  Same record,
> same groups, same users -- different permissions based on the state of
> the record (which could be indicated by the content of a field).
>
> > On Friday, October 21, 2011 3:54:26 PM UTC-4, Triquetra wrote:
> >
> > > I'd like to see
> > > web2py's access control beefed up (thus permitting easy development of
> > > workflows, among other things).  Specifically, the current web2py RBAC
> > > has two levels of granularity: table and record (row). This should be
> >
> > extended to include field(column), type(controller), and
> >
> > > context(state).
> >
> > auth.add_permission(group_id, 'name', 'object', record_id)
> >
> > In the above, 'object' can be any user-defined object, not just a DB
> table
> > (record_id is only relevant if the object is a table). Does that help?
> >
> > > Although the type(controller) access control is currently implemented
> > > via decorators in web2py, this is restricted to coders.
> >
> > You don't have to use decorators. You can directly check for permissions
> via
> > auth.has_membership() and auth.has_permission().
>


[web2py] using lambda for represent a field - what I misunderstood?

2011-10-26 Thread Lazarof
## The code ...
from gluon.contrib.populate import populate

db.define_table('product',
Field('field_n1'),
Field('field_n2'))

if db(db.product).isempty():
populate(db.product, 17)

some_function = 'function_n1'
some_action = 'action_n1'
some_table = 'table_n1'
back_to = 'back_to_pt01'
db.product.id.represent = lambda value,row: A('Ed',
_href=URL(f=some_function, args=(some_action, some_table, back_to,
value)))

## (1)
## when id=1 as a result I expect a link named Ed with href = '../app/
default/function_n1/action_n1/table_n1/back_to_pt01/1'

some_function = 'function_n2'
some_action = 'action_n2'
some_table = 'table_n2'
back_to = 'back_to_pt02'
db.product.field_n1.represent = lambda value,row: A(value,
_href=URL(f=some_function, args=(some_action, some_table, back_to,
row.id)))

## (2)
## when id=1 as a result I expect the content of field_n1 with href =
'../app/default/function_n2/action_n2/table_n2/back_to_pt02/1'

## (3) and here is the question ...
## for both (1) and (2)
## I am geting href = '../app/default/function_n2/action_n2/table_n2/
back_to_pt02/1'
## Is that correct?


## with this code I get what I am expecting
##xsome_function = 'function_n2'
##xsome_action = 'action_n2'
##xsome_table = 'table_n2'
##xback_to = 'back_to_pt02'
##db.product.field_n1.represent = lambda value,row: A(value,
_href=URL(f=xsome_function, args=(xsome_action, xsome_table, xback_to,
row.id)))


Can someone switch on the light, please.
Lazaro


[web2py] Re: SQLFORM.grid awesomeness and some questions

2011-10-26 Thread Cliff
So you need a column on the right for an "Add to Cart" button.

Sorry, don't know that one.  Maybe somebody who knows more about grid
can chime in.

On Oct 26, 12:14 pm, horridohobbyist 
wrote:
> I was thinking of extending SQLFORM.grid into a shopping cart
> application. The view form should be able to add an item to the cart.
> The grid should display an indicator that the item is in the cart.
>
> Richard
>
> On Oct 26, 11:50 am, Cliff  wrote:
>
>
>
>
>
>
>
> > Don't know about adding extra columns.  What kind of columns do you
> > mean?
>
> > As far as extending views, you can use any view you want to.
> > Somewhere in this group is a post about changing the target on the
> > 'view' and 'edit' buttons.
>
> > You can also do something like this:
>
> > def index():
>
> >     if request.args(0) == 'edit':
> >        # redefine field visibility in case there are some
> >        # you don't want users to see or edit
> >        # redefine db.mytable.myfield.represent
> >        response.view = 'another_view.html'
>
> >     form=SQLFORM.grid
> >     return form
>
> > On Oct 26, 11:29 am, horridohobbyist 
> > wrote:
>
> > > Can SQLFORM.grid be customized/extended to add extra columns, and can
> > > the view form be extended to add additional logic? I guess what I'm
> > > asking is, can SQLFORM.grid be extended into a mini-app?
>
> > > Richard
>
> > > On Oct 26, 10:32 am, Cliff  wrote:
>
> > > > SQLFORM.grid is amazing.  Many thanks Massimo, Bruno, Martin and
> > > > everyone involved.
>
> > > > Is there a way to replace the contents of the  tag at the top of
> > > > the view?  All the pages show "Index."  This is okay for the index
> > > > view, but I would like to change it to "Edit", "View" and so on.
>
> > > > Do the "design", "request" and other buttons at the bottom of the form
> > > > go away when not on localhost?  Or do I have to do something to
> > > > suppress them?
>
> > > > Thanks,
> > > > Cliff Kachinske


[web2py] Re: list of usernames

2011-10-26 Thread Anthony
On Wednesday, October 26, 2011 12:21:33 PM UTC-4, Archibald Linx wrote:
>
> Thank you Anthony ! 
>
> Is the length "len" always defined in Python ? 
>

No, I think the len() function will fail if you pass None to it, so if you 
were using request.vars, you'd want something like:

default=len(request.vars.to) if request.vars.to is not None else [whatever 
you want the default to be otherwise]
 

>
> I couldn't find much tools in the documentation to query lists of 
> references apart from the "contains" operator. 
>
> For example, let's have the following "message" table : 
> id / to  / status 
> 1  / steve,jimmy / 0,2 
> 2  / john,julia  / 1,2 
> 3  / julia,peggy / 0,1 
>
> I want to get the rows where "Julia" is in "to" and where her status 
> is "0" (in this particular case, that is row n°3). 
> With the "contains" operator I only know how to get the rows where 
> "Julia" is in "to" (that is row n°2 and n°3). 
>
> Should I write raw SQL ? 
>

How would you write it in raw SQL?



[web2py] Re: Nested functions problem?

2011-10-26 Thread annet

> If you're still having trouble, I suggest you post a minimal application
> that reproduces your problem.

I will, thanks.


Kind regards,

Annet.


[web2py] Re: book 3.2ed

2011-10-26 Thread Anthony

>
> In this post : 
>
> https://groups.google.com/group/web2py/browse_thread/thread/b81158ca46496caa/e7da3bbaefa03c90?hl=fr&lnk=gst&q=list+of+usernames#e7da3bbaefa03c90
>  
> it was noted that the possibility of the option "multiple=(0,9)" for 
> the IS_IN_DB validator of "list:reference tag" was undocumented.
>

I've been compiling a list of undocumented/underdocumented stuff (the item 
above is on it), and Massimo is working through the list for the 4th 
edition of the book.

Anthony 


[web2py] Re: Form question from a noob

2011-10-26 Thread Anthony
On Wednesday, October 26, 2011 12:36:53 PM UTC-4, David wrote:
>
> Hello, 
>
> I have been reading through the documentation but I must be missing 
> something. I am trying to figure out how to adjust form element 
> styling. Is there a way to do this inside of the view or do I need to 
> do this through css?


It depends what you want to do. Changing the CSS might be easiest (see 
http://martin.tecnodoc.com.ar/default/post/2011/09/12/3_hacking-web2py-sqlform-part-1).
 
You can also customize the way the fields are laid out -- see 
http://web2py.com/book/default/chapter/07#Custom-forms, 
http://www.web2pyslices.com/slices/take_slice/43.

Anthony


[web2py] Form question from a noob

2011-10-26 Thread David
Hello,

I have been reading through the documentation but I must be missing
something. I am trying to figure out how to adjust form element
styling. Is there a way to do this inside of the view or do I need to
do this through css?

Thanks for the help. I am loving web2py so far.

David


[web2py] Re: book 3.2ed

2011-10-26 Thread Archibald Linx
Great work !

In this post :
https://groups.google.com/group/web2py/browse_thread/thread/b81158ca46496caa/e7da3bbaefa03c90?hl=fr&lnk=gst&q=list+of+usernames#e7da3bbaefa03c90
it was noted that the possibility of the option "multiple=(0,9)" for
the IS_IN_DB validator of "list:reference tag" was undocumented.

Archibald

On 26 oct, 11:24, Johann Spies  wrote:
> Thanks!
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)


[web2py] Re: Nested functions problem?

2011-10-26 Thread Anthony
On Wednesday, October 26, 2011 11:58:38 AM UTC-4, annet wrote:
>
> This: 
>
> > {{=LOAD('locator','imagetext.load',args=company.id,ajax=True,target='component')}}
> >  
>
>
> so, without the , results in weird 
> behaviour. When I first visit the page, the div just displays 
> Loading...,


It sounds like the ajax call isn't working -- maybe use the browser 
developer tools to check the ajax request.
 

> when I click the lesrooster link, the image link and the 
> text display as is: 
>
> image:link: imagename.png 
> text:text: Texttextext ... 
>

Are you talking about the timetable link? How is that returning the 
imagetext results?

Also, below you noted that visiting the imagetext.load URL directly yields 
that same content, so it looks like the problem is the imagetext.load view 
isn't returning what you want, so you'll have to debug that function and 
view.
 

> I am stuck getting the image and text bit to work. 
>
> When I put a imagetext link on the page: 
>
> {{=A('Imagetext',callback=URL('imagetext',args=[company.id]),target='component')}}
>  
>
>
> ... and put these back in the view:  
> The business card is being displayed correctly. But I cannot have 
> visitors click a link to display the image and text. 
>

If you're using components, rather than using the callback/target arguments 
to A(), use the regular _href argument and the cid argument -- that will 
load the _href as a component into the div identified by cid (make sure the 
URL uses the .load extension if you've got a .load view for timetable). 
See 
https://docs.google.com/spreadsheet/ccc?key=0Ajy6-Ewiiuo6dGlqckdOUnB5Yl9OSmd0bV9fN0lvSlE.

The initial LOAD should automatically load the imagetext, and clicking the 
link should replace that with the timetable component.

If you're still having trouble, I suggest you post a minimal application 
that reproduces your problem.

Anthony



[web2py] Re: SQLTABLE param headers=None bug - Web2py 1.99.2 (2011-09-26 06:55:33) stable

2011-10-26 Thread tg
At least for me to following is faster when reading...

-if not headers is None:
+if headers is None:
+  headers={}
+else:
for c in columns:#new implement dict


regards

thomas


> I think I found a bug with the headers with the above version, which
> when headers=None generates a unsubscriptable error at line 2061:
>
> if isinstance(headers[colname],dict):
>
> This error can be fixed by the following changes added to line 1966 of
> sqlhtml.py:
>
>         if not headers is None:
>             for c in columns:#new implement dict
>                 if isinstance(headers.get(c, c), dict):
>                     coldict = headers.get(c, c)
>                     attrcol = dict()
>                     if coldict['width']!="":
>                         attrcol.update(_width=coldict['width'])
>                     if coldict['class']!="":
>                         attrcol.update(_class=coldict['class'])
>                     row.append(TH(coldict['label'],**attrcol))
>                 elif orderby:
>                     row.append(TH(A(headers.get(c, c),
>                                     _href=th_link+'?orderby=' + c)))
>                 else:
>                     row.append(TH(headers.get(c, c)))
>
>             if extracolumns:#new implement dict
>                 for c in extracolumns:
>                     attrcol = dict()
>                     if c['width']!="":
>                         attrcol.update(_width=c['width'])
>                     if c['class']!="":
>                         attrcol.update(_class=c['class'])
>                     row.append(TH(c['label'],**attrcol))
>
>             components.append(THEAD(TR(*row)))
> +        else:
> +          headers={}
>
> Cheers
> Calvin


[web2py] curious DAL timeout issue

2011-10-26 Thread Richard Bruskiewich
I'm a recent fan of web2py, having adopted it for some major
institutional projects in global agriculture. So far, so good - very
happy - but I have a recurring curious low level database error which
I'm not sure how to fix.

I've already tried trapping my web2py data model in a try... except
block, inside a loop to retry the database connection (about 20 times,
or so I think), but this doesn't seem to help.  The database
connection often works... it is just that when the MySQL connection is
idle for too long, or when a fresh connection is requested for a new
user session, something fails... DAL doesn't handle it.

Here's the background: I'm running web2py in an NGINX server via uwsgi
(which generally works fine - configured based on good advice online).
However, this server runs within an Amazon Web Services (AWS) EC2
server and accesses a MySQL instance running non-locally as a AWS
Relational Database (RDB) server.

I'm using a DAL pool_size of 10.

Here's the error message:

Operational Error: (2013, 'Lost connection to MySQL server during
query')

Traceback (most recent call last):
  File "/opt/web2py/gluon/main.py", line 506, in wsgibase
BaseAdapter.close_all_instances('commit')
  File "/opt/web2py/gluon/dal.py", line 373, in close_all_instances
getattr(instance,action)()
  File "/opt/web2py/gluon/dal.py", line 1225, in commit
return self.connection.commit()
  File "/opt/web2py/gluon/contrib/pymysql/connections.py", line 562,
in commit
self.errorhandler(None, exc, value)
  File "/opt/web2py/gluon/contrib/pymysql/connections.py", line 184,
in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (2013, 'Lost connection to MySQL server during
query')

I hope someone can suggest something here. Do I need to tweak some
MySQL client parameter, or does someone have some advice about Amazon
RDB usage practicalities in such a situation?

Cheers
Richard Bruskiewich
Scientific Consultant,
International Rice Research Institute (IRRI)


[web2py] Re: list of usernames

2011-10-26 Thread Archibald Linx
Thank you Anthony !

Is the length "len" always defined in Python ?

I couldn't find much tools in the documentation to query lists of
references apart from the "contains" operator.

For example, let's have the following "message" table :
id / to  / status
1  / steve,jimmy / 0,2
2  / john,julia  / 1,2
3  / julia,peggy / 0,1

I want to get the rows where "Julia" is in "to" and where her status
is "0" (in this particular case, that is row n°3).
With the "contains" operator I only know how to get the rows where
"Julia" is in "to" (that is row n°2 and n°3).

Should I write raw SQL ?

Thanks,
Archibald


On 26 oct, 15:03, Anthony  wrote:
> This is probably the easiest way to go. You could use a computed field, but
> then if you want the computed field to appear in an update form, you have
> to explicitly list it (along with all fields you want to appear). Note, if
> you instead used request.vars.to to set the field default, that wouldn't
> present any danger in terms of the contents of request.vars.to not being
> validated, because you're only using the length of request.vars.to. It
> would only be an issue if the validation of request.vars.to could result in
> it passing validation but its length changing as a result of that.
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, October 26, 2011 6:39:29 AM UTC-4, Archibald Linx wrote:
>
> > Thank you Anthony.
>
> > I will need to exclusively modify the variable "status" on other
> > occasions. So I am not sure I really want "computed fields". Is that
> > true ?
>
> > So I decided to try an onvalidation function and I ended up with :
>
> > def status(form):
> >     form.vars.status = [0]*len(form.vars.to)
>
> > def write():
> >     form = SQLFORM(db.message)
> >         if form.accepts(request.vars, session, onvalidation=status):
> >             response.flash = 'Got it'
>
> > It seems to work.
>
> > Is it ok ? If I have understood correctly, onvalidation is called
> > after validation and before insert. Like this I am sure
> > "forms.vars.to" does not contain anything fishy or dangerous.
>
> > Thanks,
> > Archibald
>
> > On 25 oct, 18:30, Anthony  wrote:
> > > On Tuesday, October 25, 2011 11:45:41 AM UTC-4, Archibald Linx wrote:
>
> > > > Thank you Anthony.
>
> > > > All this works very nicely.
> > > > Maybe the default format for auth_user should also be documented.
>
> > > > Let's say I have the following table :
> > > > db.define_table('message',
> > > >     Field('to', 'list:reference auth_user'),
> > > >     Field('status', 'list:integer'))
>
> > > > I want "status" to be a list of 0 as long as "to", but
> > > > "db.message.status.default = [0]*len(db.message.to.default)" does not
> > > > work.
>
> > > db.message.to.default represents the default value for the 'to' field
> > (which
> > > you have not set), not the actually values being inserted. Anyway, I
> > don't
> > > think the default for one field can reference the values of another.
>
> > > There are a few other options. You could use a computed field (though by
> > > default that won't display in a form, if you need that). If
> > inserts/updates
> > > will always be handled via form submissions, you could us a form
> > > onvalidation function or a custom validator. You could also just do
> > > default=[0]*len(request.vars.to), since upon form submission, the
> > values
> > > submitted to the 'to' field will be stored in request.vars.to (note,
> > the
> > > values stored in request.vars will be the unvalidated values). See here
> > for
> > > more
> > > details:
> >http://stackoverflow.com/questions/7325776/using-a-lambda-for-a-model...
>
> > > Anthony


[web2py] Re: SQLFORM.grid awesomeness and some questions

2011-10-26 Thread horridohobbyist
I was thinking of extending SQLFORM.grid into a shopping cart
application. The view form should be able to add an item to the cart.
The grid should display an indicator that the item is in the cart.

Richard

On Oct 26, 11:50 am, Cliff  wrote:
> Don't know about adding extra columns.  What kind of columns do you
> mean?
>
> As far as extending views, you can use any view you want to.
> Somewhere in this group is a post about changing the target on the
> 'view' and 'edit' buttons.
>
> You can also do something like this:
>
> def index():
>
>     if request.args(0) == 'edit':
>        # redefine field visibility in case there are some
>        # you don't want users to see or edit
>        # redefine db.mytable.myfield.represent
>        response.view = 'another_view.html'
>
>     form=SQLFORM.grid
>     return form
>
> On Oct 26, 11:29 am, horridohobbyist 
> wrote:
>
>
>
>
>
>
>
> > Can SQLFORM.grid be customized/extended to add extra columns, and can
> > the view form be extended to add additional logic? I guess what I'm
> > asking is, can SQLFORM.grid be extended into a mini-app?
>
> > Richard
>
> > On Oct 26, 10:32 am, Cliff  wrote:
>
> > > SQLFORM.grid is amazing.  Many thanks Massimo, Bruno, Martin and
> > > everyone involved.
>
> > > Is there a way to replace the contents of the  tag at the top of
> > > the view?  All the pages show "Index."  This is okay for the index
> > > view, but I would like to change it to "Edit", "View" and so on.
>
> > > Do the "design", "request" and other buttons at the bottom of the form
> > > go away when not on localhost?  Or do I have to do something to
> > > suppress them?
>
> > > Thanks,
> > > Cliff Kachinske


[web2py] Re: Nested functions problem?

2011-10-26 Thread annet
Hi Anthony,

> Maybe these are just typos, but looks like you've got an extra ( at the
> beginning, and your select is coming from a different table than the query.

My bad, I stripped the query because it's much longer, and the entire
query isn't needed to get the picture.

This:

> {{=LOAD('locator','imagetext.load',args=company.id,ajax=True,target='component')}}

so, without the , results in weird
behaviour. When I first visit the page, the div just displays
Loading..., when I click the lesrooster link, the image link and the
text display as is:

image:link: imagename.png
text:text: Texttextext ...

.. and when I click the lesrooster link again, the timetable displays.


> Also, whenever a component fails to load properly, always check to make
> sure the action itself is returning something -- you can do that by going
> directly to the URL of the component: /yourapp/locator/imagetext.load


http://127.0.0.1:8000/init/locator/imagetext.load/283

displays:

image:link: imagename.png
text:text: Texttextext ...


http://127.0.0.1:8000/init/locator/imagetext/283

displays:

image:link: imagename.png
text:text: Texttextext ...

.. but in the generic view.


> > 
>
> > {{=A('Lesrooster',callback=URL('timetable','timetable',args=[company.id]),target='component')}}
>
> >  

This works alright now.

I am stuck getting the image and text bit to work.

When I put a imagetext link on the page:

{{=A('Imagetext',callback=URL('imagetext',args=[company.id]),target='component')}}

... and put these back in the view: 
The business card is being displayed correctly. But I cannot have
visitors click a link to display the image and text.

is there another way to fix this?


Kind regards,

Annet.


[web2py] Re: SQLFORM.grid awesomeness and some questions

2011-10-26 Thread Cliff
Don't know about adding extra columns.  What kind of columns do you
mean?

As far as extending views, you can use any view you want to.
Somewhere in this group is a post about changing the target on the
'view' and 'edit' buttons.

You can also do something like this:

def index():

if request.args(0) == 'edit':
   # redefine field visibility in case there are some
   # you don't want users to see or edit
   # redefine db.mytable.myfield.represent
   response.view = 'another_view.html'

form=SQLFORM.grid
return form

On Oct 26, 11:29 am, horridohobbyist 
wrote:
> Can SQLFORM.grid be customized/extended to add extra columns, and can
> the view form be extended to add additional logic? I guess what I'm
> asking is, can SQLFORM.grid be extended into a mini-app?
>
> Richard
>
> On Oct 26, 10:32 am, Cliff  wrote:
>
>
>
> > SQLFORM.grid is amazing.  Many thanks Massimo, Bruno, Martin and
> > everyone involved.
>
> > Is there a way to replace the contents of the  tag at the top of
> > the view?  All the pages show "Index."  This is okay for the index
> > view, but I would like to change it to "Edit", "View" and so on.
>
> > Do the "design", "request" and other buttons at the bottom of the form
> > go away when not on localhost?  Or do I have to do something to
> > suppress them?
>
> > Thanks,
> > Cliff Kachinske


[web2py] Re: SQLFORM.grid awesomeness and some questions

2011-10-26 Thread Cliff
Thanks, Anthony

I didn't realize it was using generic.html.  Simple fix, that.


On Oct 26, 11:17 am, Anthony  wrote:
> On Wednesday, October 26, 2011 10:32:35 AM UTC-4, Cliff wrote:
>
> > Do the "design", "request" and other buttons at the bottom of the form
> > go away when not on localhost?  Or do I have to do something to
> > suppress them?
>
> Are you using the generic.html view? If so, yes, those buttons will go away
> when not on localhost. However, for security reasons, it is recommended
> that you don't use generic views on production anyway (except in limited
> circumstances, when you are explicitly controlling which generic views are
> available).
>
> Anthony


[web2py] Re: SQLFORM.grid awesomeness and some questions

2011-10-26 Thread horridohobbyist
Can SQLFORM.grid be customized/extended to add extra columns, and can
the view form be extended to add additional logic? I guess what I'm
asking is, can SQLFORM.grid be extended into a mini-app?

Richard

On Oct 26, 10:32 am, Cliff  wrote:
> SQLFORM.grid is amazing.  Many thanks Massimo, Bruno, Martin and
> everyone involved.
>
> Is there a way to replace the contents of the  tag at the top of
> the view?  All the pages show "Index."  This is okay for the index
> view, but I would like to change it to "Edit", "View" and so on.
>
> Do the "design", "request" and other buttons at the bottom of the form
> go away when not on localhost?  Or do I have to do something to
> suppress them?
>
> Thanks,
> Cliff Kachinske


[web2py] Re: SQLFORM.grid awesomeness and some questions

2011-10-26 Thread Anthony
On Wednesday, October 26, 2011 10:32:35 AM UTC-4, Cliff wrote:
>
> Do the "design", "request" and other buttons at the bottom of the form 
> go away when not on localhost?  Or do I have to do something to 
> suppress them?
>

Are you using the generic.html view? If so, yes, those buttons will go away 
when not on localhost. However, for security reasons, it is recommended 
that you don't use generic views on production anyway (except in limited 
circumstances, when you are explicitly controlling which generic views are 
available).

Anthony


Re: [web2py] Re: Problem printing a web2py webpage

2011-10-26 Thread Anthony
Actually, looks like it's in the web2py base.css:

@media print {
* { background: transparent !important; color: #444 !important; 
text-shadow: none !important; }
a, a:visited { color: #444 !important; text-decoration: underline; }
a:after { content: " (" attr(href) ")"; }
abbr:after { content: " (" attr(title) ")"; }
.ir a:after { content: ""; }  /* Don't show links for images */
pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
thead { display: table-header-group; } /* 
css-discuss.incutio.com/wiki/Printing_Tables */
tr, img { page-break-inside: avoid; }
@page { margin: 0.5cm; }
p, h2, h3 { orphans: 3; widows: 3; }
h2, h3{ page-break-after: avoid; }
}



On Wednesday, October 26, 2011 10:39:51 AM UTC-4, Ramos wrote:
>
> No, its a simple web2py app
>
>
> please view my view :)
>
> Can you see the bug? 
>
> {{extend 'layout.html'}}
> 
> function timedRefresh(timeoutPeriod) {
> setTimeout("location.reload(true);",timeoutPeriod);
> }
> 
>
> 
> jQuery(document).ready(function(){timedRefresh(5) ;});
> 
>
>
> 
>  
>  {{for grade in grades:}}
> {{=grade}} 
> {{pass}} 
>   
>   {{for silo in range(0,19):}}
> 
> {{=silo+1}}
>{{for cols in range(0,8):}}
>   {{tableclass=''}}  
>{{if flags[silo]!='0'and Tabela[silo][cols][1]!='':}}
>{{tableclass='a1'}}
>{{else:}}
> {{if  Tabela[silo][cols][1]=='':}}
> {{tableclass='a2'}}
> {{else:}} 
>  {{tableclass='a0'}} 
> {{pass}}  
>{{pass}}   
> {{=Tabela[silo][cols][2]}} 
> 
>  class={{=tableclass}}>{{=A(Tabela[silo][cols][1],_href=URL(r=request,f='SiloDetalhe',args=silo+1))}}
>  
>  
>{{=Tabela[silo][cols][0]}}
>   {{pass}} 
> 
>   {{pass}}
>   
>  {{for grade in grades:}}
>  
> {{=Totais[grade] if 
> Totais.has_key(grade) else 0}} 
> {{pass}} 
>
>
> 
>
> .a1 {
> border:1px solid black;
>  background-color: #00ff00;
> }
> .a0 {
>
> background-color: cyan;
> border:1px solid black;
>
> }
> .a2 {
>
> background-color: white;
> border:1px solid black;
>
> }
> .header {
>  background-color: Yellow;
>  color: Black;
> border:1px solid black;
>  font-family: arial;
>  font-size:10;
>  text-align: center;
> }
> .bottom {
>  background-color: #9f9fff;
>  color: black;
> border:1px solid black;
>  font-family: arial;
>  font-size:10;
>  text-align: right;
> font-weight:bold;
>
> }
> .silos{
>  background-color: #ece9d8;
>  color: green;
> border:1px solid black;
>  font-family: arial;
>  font-size:10;
>  text-align: right;
>
> }
> 
>
>
>
>
>
>
>
> 2011/10/26 Anthony 
>
>> You probably have some CSS or Javascript somewhere that is telling the 
>> browser to display the URL for links in parentheses after the link text. 
>> Something like this: 
>> http://davidwalsh.name/optimize-your-links-for-print-using-css-show-url
>>
>>
>> On Wednesday, October 26, 2011 9:57:45 AM UTC-4, Ramos wrote:
>>
>>> this is what i have in the source
>>> >> href="/DO/Silos/SiloDetalhe/1
>>> "**>79.4  When printed in paper it shows the href after 
>>> the 79.4 value.
>>>
>>> Strange?!
>>>
>>>
>>>
>>> 011/10/26 Anthony 
>>>  
 Does the (/DO/Silos/SiloDetalhe/2) appear inside the TDs in the HTML 
 page source (not what the browser shows, the actual HTML source code), or 
 only in the printed output?


 On Wednesday, October 26, 2011 6:00:12 AM UTC-4, Ramos wrote:
>
> hello i have a problem
>
> please see image1.jpeg is what i see in the browser
>
> when i print it i get what you see in image2.pdf
>
> How is that possible?
>
> Thank you
>

>>>
>

[web2py] Re: Contribution

2011-10-26 Thread Hong-Khoan Quach
I want to thank you all for your suggestions so far and please
post further suggestions :).

Massimo, Anthony or other contributors/committers, do you
have anything on your TODO list ?

Regards

Hong-Khoan



Am 21.10.2011 12:52, schrieb Hong-Khoan Quach:
> Hi there.
> 
> We would like to contribute to web2py for a university open source
> practical course. Does anyone have an idea for an important/cool feature
> that we could propose to our supervisor?
> Furthermore, are there any low hanging fruits, we can start with?
> 
> Regards
> 
> Matteo and Hong-Khoan
> 



signature.asc
Description: OpenPGP digital signature


[web2py] Re: NInja IDE 2.0b and Plugin contest

2011-10-26 Thread Anthony
Looks interesting, but can't get anything but some default proportionally 
spaced font in the editor on Windows 7 (changing the font in the editor 
preferences has no effect).

On Wednesday, October 26, 2011 1:33:29 AM UTC-4, rochacbruno wrote:
>
> NInja IDE released 2.0b and it is awesome! (http://www.ninja-ide.org/)
>
> They are running a plugin contest http://www.ninja-ide.org/plugins/
>
> Any taker to create a web2py plugin?
>
> What features do people think a web2py plugin for Ninja-IDE should have? 
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>  

Re: [web2py] Re: Problem printing a web2py webpage

2011-10-26 Thread António Ramos
No, its a simple web2py app


please view my view :)

Can you see the bug?

{{extend 'layout.html'}}

function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}



jQuery(document).ready(function(){timedRefresh(5) ;});


   

 
 {{for grade in grades:}}
{{=grade}}
{{pass}}
 
  {{for silo in range(0,19):}}

{{=silo+1}}
   {{for cols in range(0,8):}}
  {{tableclass=''}}
   {{if flags[silo]!='0'and Tabela[silo][cols][1]!='':}}
   {{tableclass='a1'}}
   {{else:}}
{{if  Tabela[silo][cols][1]=='':}}
{{tableclass='a2'}}
{{else:}}
 {{tableclass='a0'}}
{{pass}}
   {{pass}}
{{=Tabela[silo][cols][2]}}

{{=A(Tabela[silo][cols][1],_href=URL(r=request,f='SiloDetalhe',args=silo+1))}}

   {{=Tabela[silo][cols][0]}}
  {{pass}}
   
  {{pass}}
  
 {{for grade in grades:}}

{{=Totais[grade] if
Totais.has_key(grade) else 0}}
{{pass}}
 
   


.a1 {
border:1px solid black;
 background-color: #00ff00;
}
.a0 {

background-color: cyan;
border:1px solid black;

}
.a2 {

background-color: white;
border:1px solid black;

}
.header {
 background-color: Yellow;
 color: Black;
border:1px solid black;
 font-family: arial;
 font-size:10;
 text-align: center;
}
.bottom {
 background-color: #9f9fff;
 color: black;
border:1px solid black;
 font-family: arial;
 font-size:10;
 text-align: right;
font-weight:bold;

}
.silos{
 background-color: #ece9d8;
 color: green;
border:1px solid black;
 font-family: arial;
 font-size:10;
 text-align: right;

}








2011/10/26 Anthony 

> You probably have some CSS or Javascript somewhere that is telling the
> browser to display the URL for links in parentheses after the link text.
> Something like this:
> http://davidwalsh.name/optimize-your-links-for-print-using-css-show-url
>
>
> On Wednesday, October 26, 2011 9:57:45 AM UTC-4, Ramos wrote:
>
>> this is what i have in the source
>> > href="/DO/Silos/SiloDetalhe/1
>> "**>79.4  When printed in paper it shows the href after the
>> 79.4 value.
>>
>> Strange?!
>>
>>
>>
>> 011/10/26 Anthony 
>>
>>> Does the (/DO/Silos/SiloDetalhe/2) appear inside the TDs in the HTML page
>>> source (not what the browser shows, the actual HTML source code), or only in
>>> the printed output?
>>>
>>>
>>> On Wednesday, October 26, 2011 6:00:12 AM UTC-4, Ramos wrote:

 hello i have a problem

 please see image1.jpeg is what i see in the browser

 when i print it i get what you see in image2.pdf

 How is that possible?

 Thank you

>>>
>>


[web2py] SQLFORM.grid awesomeness and some questions

2011-10-26 Thread Cliff
SQLFORM.grid is amazing.  Many thanks Massimo, Bruno, Martin and
everyone involved.

Is there a way to replace the contents of the  tag at the top of
the view?  All the pages show "Index."  This is okay for the index
view, but I would like to change it to "Edit", "View" and so on.

Do the "design", "request" and other buttons at the bottom of the form
go away when not on localhost?  Or do I have to do something to
suppress them?

Thanks,
Cliff Kachinske


Re: [web2py] Re: Problem printing a web2py webpage

2011-10-26 Thread Anthony
You probably have some CSS or Javascript somewhere that is telling the 
browser to display the URL for links in parentheses after the link text. 
Something like 
this: http://davidwalsh.name/optimize-your-links-for-print-using-css-show-url

On Wednesday, October 26, 2011 9:57:45 AM UTC-4, Ramos wrote:
>
> this is what i have in the source
>  href="/DO/Silos/SiloDetalhe/1
> ">79.4  When printed in paper it shows the href after the 
> 79.4 value.
>
> Strange?!
>
>
>
> 011/10/26 Anthony 
>
>> Does the (/DO/Silos/SiloDetalhe/2) appear inside the TDs in the HTML page 
>> source (not what the browser shows, the actual HTML source code), or only 
>> in the printed output?
>>
>>
>> On Wednesday, October 26, 2011 6:00:12 AM UTC-4, Ramos wrote:
>>>
>>> hello i have a problem
>>>
>>> please see image1.jpeg is what i see in the browser
>>>
>>> when i print it i get what you see in image2.pdf
>>>
>>> How is that possible?
>>>
>>> Thank you
>>>
>>
>

Re: [web2py] Re: Problem printing a web2py webpage

2011-10-26 Thread António Ramos
this is what i have in the source
https://194.65.91.152/DO/Silos/SiloDetalhe/1>
">79.4  When printed in paper it shows the href after the 79.4
value.

Strange?!



011/10/26 Anthony 

> Does the (/DO/Silos/SiloDetalhe/2) appear inside the TDs in the HTML page
> source (not what the browser shows, the actual HTML source code), or only in
> the printed output?
>
>
> On Wednesday, October 26, 2011 6:00:12 AM UTC-4, Ramos wrote:
>>
>> hello i have a problem
>>
>> please see image1.jpeg is what i see in the browser
>>
>> when i print it i get what you see in image2.pdf
>>
>> How is that possible?
>>
>> Thank you
>>
>


Re: [web2py] NInja IDE 2.0b and Plugin contest

2011-10-26 Thread Sebastian E. Ovide
how is it compared with Eclipse PyDev ?

On Wed, Oct 26, 2011 at 2:35 PM, Martín Mulone wrote:

> I'm using too and is great.
>
>
> 2011/10/26 Bruno Rocha 
>
>> NInja IDE released 2.0b and it is awesome! (http://www.ninja-ide.org/)
>>
>> They are running a plugin contest http://www.ninja-ide.org/plugins/
>>
>> Any taker to create a web2py plugin?
>>
>> What features do people think a web2py plugin for Ninja-IDE should have?
>>
>> --
>>
>> Bruno Rocha
>> [http://rochacbruno.com.br]
>>
>>
>
>
> --
>  http://martin.tecnodoc.com.ar
>
>


-- 
Sebastian E. Ovide


Re: [web2py] NInja IDE 2.0b and Plugin contest

2011-10-26 Thread Martín Mulone
I'm using too and is great.

2011/10/26 Bruno Rocha 

> NInja IDE released 2.0b and it is awesome! (http://www.ninja-ide.org/)
>
> They are running a plugin contest http://www.ninja-ide.org/plugins/
>
> Any taker to create a web2py plugin?
>
> What features do people think a web2py plugin for Ninja-IDE should have?
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


-- 
 http://martin.tecnodoc.com.ar


[web2py] Re: NInja IDE 2.0b and Plugin contest

2011-10-26 Thread Ross Peoples
That would be cool. I've never used Ninja IDE, but it looks nice. I'm all 
for more IDE support for web2py. Then all it needs is the Mac version, and 
we're all set :)

[web2py] Re: Web2py won't connect to MSSQL

2011-10-26 Thread CJM
Thank you Massimo!

The driver did return None and setting the driver manually did the
trick.

Is this an issue with web2py or did I somehow setup my machine
incorrectly?



On Oct 25, 6:15 pm, Massimo Di Pierro 
wrote:
> try:
>
> from gluon.dal import MSSQLAdapter
> print MSSQLAdapter.driver
>
> My guess isthat it is failing to import pyodbc from dal.py somehow and
> the driver should should be set to
>
>    driver = globals().get('pyodbc',None)
>
> is set to None instead.
>
> On Oct 25, 10:20 am, CJM  wrote:
>
>
>
>
>
>
>
> > I'm unable to get web2py to connect to mssql.
>
> > (Failure to connect, tried 5 times:
> > 'NoneType' object has no attribute 'connect')
>
> > My connection string is: db = DAL('mssql://
> > testUser:password1@localhost/testDB')
>
> > Environment
> >   Windows Server 2008 R2, 64-bit operating system
> >   SQL Server 2008 R2, local.
> >   Web2py: source code install version 1.99.2 (2011-09-26 06:55:33)
> > stable.
> >   pyodbc
> >   Python 2.7.2
>
> > I've tested that I can connect using the pyodbc. The following code
> > works:
>
> > import pyodbc
> > cnxn = pyodbc.connect('DRIVER={SQL
> > Server};SERVER=localhost;DATABASE=testDB;UID=testUser;PWD=password1')
> > cursor = cnxn.cursor()
> > cursor.execute("select * from tbUsers")
> > rows = cursor.fetchall()
> > for row in rows:
> >   print row
>
> > Thanks for your time.
>
> > Corey.


[web2py] Re: Problem printing a web2py webpage

2011-10-26 Thread Anthony
Does the (/DO/Silos/SiloDetalhe/2) appear inside the TDs in the HTML page 
source (not what the browser shows, the actual HTML source code), or only 
in the printed output?

On Wednesday, October 26, 2011 6:00:12 AM UTC-4, Ramos wrote:
>
> hello i have a problem
>
> please see image1.jpeg is what i see in the browser
>
> when i print it i get what you see in image2.pdf
>
> How is that possible?
>
> Thank you
>


[web2py] Re: list of usernames

2011-10-26 Thread Anthony
This is probably the easiest way to go. You could use a computed field, but 
then if you want the computed field to appear in an update form, you have 
to explicitly list it (along with all fields you want to appear). Note, if 
you instead used request.vars.to to set the field default, that wouldn't 
present any danger in terms of the contents of request.vars.to not being 
validated, because you're only using the length of request.vars.to. It 
would only be an issue if the validation of request.vars.to could result in 
it passing validation but its length changing as a result of that.

Anthony

On Wednesday, October 26, 2011 6:39:29 AM UTC-4, Archibald Linx wrote:
>
> Thank you Anthony. 
>
> I will need to exclusively modify the variable "status" on other 
> occasions. So I am not sure I really want "computed fields". Is that 
> true ? 
>
> So I decided to try an onvalidation function and I ended up with : 
>
> def status(form): 
> form.vars.status = [0]*len(form.vars.to) 
>
> def write(): 
> form = SQLFORM(db.message) 
> if form.accepts(request.vars, session, onvalidation=status): 
> response.flash = 'Got it' 
>
> It seems to work. 
>
> Is it ok ? If I have understood correctly, onvalidation is called 
> after validation and before insert. Like this I am sure 
> "forms.vars.to" does not contain anything fishy or dangerous. 
>
> Thanks, 
> Archibald 
>
>
> On 25 oct, 18:30, Anthony  wrote: 
> > On Tuesday, October 25, 2011 11:45:41 AM UTC-4, Archibald Linx wrote: 
> > 
> > > Thank you Anthony. 
> > 
> > > All this works very nicely. 
> > > Maybe the default format for auth_user should also be documented. 
> > 
> > > Let's say I have the following table : 
> > > db.define_table('message', 
> > > Field('to', 'list:reference auth_user'), 
> > > Field('status', 'list:integer')) 
> > 
> > > I want "status" to be a list of 0 as long as "to", but 
> > > "db.message.status.default = [0]*len(db.message.to.default)" does not 
> > > work. 
> > 
> > db.message.to.default represents the default value for the 'to' field 
> (which 
> > you have not set), not the actually values being inserted. Anyway, I 
> don't 
> > think the default for one field can reference the values of another. 
> > 
> > There are a few other options. You could use a computed field (though by 
> > default that won't display in a form, if you need that). If 
> inserts/updates 
> > will always be handled via form submissions, you could us a form 
> > onvalidation function or a custom validator. You could also just do 
> > default=[0]*len(request.vars.to), since upon form submission, the 
> values 
> > submitted to the 'to' field will be stored in request.vars.to (note, 
> the 
> > values stored in request.vars will be the unvalidated values). See here 
> for 
> > more 
> > details:
> http://stackoverflow.com/questions/7325776/using-a-lambda-for-a-model... 
> > 
> > Anthony



[web2py] Re: Nested functions problem?

2011-10-26 Thread Anthony
On Wednesday, October 26, 2011 7:08:43 AM UTC-4, annet wrote:
>
>
> image=db((db.bedrijfimagelink.bedrijf_id==id).select(db.imagelink.link).first()
>  
>
>

Maybe these are just typos, but looks like you've got an extra ( at the 
beginning, and your select is coming from a different table than the query.

 
>   
> {{=LOAD('locator','imagetext.load',args=283,ajax=True,target='component')}} 
>
> 
>

No, don't put the LOAD helper inside a div. The LOAD helper creates its own 
div with the id of the 'target' argument. The above will create a div with 
id='component' inside another div with id='component' (which isn't allowed).

Also, whenever a component fails to load properly, always check to make 
sure the action itself is returning something -- you can do that by going 
directly to the URL of the component: /yourapp/locator/imagetext.load
 

>  
>   
> {{=A('Lesrooster',callback=URL('timetable','timetable',args=[company.id]),target='component')}}
>  
>
>   
>
>
> Which generates the following link: 
>
> Lesrooster 
>
>
> .. and address in the browser: 
> http://127.0.0.1:8000/init/locator/businesscard/283#null 
>

Hmm, does the link really have no space between the end of the onclick and 
the href (i.e., ...false;"href)? If so, see if you can hand code that link 
and add a space. If that's the issue, there may be a bug in the A() helper.

Anthony


[web2py] Re: Nested functions problem?

2011-10-26 Thread annet
The timetable link now works:


 
{{=A('Lesrooster',callback=URL('timetable','timetable',args=[company.id]),target='component')}}
 

I have no idea why it didn't work ... So I am left with the problem of
loading the image and text the first time the locator/businesscard
page opens.


Kind regards,

Annet.


[web2py] SQLTABLE param headers=None bug - Web2py 1.99.2 (2011-09-26 06:55:33) stable

2011-10-26 Thread Calvin
Hi

I think I found a bug with the headers with the above version, which
when headers=None generates a unsubscriptable error at line 2061:

if isinstance(headers[colname],dict):

This error can be fixed by the following changes added to line 1966 of
sqlhtml.py:


if not headers is None:
for c in columns:#new implement dict
if isinstance(headers.get(c, c), dict):
coldict = headers.get(c, c)
attrcol = dict()
if coldict['width']!="":
attrcol.update(_width=coldict['width'])
if coldict['class']!="":
attrcol.update(_class=coldict['class'])
row.append(TH(coldict['label'],**attrcol))
elif orderby:
row.append(TH(A(headers.get(c, c),
_href=th_link+'?orderby=' + c)))
else:
row.append(TH(headers.get(c, c)))

if extracolumns:#new implement dict
for c in extracolumns:
attrcol = dict()
if c['width']!="":
attrcol.update(_width=c['width'])
if c['class']!="":
attrcol.update(_class=c['class'])
row.append(TH(c['label'],**attrcol))

components.append(THEAD(TR(*row)))
+else:
+  headers={}

Cheers
Calvin


[web2py] Re: Nested functions problem?

2011-10-26 Thread annet
I tried:

Controller:

def imagetext():
id=request.args(0)
 
image=db((db.bedrijfimagelink.bedrijf_id==id).select(db.imagelink.link).first()
text=db(db.hptext.bedrijf_id==id).select(db.hptext.tekst).first()
return dict(image=image,text=text)

View:


 
{{=LOAD('locator','imagetext.load',args=283,ajax=True,target='component')}}



and the second view locator/imagetext.load:


{{if image:}}
  
{{=IMG(_src=URL('static','init/images/banners/%s' % image.link),
_width="696px", _height="120px")}}
   
{{pass}}
{{if text:}}
  

  {{=XML(text.tekst)}}
 
   
{{pass}}


But the div displays Loading... instead of the text and the image.


I also tried:

Controller:

def businesscard():
if not len(request.args):
redirect(URL('default','error'))
else:
id=request.args(0)
...
 
functions=db(db.function.bedrijf_id==id).select(db.function.ALL).first()
...
if functions.image:
 
image=db((db.bedrijfimagelink.bedrijf_id==id).select(db.imagelink.link).first()
if functions.text:
 
text=db(db.hptext.bedrijf_id==id).select(db.hptext.tekst).first()

return dict(..,image=image,text=text)


View:


  {{if image:}}

  {{=IMG(_src=URL('static','init/images/banners/%s' % image.link),
_width="696px", _height="120px")}}
 
  {{pass}}
  {{if text:}}

  
{{=XML(text.tekst)}}
   
 
  {{pass}}
 
...

 
{{=A('Lesrooster',callback=URL('timetable','timetable',args=[company.id]),target='component')}}
 


Which generates the following link:

Lesrooster


.. and address in the browser: 
http://127.0.0.1:8000/init/locator/businesscard/283#null


... but doesn;t work either.


The problem with Cliff's solution (and all the examples at w3c) is
that the image and text are part of the first page, I cannot have the
vistor click a button to display the image and text.


I hope there is a way to get this to work ..

Kind regards,

Annet.


[web2py] Re: list of usernames

2011-10-26 Thread Archibald Linx
Thank you Anthony.

I will need to exclusively modify the variable "status" on other
occasions. So I am not sure I really want "computed fields". Is that
true ?

So I decided to try an onvalidation function and I ended up with :

def status(form):
form.vars.status = [0]*len(form.vars.to)

def write():
form = SQLFORM(db.message)
if form.accepts(request.vars, session, onvalidation=status):
response.flash = 'Got it'

It seems to work.

Is it ok ? If I have understood correctly, onvalidation is called
after validation and before insert. Like this I am sure
"forms.vars.to" does not contain anything fishy or dangerous.

Thanks,
Archibald


On 25 oct, 18:30, Anthony  wrote:
> On Tuesday, October 25, 2011 11:45:41 AM UTC-4, Archibald Linx wrote:
>
> > Thank you Anthony.
>
> > All this works very nicely.
> > Maybe the default format for auth_user should also be documented.
>
> > Let's say I have the following table :
> > db.define_table('message',
> >     Field('to', 'list:reference auth_user'),
> >     Field('status', 'list:integer'))
>
> > I want "status" to be a list of 0 as long as "to", but
> > "db.message.status.default = [0]*len(db.message.to.default)" does not
> > work.
>
> db.message.to.default represents the default value for the 'to' field (which
> you have not set), not the actually values being inserted. Anyway, I don't
> think the default for one field can reference the values of another.
>
> There are a few other options. You could use a computed field (though by
> default that won't display in a form, if you need that). If inserts/updates
> will always be handled via form submissions, you could us a form
> onvalidation function or a custom validator. You could also just do
> default=[0]*len(request.vars.to), since upon form submission, the values
> submitted to the 'to' field will be stored in request.vars.to (note, the
> values stored in request.vars will be the unvalidated values). See here for
> more
> details:http://stackoverflow.com/questions/7325776/using-a-lambda-for-a-model...
>
> Anthony


Re: [web2py] book 3.2ed

2011-10-26 Thread Johann Spies
Thanks!

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)