Re: [web2py] Oreilly python-Certification

2011-11-14 Thread Phyo Arkar
Cool , i am so bored to study for certs but i think this one is cool!

On 11/14/11, António Ramos ramstei...@gmail.com wrote:
 http://www.oreillyschool.com/certificates/python-programming.php



Re: [web2py] Webfaction: Memory usage way over your limit ; again.

2011-11-14 Thread Roberto De Ioris

 Again at Webfaction my memory usage is way over my limit:

 Below is the list of processes that you're running with the memory
 that they use (the command used to list these processes is ps -u
 fitwise -o rss,etime,pid,command):

 User - Memory - Elapsed Time - Pid - Command:
 
 fitwise - 1MB - 24 days, 11:45:32 - 30464 - /home/fitwise/webapps/w2p/
 apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
 httpd.conf -k start
 fitwise - 27MB - 24 days, 11:45:32 - 30465 - /home/fitwise/webapps/w2p/
 apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
 httpd.conf -k start
 fitwise - 25MB - 24 days, 11:45:32 - 30466 - /home/fitwise/webapps/w2p/
 apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
 httpd.conf -k start
 fitwise - 25MB - 24 days, 11:45:32 - 30467 - /home/fitwise/webapps/w2p/
 apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
 httpd.conf -k start
 fitwise - 26MB - 24 days, 11:45:32 - 30468 - /home/fitwise/webapps/w2p/
 apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
 httpd.conf -k start
 fitwise - 25MB - 24 days, 11:45:32 - 30469 - /home/fitwise/webapps/w2p/
 apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
 httpd.conf -k start
 fitwise - 2MB - 24 days, 11:45:32 - 30470 - /home/fitwise/webapps/w2p/
 apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
 httpd.conf -k start

 I did this:

 Serve static media with a Static-only application.

 I did not yet set up Nginx+uwsgi because at Webfaction they said:
 Using Nginx+uwsgi may reduce your memory usage, but it will involve
 some experimentation with your application. and I don't have much
 time to experiment at the moment.

There is nothing to experiment to with webfaction + uWSGI.

After having installed uWSGI 1.0 (from mercurial and with python2.6)
simply run it with

uwsgi --wsgi-file web2py/wsgihandler.py -m --http-socket :PORT

where PORT is the port assigned by webfaction.

The -m flag report the memory usage after each request, and you can
obviously add flags to automatically respawn instances based on memory
usage.

PAY ATTENTION:

only the 1.0 branch of uWSGI is fully usable in webfaction without nginx
or the --http option, and has support for their HTTPS proxy out of the box
(thanks to the report of a web2py user in this list).

Webfaction guys should really invest some time in uWSGI analysys, as it is
built with their kind of services in mind.

QUICK AND DIRT WAY (from webfaction ssh home)

# install mercurial
easy_install mercurial
hg clone http://projects.unbit.it/hg/uwsgi
cd uwsgi
# compile uwsgi
make -f Makefile.Py26
cd ..
# download web2py
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
cd web2py
# run web2py rocket server to setup password
python2.6 web2py.py
# set your password then kill the server
cp parameters_8080.py parameters_PORT.py
# where PORT is your webfaction port
cd ..
# start uwsgi
./uwsgi/uwsgi --wsgi-file web2py/wsgihandler.py -m --http-socket :PORT

-- 
Roberto De Ioris
http://unbit.it


[web2py] Re: configuration of mail in appengine

2011-11-14 Thread Joseph Jude
Below works for me:
steps I followed. Your context may differ and customize accordingly.
1) define a db model with the fields you want; I wanted all emails to be 
stored too, so I defined this model
2) define two functions - a contact fn that gets called from template; the 
contact fn itself calls another fn to send email; in the template you can 
validate the fields like valid email id etc.
3) This is for sending emails from admin email; customization is needed if 
otherwise


Here is the code:

def contact(): 
form = crud.create(db.contact_emails, 
onaccept=_send_email, 
next = URL('index'), 
message=T(Thank you for your message))
return dict(form=form)

def _send_email(form):
#called from successful accept of contact form
#form is sent as a first argument
mail=Mail()
mail.settings.server='gae'
mail.settings.sender=x...@gmail.com #This must be the email address of a 
registered
   #administrator for the application
mail.settings.login = None
mail.send(to='xx...@gmail.com', subject='[123-Check] Contact', 
message=form.vars.body)

return 


Re: [web2py] Webfaction: Memory usage way over your limit ; again.

2011-11-14 Thread Vasile Ermicioi
web2py is a great framework
webfaction is a great hosting

God bless you, Roberto, by making it possible to use them together :)

and uwsgi is a great webserver :)

will try soon 1.0 version


[web2py] Re: configuration of mail in appengine

2011-11-14 Thread Joseph Jude
You can see it working at: 123-check.appspot.com/init/default/contact

[web2py] REAGARDING WEBGRID AND POWER GRID

2011-11-14 Thread Rohitraj Sharma
I HAVE MADE ONE APPLICATION WHERE I USED WEB GRID AND POWER GRID ITS
WORK IN LOCAL HOST BUT WHEN I DEPLOY ON GOOGLE APPS ENGINE IYS SHOW
FOR WEB GRID invalid view (default/
Registration_Certificate_Repository.html)
AND FOR

POWER GRID  Internal error  Ticket issued: unknown

AND MY SECOUND PROBLEM IS MY MAIL IS NOT WORKING IN APPLICATION I
USED
mail.settings.server = 'smtp.gae.com' ITS WORK IN LOCAL HOST BUT NOT
IN GOOGLE APPS ENGINE

mail.settings.server = 'smtp.gmail.com:587' GAE IS NOT WORKING
mail.settings.sender = 'feedb...@themislexsol.com' # your
email
mail.settings.login = 'feedb...@my.com :ABCDEFG '  # your
credentials or None
CAPTCHA ALSO NOT WORK
auth.settings.captcha = Recaptcha(request,
'6LdtW8gSAPVbyL_oWtc58IzNaVbPF_xnoDsJ',
'6LdtW8gSAJleuqP9B8mQZWrpHwHjXfJ19dnT')


PLZ HELP ME IN THAT
THANKS


[web2py] How to change the position of submit button in a SQLFORM

2011-11-14 Thread Dominique
Hello All,

I have a form built with SQLFORM.factory.

I would like to change the position of the submit button.

I know how to insert an element somewhere with for instance 
form[0][3][1].insert(-1, my_element) but not how to move the submit button 
from its pre-defined place (last row) to another place.

I'd prefer not to define its place in the view but rather in the controller.

For info, the hierarchy of the form is:
form
input1
select1
div1
div2
div class=w2p_fl
div class=w2p_fw
select id='bla1
select id=bla2
div class=w2p_fc
div3 id=submit_record_row
iv class=w2p_fl
div class=w2p_fw
input type=submit
 div class=w2p_fc

I'd like to move the submit button (which is in the div3) to the div2, just 
after the select id=bla2

Thanks in advance for any help

Dominique


[web2py] SQLForm.grid - How do I use it properly?

2011-11-14 Thread Rahul
Hi All,
  Can anyone let me know how to use SQLForm.grid properly or tell
me what I am missing. I have not installed any jquery plugin for the
same (assuming that it is part of 1.99.2 by default). I cannot see the
complete grid, just some buttons and data as per my query below. Also
the links do not function when clicked. The table does not show any
backgroud color or anything. Simply it doesnt look like a jquery
grid.  My code is as below -

My machine - Windows7 , IE9 and Firefox 7.0, Chrome.
Web2py- Latest stable (1.99.1)

#-Controller- (default.py)---
def index():

example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html

#Posts grid - SQLForm.grid
#grid = SQLFORM.grid(db.projects_posts)
query = ((db.projects_posts.post_visibility==Classified))
columns = ('projects_posts.title',
   'projects_posts.project_details',
   'projects_posts.estimated_worth'
  )
headers ={'projects_posts.title': 'Title',
  'projects_posts.project_details': 'Details',
  'projects_posts.estimated_worth': 'Worth'}

form = SQLFORM.grid( query=query, columns=columns,
headers=headers,
 deletable=False, editable=False, csv=False,
maxtextlength=64 )


return dict(form=form)

#- View ---  (index.html)
{{extend 'layout.html'}}
{{=form}}


Also, if possible please refer me to the proper documentation for
SQLForm.grid. Again, if I include the parameter  form =
SQLForm.grid(.,  ui=jquery-ui) in above code, the buttons
disappear and it only shows me links for 'view' etc.

Q: What is the exact proper method to use SQLForm.grid -
Q: What all libraries do I need to include? where?
Q: How to make links work the way they should ?
Q: Can search be customized? How?
Q: Is this documented in online book?  - did not find much about it in
version 3.2 though.

Please advice or refer me to the proper thread(though I checked
several to find solutions).

Regards, Rahul


[web2py] Re: Resetting the database

2011-11-14 Thread Archibald Linx
Thank you Bruno.

I am using SQLite.

I want to reset all the tables of my project.

Thanks,
Archibald

On 14 nov, 01:44, Bruno Rocha rochacbr...@gmail.com wrote:
 which database engine?

 http://zerp.ly/rochacbruno
 Em 13/11/2011 22:38, Archibald Linx archibaldl...@gmail.com escreveu:







  Dear Web2py users,

  How can I reset the database of my Web2py project ?

  Thanks,
  Archibald


[web2py] book ch7 upload

2011-11-14 Thread Plumo
I wanted to make a comment on the book but a single line input box is used 
instead of a textarea. 
Should this be changed?

Anyway, need to post here for now.
I tried following the upload example in ch7.

The docs specify:
form.validate(...)
is a shortcut for:
form.process(...,dbio=False).accepted

Then the examples use:
form.validate().accepted

This should just be: 
form.validate()


Then I tried the SQLFORM.factory upload example with v1.99.2, and got this 
error:
RuntimeError: you must specify a Field(...,uploadfolder=...)

uploadfolder should not be required because I don't want to store the file.

Richard


[web2py] Re: How to change the position of submit button in a SQLFORM

2011-11-14 Thread DenesL
Hi Dominique,

I believe the easiest would be to manually insert the submit button at
the appropriate location, as in the following example:

form = SQLFORM.factory(
  Field('name'),
  Field('age','integer'),
  formstyle='divs',
  buttons=[],
)
form[0].insert(1,DIV(INPUT(_type='submit', _value='submit me')))

Notes:
- the submit button will be in the middle of the form in this case
- you can further style the DIV or the INPUT as needed
- formstyle divs used here, it should work with the others too
- buttons=[] blocks the auto-created submit button at the bottom
- change the insert index to your desired location


On Nov 14, 5:26 am, Dominique mydom...@gmail.com wrote:
 Hello All,

 I have a form built with SQLFORM.factory.

 I would like to change the position of the submit button.

 I know how to insert an element somewhere with for instance
 form[0][3][1].insert(-1, my_element) but not how to move the submit button
 from its pre-defined place (last row) to another place.

 I'd prefer not to define its place in the view but rather in the controller.

 For info, the hierarchy of the form is:
 form
 input1
 select1
 div1
 div2
 div class=w2p_fl
 div class=w2p_fw
 select id='bla1
 select id=bla2
 div class=w2p_fc
 div3 id=submit_record_row
 iv class=w2p_fl
 div class=w2p_fw
 input type=submit
  div class=w2p_fc

 I'd like to move the submit button (which is in the div3) to the div2, just
 after the select id=bla2

 Thanks in advance for any help

 Dominique


[web2py] Re: Resetting the database

2011-11-14 Thread DenesL
Hi Archibald,

if you want to clear all records from a table do:

  db.table.truncate()

To clear all just loop thru db.tables .

db.commit() to finish.

It should work for all DBs.


On Nov 14, 7:56 am, Archibald Linx archibaldl...@gmail.com wrote:
 Thank you Bruno.

 I am using SQLite.

 I want to reset all the tables of my project.

 Thanks,
 Archibald

 On 14 nov, 01:44, Bruno Rocha rochacbr...@gmail.com wrote:







  which database engine?

 http://zerp.ly/rochacbruno
  Em 13/11/2011 22:38, Archibald Linx archibaldl...@gmail.com escreveu:

   Dear Web2py users,

   How can I reset the database of my Web2py project ?

   Thanks,
   Archibald


[web2py] Re: How to change the position of submit button in a SQLFORM

2011-11-14 Thread Anthony
On Monday, November 14, 2011 8:53:30 AM UTC-5, DenesL wrote:

 - buttons=[] blocks the auto-created submit button at the bottom


Another undocumented feature. What is the purpose of 'buttons'? The only 
code I see that deals with it simply checks whether it includes 'submit'. 
What happens if you put other things in the list? If it's just for 
including/excluding the submit button, why not a boolean?

Anthony 


[web2py] Re: Removal of 'columns' in grid/smartgrid creates problems for search function

2011-11-14 Thread Massimo Di Pierro
You just made an excellent case for putting the columns back.

Massimo

On Nov 14, 1:52 am, Johann Spies johann.sp...@gmail.com wrote:
 I have used the columns-argument to set the display columns and the
 'fields' argument to define the search fields for the search function.

 I only wanted to display 2 columns of a table but about 15 fields to be
 searchable eg.  '* parent_organisation contains america'.*
 Now if 'parent_organisation' is not spesified in 'fields' I get a 'invalid
 query' result.

 It worked well.  How can I have the same functionality with no
 columns-argument?

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


[web2py] Re: Removal of 'columns' in grid/smartgrid creates problems for search function

2011-11-14 Thread Massimo Di Pierro
I put it back, give it a try.

On Nov 14, 1:52 am, Johann Spies johann.sp...@gmail.com wrote:
 I have used the columns-argument to set the display columns and the
 'fields' argument to define the search fields for the search function.

 I only wanted to display 2 columns of a table but about 15 fields to be
 searchable eg.  '* parent_organisation contains america'.*
 Now if 'parent_organisation' is not spesified in 'fields' I get a 'invalid
 query' result.

 It worked well.  How can I have the same functionality with no
 columns-argument?

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


[web2py] Re: Webfaction: Memory usage way over your limit ; again.

2011-11-14 Thread Massimo Di Pierro
Thanks Roberto.
How about you send me a setup-script to include in the scrips folder?

On Nov 14, 3:03 am, Roberto De Ioris robe...@unbit.it wrote:
  Again at Webfaction my memory usage is way over my limit:

  Below is the list of processes that you're running with the memory
  that they use (the command used to list these processes is ps -u
  fitwise -o rss,etime,pid,command):

  User - Memory - Elapsed Time - Pid - Command:
  
  fitwise - 1MB - 24 days, 11:45:32 - 30464 - /home/fitwise/webapps/w2p/
  apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
  httpd.conf -k start
  fitwise - 27MB - 24 days, 11:45:32 - 30465 - /home/fitwise/webapps/w2p/
  apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
  httpd.conf -k start
  fitwise - 25MB - 24 days, 11:45:32 - 30466 - /home/fitwise/webapps/w2p/
  apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
  httpd.conf -k start
  fitwise - 25MB - 24 days, 11:45:32 - 30467 - /home/fitwise/webapps/w2p/
  apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
  httpd.conf -k start
  fitwise - 26MB - 24 days, 11:45:32 - 30468 - /home/fitwise/webapps/w2p/
  apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
  httpd.conf -k start
  fitwise - 25MB - 24 days, 11:45:32 - 30469 - /home/fitwise/webapps/w2p/
  apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
  httpd.conf -k start
  fitwise - 2MB - 24 days, 11:45:32 - 30470 - /home/fitwise/webapps/w2p/
  apache2/bin/httpd.worker -f /home/fitwise/webapps/w2p/apache2/conf/
  httpd.conf -k start

  I did this:

  Serve static media with a Static-only application.

  I did not yet set up Nginx+uwsgi because at Webfaction they said:
  Using Nginx+uwsgi may reduce your memory usage, but it will involve
  some experimentation with your application. and I don't have much
  time to experiment at the moment.

 There is nothing to experiment to with webfaction + uWSGI.

 After having installed uWSGI 1.0 (from mercurial and with python2.6)
 simply run it with

 uwsgi --wsgi-file web2py/wsgihandler.py -m --http-socket :PORT

 where PORT is the port assigned by webfaction.

 The -m flag report the memory usage after each request, and you can
 obviously add flags to automatically respawn instances based on memory
 usage.

 PAY ATTENTION:

 only the 1.0 branch of uWSGI is fully usable in webfaction without nginx
 or the --http option, and has support for their HTTPS proxy out of the box
 (thanks to the report of a web2py user in this list).

 Webfaction guys should really invest some time in uWSGI analysys, as it is
 built with their kind of services in mind.

 QUICK AND DIRT WAY (from webfaction ssh home)

 # install mercurial
 easy_install mercurial
 hg clonehttp://projects.unbit.it/hg/uwsgi
 cd uwsgi
 # compile uwsgi
 make -f Makefile.Py26
 cd ..
 # download web2py
 wgethttp://www.web2py.com/examples/static/web2py_src.zip
 unzip web2py_src.zip
 cd web2py
 # run web2py rocket server to setup password
 python2.6 web2py.py
 # set your password then kill the server
 cp parameters_8080.py parameters_PORT.py
 # where PORT is your webfaction port
 cd ..
 # start uwsgi
 ./uwsgi/uwsgi --wsgi-file web2py/wsgihandler.py -m --http-socket :PORT

 --
 Roberto De Iorishttp://unbit.it


[web2py] Re: book ch7 upload

2011-11-14 Thread Massimo Di Pierro
Please open a ticket about this. Right now dal does not know you are
not plannit to do dbio.

You can try replace in dal.py

else:
raise RuntimeError, you must specify a
Field(...,uploadfolder=...)

elif not self._db._uri is None:
raise RuntimeError, you must specify a
Field(...,uploadfolder=...)

Let me know if this solves the problem.



On Nov 14, 7:42 am, Plumo richar...@gmail.com wrote:
 I wanted to make a comment on the book but a single line input box is used
 instead of a textarea.
 Should this be changed?

 Anyway, need to post here for now.
 I tried following the upload example in ch7.

 The docs specify:
 form.validate(...)
 is a shortcut for:
 form.process(...,dbio=False).accepted

 Then the examples use:
 form.validate().accepted

 This should just be:
 form.validate()

 Then I tried the SQLFORM.factory upload example with v1.99.2, and got this
 error:
 RuntimeError: you must specify a Field(...,uploadfolder=...)

 uploadfolder should not be required because I don't want to store the file.

 Richard


[web2py] Re: How to change the position of submit button in a SQLFORM

2011-11-14 Thread Massimo Di Pierro
You can add other buttons like

buttons = [INPUT(_type=submit),
INPUT(_type=button,_onclick=history.go(-1);return False)]

etc.

On Nov 14, 8:05 am, Anthony abasta...@gmail.com wrote:
 On Monday, November 14, 2011 8:53:30 AM UTC-5, DenesL wrote:

  - buttons=[] blocks the auto-created submit button at the bottom

 Another undocumented feature. What is the purpose of 'buttons'? The only
 code I see that deals with it simply checks whether it includes 'submit'.
 What happens if you put other things in the list? If it's just for
 including/excluding the submit button, why not a boolean?

 Anthony


Re: [web2py] SQLForm.grid - How do I use it properly?

2011-11-14 Thread Jim Steil

here are a few thoughts...

1.  Make sure you create this test in a new app.  If you're updating or 
adding functionality to an already existing app, then your layout and 
base.css need to be updated.
2.  If using jquery-ui, then you need to download jquery-ui and include 
it in your layout.html with a line like this:



{{response.files.append(URL('static','jquery-ui/js/jquery-ui-1.8.16.custom.min.js'))}}

{{response.files.append(URL('static','jquery-ui/css/sunny/jquery-ui-1.8.16.custom.css'))}}


3.  Don't use the 'columns' argument.  It is going away in the next 
release.  Instead, use 'fields'.  In your case, use the following:


fields = [db.projects_posts.title, db.projects_posts.project_details, 
db.projects_posts.estimated_worth]


4.  I typically do not specify the 'headers' arg.  Instead, set the 
'label' on your table definition.  That way you only have to do it once 
and can use it all over.  If you need to override it for a particular 
function, then just set the 'label' attribute in that function.


5.  At this time there is no documentation available for SQLFORM.grid or 
SQLFORM.smartgrid.  The best thing to do would be to look through this 
group for all the posts.  Massimo is working on an updated version of 
that manual that he is hoping to have complete by the end of this 
month.  That should contain information on .grid and .smartgrid.


6.  If you are going to be playing around with this I would recommend 
that you work with the code in trunk.  I don't recall what state the 
.grid was in when 1.99.2 was released.


As for answers for your specific questions:

Q: What is the exact proper method to use SQLForm.grid -
I think your on the right track.  Just need to clean up your css and 
layout.html files to get the proper formatting.

Q: What all libraries do I need to include? where?
If you want to use jquery-ui then you need to download it and reference it in 
your layout.html.

Q: How to make links work the way they should ?
I'd like some more information on what is going on here before giving an answer.

Q: Can search be customized? How?
I don't remember if the search_form is implemented in 1.99.2, but there is a 
search facility built in that allows the users to create a custom search.  I am 
not a fan of it and have some other ideas how developers could be allowed to 
create custom search forms, but I haven't opened a ticket on it yet.

Q: Is this documented in online book?  - did not find much about it in
version 3.2 though.

Documentation will be coming with the next version of the book targeted 
for the end of the month.


Hope this helps.

-Jim


On 11/14/2011 6:54 AM, Rahul wrote:

Hi All,
   Can anyone let me know how to use SQLForm.grid properly or tell
me what I am missing. I have not installed any jquery plugin for the
same (assuming that it is part of 1.99.2 by default). I cannot see the
complete grid, just some buttons and data as per my query below. Also
the links do not function when clicked. The table does not show any
backgroud color or anything. Simply it doesnt look like a jquery
grid.  My code is as below -

My machine - Windows7 , IE9 and Firefox 7.0, Chrome.
Web2py- Latest stable (1.99.1)

#-Controller- (default.py)---
def index():
 
 example action using the internationalization operator T and flash
 rendered by views/default/index.html or views/generic.html
 
 #Posts grid - SQLForm.grid
 #grid = SQLFORM.grid(db.projects_posts)
 query = ((db.projects_posts.post_visibility==Classified))
 columns = ('projects_posts.title',
'projects_posts.project_details',
'projects_posts.estimated_worth'
   )
 headers ={'projects_posts.title': 'Title',
   'projects_posts.project_details': 'Details',
   'projects_posts.estimated_worth': 'Worth'}

 form = SQLFORM.grid( query=query, columns=columns,
headers=headers,
  deletable=False, editable=False, csv=False,
maxtextlength=64 )


 return dict(form=form)

#- View ---  (index.html)
{{extend 'layout.html'}}
{{=form}}


Also, if possible please refer me to the proper documentation for
SQLForm.grid. Again, if I include the parameter  form =
SQLForm.grid(.,  ui=jquery-ui) in above code, the buttons
disappear and it only shows me links for 'view' etc.

Q: What is the exact proper method to use SQLForm.grid -
Q: What all libraries do I need to include? where?
Q: How to make links work the way they should ?
Q: Can search be customized? How?
Q: Is this documented in online book?  - did not find much about it in
version 3.2 though.

Please advice or refer me to the proper thread(though I checked
several to find solutions).

Regards, Rahul


Re: [web2py] SQLForm.grid - How do I use it properly?

2011-11-14 Thread Jim Steil
I stand corrected on the 'columns' comment.  Massimo added it back in 
this morning.


-Jim

On 11/14/2011 8:45 AM, Jim Steil wrote:

here are a few thoughts...

1.  Make sure you create this test in a new app.  If you're updating 
or adding functionality to an already existing app, then your layout 
and base.css need to be updated.
2.  If using jquery-ui, then you need to download jquery-ui and 
include it in your layout.html with a line like this:



{{response.files.append(URL('static','jquery-ui/js/jquery-ui-1.8.16.custom.min.js'))}}

{{response.files.append(URL('static','jquery-ui/css/sunny/jquery-ui-1.8.16.custom.css'))}}


3.  Don't use the 'columns' argument.  It is going away in the next 
release.  Instead, use 'fields'.  In your case, use the following:


fields = [db.projects_posts.title, db.projects_posts.project_details, 
db.projects_posts.estimated_worth]


4.  I typically do not specify the 'headers' arg.  Instead, set the 
'label' on your table definition.  That way you only have to do it 
once and can use it all over.  If you need to override it for a 
particular function, then just set the 'label' attribute in that 
function.


5.  At this time there is no documentation available for SQLFORM.grid 
or SQLFORM.smartgrid.  The best thing to do would be to look through 
this group for all the posts.  Massimo is working on an updated 
version of that manual that he is hoping to have complete by the end 
of this month.  That should contain information on .grid and .smartgrid.


6.  If you are going to be playing around with this I would recommend 
that you work with the code in trunk.  I don't recall what state the 
.grid was in when 1.99.2 was released.


As for answers for your specific questions:

Q: What is the exact proper method to use SQLForm.grid -
I think your on the right track.  Just need to clean up your css and 
layout.html files to get the proper formatting.


Q: What all libraries do I need to include? where?
If you want to use jquery-ui then you need to download it and 
reference it in your layout.html.


Q: How to make links work the way they should ?
I'd like some more information on what is going on here before giving 
an answer.


Q: Can search be customized? How?
I don't remember if the search_form is implemented in 1.99.2, but 
there is a search facility built in that allows the users to create a 
custom search.  I am not a fan of it and have some other ideas how 
developers could be allowed to create custom search forms, but I 
haven't opened a ticket on it yet.


Q: Is this documented in online book?  - did not find much about it in
version 3.2 though.

Documentation will be coming with the next version of the book 
targeted for the end of the month.


Hope this helps.

-Jim


On 11/14/2011 6:54 AM, Rahul wrote:

Hi All,
   Can anyone let me know how to use SQLForm.grid properly or tell
me what I am missing. I have not installed any jquery plugin for the
same (assuming that it is part of 1.99.2 by default). I cannot see the
complete grid, just some buttons and data as per my query below. Also
the links do not function when clicked. The table does not show any
backgroud color or anything. Simply it doesnt look like a jquery
grid.  My code is as below -

My machine - Windows7 , IE9 and Firefox 7.0, Chrome.
Web2py- Latest stable (1.99.1)

#-Controller- (default.py)---
def index():
 
 example action using the internationalization operator T and flash
 rendered by views/default/index.html or views/generic.html
 
 #Posts grid - SQLForm.grid
 #grid = SQLFORM.grid(db.projects_posts)
 query = ((db.projects_posts.post_visibility==Classified))
 columns = ('projects_posts.title',
'projects_posts.project_details',
'projects_posts.estimated_worth'
   )
 headers ={'projects_posts.title': 'Title',
   'projects_posts.project_details': 'Details',
   'projects_posts.estimated_worth': 'Worth'}

 form = SQLFORM.grid( query=query, columns=columns,
headers=headers,
  deletable=False, editable=False, csv=False,
maxtextlength=64 )


 return dict(form=form)

#- View ---  (index.html)
{{extend 'layout.html'}}
{{=form}}


Also, if possible please refer me to the proper documentation for
SQLForm.grid. Again, if I include the parameter  form =
SQLForm.grid(.,  ui=jquery-ui) in above code, the buttons
disappear and it only shows me links for 'view' etc.

Q: What is the exact proper method to use SQLForm.grid -
Q: What all libraries do I need to include? where?
Q: How to make links work the way they should ?
Q: Can search be customized? How?
Q: Is this documented in online book?  - did not find much about it in
version 3.2 though.

Please advice or refer me to the proper thread(though I checked
several to find solutions).

Regards, Rahul


Re: [web2py] Re: Resetting the database

2011-11-14 Thread ~redShadow~
On Mon, 2011-11-14 at 06:02 -0800, DenesL wrote: 
 Hi Archibald,
 
 if you want to clear all records from a table do:
 
   db.table.truncate()
 
 To clear all just loop thru db.tables .
 
 db.commit() to finish.
 
 It should work for all DBs.
 
 
 On Nov 14, 7:56 am, Archibald Linx archibaldl...@gmail.com wrote:
  Thank you Bruno.
 
  I am using SQLite.
 
  I want to reset all the tables of my project.

* If you want to delete *content* of some specific table, use
``db.table.truncate()``, as DenesL says.
* If you want the DAL to recreate the whole table (with SQLite, the
allowed alters are limited, sometimes table drop is needed in order to
clean up): ``db.table.truncate()``
* If you want to completely destroy and recreate the whole database,
just empty the ``databases`` folder inside your application directory.

-- 
Samuele ~redShadow~ Santi

 redshadow[at]hackzine.org - redshadowhack[at]gmail.com

  Blog: http://hackzine.org

  GPG Key signature:
   050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933

/me recommends:
Squadra Informatica - http://www.squadrainformatica.com

 - Proud ThinkPad T-Series owner
 - Registered Linux-User: #440008
  * GENTOO User since 1199142000 (2008-01-01)
  * former DEBIAN SID user

  Software is like sex: it's better when it's free!
  -- Linus Torvalds



signature.asc
Description: This is a digitally signed message part


[web2py] Re: Resetting the database

2011-11-14 Thread apple
Web2py tries to redefine tables in line with changes in the model file
but sometimes this is not possible with sqlite. Therefore you may want
to delete the table definitions as well. If you do want a clean sheet
of paper then do this:

exclude=[]
import os
import glob
import sys
sys.path.append(c:/web2py)
from gluon import *
db = DAL('sqlite://storage.sqlite', folder='c:/web2py/applications/app/
databases', auto_import=True)

def delete():
for tablename in db.tables[:]:
if tablename in exclude or tablename[0:4]==auth:
print(keep +tablename)
else:
table=db[tablename]
try:
print(delete +tablename)
filelist=glob.glob(c:/web2py/applications/app/
databases/*+tablename+.table)
if len(filelist)0: os.remove(filelist[0])
table.drop()
except:
print(failed to delete +tablename)
print(sys.exc_info())
db.commit()
delete()

On Nov 14, 2:02 pm, DenesL denes1...@yahoo.ca wrote:
 Hi Archibald,

 if you want to clear all records from a table do:

   db.table.truncate()

 To clear all just loop thru db.tables .

 db.commit() to finish.

 It should work for all DBs.

 On Nov 14, 7:56 am, Archibald Linx archibaldl...@gmail.com wrote:







  Thank you Bruno.

  I am using SQLite.

  I want to reset all the tables of my project.

  Thanks,
  Archibald

  On 14 nov, 01:44, Bruno Rocha rochacbr...@gmail.com wrote:

   which database engine?

  http://zerp.ly/rochacbruno
   Em 13/11/2011 22:38, Archibald Linx archibaldl...@gmail.com escreveu:

Dear Web2py users,

How can I reset the database of my Web2py project ?

Thanks,
Archibald


[web2py] Re: How to change the position of submit button in a SQLFORM

2011-11-14 Thread Anthony
On Monday, November 14, 2011 9:34:30 AM UTC-5, Massimo Di Pierro wrote:

 You can add other buttons like 

 buttons = [INPUT(_type=submit), 
 INPUT(_type=button,_onclick=history.go(-1);return False)] 


Can you show a complete example? I just tried the above with SQLFORM and 
SQLFORM.factory, and it shows neither of the buttons listed above. I also 
can't find any code that references the 'buttons' argument, except for:

if (not readonly) and ('submit' in buttons):
widget = INPUT(_type='submit',
   _value=submit_button)
xfields.append(('submit_record'+SQLFORM.ID_ROW_SUFFIX,
'', widget,col3.get('submit_button', '')))
self.custom.submit = widget

Anthony


[web2py] Re: Removal of 'columns' in grid/smartgrid creates problems for search function

2011-11-14 Thread Massimo Di Pierro
On a second thought... all readable fields should be searchable even
if not displayed. I fixed this and columns is gone again.

On Nov 14, 8:16 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I put it back, give it a try.

 On Nov 14, 1:52 am, Johann Spies johann.sp...@gmail.com wrote:







  I have used the columns-argument to set the display columns and the
  'fields' argument to define the search fields for the search function.

  I only wanted to display 2 columns of a table but about 15 fields to be
  searchable eg.  '* parent_organisation contains america'.*
  Now if 'parent_organisation' is not spesified in 'fields' I get a 'invalid
  query' result.

  It worked well.  How can I have the same functionality with no
  columns-argument?

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


[web2py] Re: Removal of 'columns' in grid/smartgrid creates problems for search function

2011-11-14 Thread Anthony
What if you don't want all readable fields searchable -- can that be 
accomodated?

On Monday, November 14, 2011 10:53:28 AM UTC-5, Massimo Di Pierro wrote:

 On a second thought... all readable fields should be searchable even 
 if not displayed. I fixed this and columns is gone again. 

 On Nov 14, 8:16 am, Massimo Di Pierro massimo@gmail.com 
 wrote: 
  I put it back, give it a try. 
  
  On Nov 14, 1:52 am, Johann Spies johann...@gmail.com wrote: 
  
  
  
  
  
  
  
   I have used the columns-argument to set the display columns and the 
   'fields' argument to define the search fields for the search function. 
  
   I only wanted to display 2 columns of a table but about 15 fields to 
 be 
   searchable eg.  '* parent_organisation contains america'.* 
   Now if 'parent_organisation' is not spesified in 'fields' I get a 
 'invalid 
   query' result. 
  
   It worked well.  How can I have the same functionality with no 
   columns-argument? 
  
   Regards 
   Johann 
   -- 
   Because experiencing your loyal love is better than life itself, 
   my lips will praise you.  (Psalm 63:3)



[web2py] Prevent auto-conversion of %20

2011-11-14 Thread Sathvik Ponangi
Hi,

 I'm using Web2Py(stable) with GAE(py2.5, SDK1.5.5). The '%20' parts of the
url in request.args automatically change into underscores '_' .
How do I get them to stay that way, so that I may use them as spaces (with
urllib.decode)?

With Regards,
Sathvik
-- 
Sathvik Ponangi


[web2py] Re: stripe.com support

2011-11-14 Thread Matt Gorecki
What a coincidence, Massimo.  I was just going to start working on
Stripe integration today.

Matt

On Nov 13, 9:28 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I added

 gluon/contrib/stripe.py

 it provide a minimalist support for stripe.com payment processing

 1) get an account with stripe.com
 2) activate by giving them your bank account info
 3) get a key (looks like a t9uy97gg787yuUYuyf878fljhfuy67)
 4) in web2py:

     from gluon.contrib.stripe import Stripe
     key = 'your key'

 d=Stripe(key).charge(amount=100,card_number='...',card_exp_month='...',card 
 _exp_year='...',card_cvc_check='...',description='...')
     print 'charged',d['paid']
     s = Stripe(key).check(d[u'id'])
     print 'paid',s['paid'],s['amount'] ,s['currency']
     s = Stripe(key).refund(d[u'id'])
     print 'refunded',s['refunded']

 works out of the box. No fix costs. You can accept credit cards and
 they take a 3% cut.

 They provide their own Python API with more functionalities but I
 found I do not need more than the above ones (charge, check, refund).


[web2py] django and sqlalchemy on web2py

2011-11-14 Thread David Watson
Hi All,

I've been working with the code here:

http://code.google.com/p/django-and-sqlalchemy-on-web2py/

to port a legacy django model to web2py.

It works fine for simple single inheritance cases, and cases where the
ancestor depth is one. However, when I try to use a user-defined
django model that inherits from another user-defined django model, I
get errors at runtime.

I suspect there is additional metaclass munging needed in
DjangoModelFactory but I'm not sure what that looks like exactly.

When I add this class PersonChoice to django.py:

class Person(Model):
name=CharField('Full Name',max_length=64,null=True)
choices=ManyToManyField(Choice)

class PersonChoice(Person):
test = CharField('test', max_length=64, null=True)


I get:

Traceback (most recent call last):
  File django.py, line 213, in module
test_django_model()
  File django.py, line 33, in test_django_model
class PersonChoice(Person):
  File /usr/lib/python2.7/site-packages/gluon/dal.py, line 4592, in
__init__
db and db._adapter.sequence_name(tablename)
AttributeError: 'str' object has no attribute '_adapter'


And if I change the previous example to:

class PersonChoice(Model, Person):
test = CharField('test', max_length=64, null=True)

I get:

Traceback (most recent call last):
  File django.py, line 213, in module
test_django_model()
  File django.py, line 33, in test_django_model
class PersonChoice(Model, Person):
  File django.py, line 181, in __new__
obj = type.__new__(cls,name,bases,attrs)
TypeError: Error when calling the metaclass bases
metaclass conflict: the metaclass of a derived class must be a
(non-strict) subclass of the metaclasses of all its bases

Does anyone know if there's a way to get the DjangoModelFactory to
handle the additional layer of inheritance?

Thanks,
David


[web2py] web2py contributors

2011-11-14 Thread Massimo Di Pierro
Hello everybody,

I am preparing the new book and need to update the contributors page:

   http://web2py.com/examples/default/who.html

If your name is not there and it should be please do not be shy and email me 
privately with your full name and google account alias. This is more likely an 
oversight than intentional.

I remind you that if you have provided significant contributions (more than a 
few lines of code or help with testing), you should send me a signed copy of 
the contributor agreement, which you can find on the same page.

Massimo

Re: [web2py] SQLForm.grid - How do I use it properly?

2011-11-14 Thread Jim Steil

Ok, columns are gone again...

Might just be best to stick with using fields.

-Jim

On 11/14/2011 8:47 AM, Jim Steil wrote:
I stand corrected on the 'columns' comment.  Massimo added it back in 
this morning.


-Jim

On 11/14/2011 8:45 AM, Jim Steil wrote:

here are a few thoughts...

1.  Make sure you create this test in a new app.  If you're updating 
or adding functionality to an already existing app, then your layout 
and base.css need to be updated.
2.  If using jquery-ui, then you need to download jquery-ui and 
include it in your layout.html with a line like this:



{{response.files.append(URL('static','jquery-ui/js/jquery-ui-1.8.16.custom.min.js'))}}

{{response.files.append(URL('static','jquery-ui/css/sunny/jquery-ui-1.8.16.custom.css'))}}


3.  Don't use the 'columns' argument.  It is going away in the next 
release.  Instead, use 'fields'.  In your case, use the following:


fields = [db.projects_posts.title, db.projects_posts.project_details, 
db.projects_posts.estimated_worth]


4.  I typically do not specify the 'headers' arg.  Instead, set the 
'label' on your table definition.  That way you only have to do it 
once and can use it all over.  If you need to override it for a 
particular function, then just set the 'label' attribute in that 
function.


5.  At this time there is no documentation available for SQLFORM.grid 
or SQLFORM.smartgrid.  The best thing to do would be to look through 
this group for all the posts.  Massimo is working on an updated 
version of that manual that he is hoping to have complete by the end 
of this month.  That should contain information on .grid and .smartgrid.


6.  If you are going to be playing around with this I would recommend 
that you work with the code in trunk.  I don't recall what state the 
.grid was in when 1.99.2 was released.


As for answers for your specific questions:

Q: What is the exact proper method to use SQLForm.grid -
I think your on the right track.  Just need to clean up your css and 
layout.html files to get the proper formatting.


Q: What all libraries do I need to include? where?
If you want to use jquery-ui then you need to download it and 
reference it in your layout.html.


Q: How to make links work the way they should ?
I'd like some more information on what is going on here before giving 
an answer.


Q: Can search be customized? How?
I don't remember if the search_form is implemented in 1.99.2, but 
there is a search facility built in that allows the users to create a 
custom search.  I am not a fan of it and have some other ideas how 
developers could be allowed to create custom search forms, but I 
haven't opened a ticket on it yet.


Q: Is this documented in online book?  - did not find much about it in
version 3.2 though.

Documentation will be coming with the next version of the book 
targeted for the end of the month.


Hope this helps.

-Jim


On 11/14/2011 6:54 AM, Rahul wrote:

Hi All,
   Can anyone let me know how to use SQLForm.grid properly or tell
me what I am missing. I have not installed any jquery plugin for the
same (assuming that it is part of 1.99.2 by default). I cannot see the
complete grid, just some buttons and data as per my query below. Also
the links do not function when clicked. The table does not show any
backgroud color or anything. Simply it doesnt look like a jquery
grid.  My code is as below -

My machine - Windows7 , IE9 and Firefox 7.0, Chrome.
Web2py- Latest stable (1.99.1)

#-Controller- (default.py)---
def index():
 
 example action using the internationalization operator T and flash
 rendered by views/default/index.html or views/generic.html
 
 #Posts grid - SQLForm.grid
 #grid = SQLFORM.grid(db.projects_posts)
 query = ((db.projects_posts.post_visibility==Classified))
 columns = ('projects_posts.title',
'projects_posts.project_details',
'projects_posts.estimated_worth'
   )
 headers ={'projects_posts.title': 'Title',
   'projects_posts.project_details': 'Details',
   'projects_posts.estimated_worth': 'Worth'}

 form = SQLFORM.grid( query=query, columns=columns,
headers=headers,
  deletable=False, editable=False, csv=False,
maxtextlength=64 )


 return dict(form=form)

#- View ---  (index.html)
{{extend 'layout.html'}}
{{=form}}


Also, if possible please refer me to the proper documentation for
SQLForm.grid. Again, if I include the parameter  form =
SQLForm.grid(.,  ui=jquery-ui) in above code, the buttons
disappear and it only shows me links for 'view' etc.

Q: What is the exact proper method to use SQLForm.grid -
Q: What all libraries do I need to include? where?
Q: How to make links work the way they should ?
Q: Can search be customized? How?
Q: Is this documented in online book?  - did not find much about it in
version 3.2 though.

Please advice or refer me to the proper thread(though I checked

[web2py] IS_IN_DB _and arg

2011-11-14 Thread Jim Steil

Hi

Using SQLFORM.factory and trying to build a dropdown box based off a 
table but limiting the options in the dropdown.  Here is what I have:


plantsNotForUser = db(db.plant.plantNumber==2)

form = SQLFORM.factory(
Field('plantId', db.plant, label='Plant',
  requires=IS_IN_DB(db, 'plant.id', '%(plantNumber)s - 
%(name)s',

zero='...choose one...',
_and=IS_NOT_IN_DB(plantsNotForUser, 
'plant.id')),

  default=plantId))

However, when I display the form, plant number 2 is included in the 
list.  I don't want to show that one.


Am I misunderstanding what the _and arg does?

-Jim



Re: [web2py] IS_IN_DB _and arg

2011-11-14 Thread Richard Vézina
Why you can't specify in IS_IN_DB and pass a subset of you table and use
where clause to subset your DB like this :

db(db.plant.plantNumber!=2)

??

Look in the book how to pass a set instead of db to IS_IN_DB class...

Richard

On Mon, Nov 14, 2011 at 12:16 PM, Jim Steil j...@qlf.com wrote:

  Hi

 Using SQLFORM.factory and trying to build a dropdown box based off a table
 but limiting the options in the dropdown.  Here is what I have:

 plantsNotForUser = db(db.plant.plantNumber==2)

 form = SQLFORM.factory(
 Field('plantId', db.plant, label='Plant',
   requires=IS_IN_DB(db, 'plant.id', '%(plantNumber)s -
 %(name)s',
 zero='...choose one...',
 _and=IS_NOT_IN_DB(plantsNotForUser, '
 plant.id')),
   default=plantId))

 However, when I display the form, plant number 2 is included in the list.
 I don't want to show that one.

 Am I misunderstanding what the _and arg does?

 -Jim




Re: [web2py] IS_IN_DB _and arg

2011-11-14 Thread Jim Steil

Perfect, thanks for the tip Richard.

-Jim

On 11/14/2011 11:28 AM, Richard Vézina wrote:
Why you can't specify in IS_IN_DB and pass a subset of you table and 
use where clause to subset your DB like this :


db(db.plant.plantNumber!=2)

??

Look in the book how to pass a set instead of db to IS_IN_DB class...

Richard

On Mon, Nov 14, 2011 at 12:16 PM, Jim Steil j...@qlf.com 
mailto:j...@qlf.com wrote:


Hi

Using SQLFORM.factory and trying to build a dropdown box based off
a table but limiting the options in the dropdown.  Here is what I
have:

plantsNotForUser = db(db.plant.plantNumber==2)

form = SQLFORM.factory(
Field('plantId', db.plant, label='Plant',
  requires=IS_IN_DB(db, 'plant.id http://plant.id',
'%(plantNumber)s - %(name)s',
zero='...choose one...',
   
_and=IS_NOT_IN_DB(plantsNotForUser, 'plant.id http://plant.id')),

  default=plantId))

However, when I display the form, plant number 2 is included in
the list.  I don't want to show that one.

Am I misunderstanding what the _and arg does?

-Jim




[web2py] Re: SQLFORM.grid sorting dates

2011-11-14 Thread peter
Any thoughts on the suggestion about dates sorting in reverse order in
SQLFORM.grid. The link in the previous message does not work, but the
web address is correct.

Peter



On Oct 27, 4:15 pm, peter peterchutchin...@gmail.com wrote:
 If one clicks on 'data modified' in a windows folder, the files are
 ordered with the most recent first.

 InSQLFORM.gridif one has a column with a date in it, and one clicks
 on the heading, they are sorted with the oldest first.

 Seewww.ukjazz.net/store/albums

 It would be nice ifSQLFORM.gridacted the same as windows folders
 here. Firstly for consistency, and secondly because usually one wants
 to order things by the most recent first.

 I realise that a second click on the heading does sort in this way

 Peter


Re: [web2py] IS_IN_DB _and arg

2011-11-14 Thread Richard Vézina
You are welcome.

Richard

On Mon, Nov 14, 2011 at 12:48 PM, Jim Steil j...@qlf.com wrote:

  Perfect, thanks for the tip Richard.

 -Jim


 On 11/14/2011 11:28 AM, Richard Vézina wrote:

 Why you can't specify in IS_IN_DB and pass a subset of you table and use
 where clause to subset your DB like this :

  db(db.plant.plantNumber!=2)

  ??

  Look in the book how to pass a set instead of db to IS_IN_DB class...

  Richard

 On Mon, Nov 14, 2011 at 12:16 PM, Jim Steil j...@qlf.com wrote:

  Hi

 Using SQLFORM.factory and trying to build a dropdown box based off a
 table but limiting the options in the dropdown.  Here is what I have:

 plantsNotForUser = db(db.plant.plantNumber==2)

 form = SQLFORM.factory(
 Field('plantId', db.plant, label='Plant',
   requires=IS_IN_DB(db, 'plant.id', '%(plantNumber)s -
 %(name)s',
 zero='...choose one...',
 _and=IS_NOT_IN_DB(plantsNotForUser, '
 plant.id')),
   default=plantId))

 However, when I display the form, plant number 2 is included in the
 list.  I don't want to show that one.

 Am I misunderstanding what the _and arg does?

 -Jim





Re: [web2py] Re: Resetting the database

2011-11-14 Thread Bruno Rocha
using sqlite. just go to /databases folder and delete everything there.

web2py will create it all again.

http://zerp.ly/rochacbruno
Em 14/11/2011 10:56, Archibald Linx archibaldl...@gmail.com escreveu:

 Thank you Bruno.

 I am using SQLite.

 I want to reset all the tables of my project.

 Thanks,
 Archibald

 On 14 nov, 01:44, Bruno Rocha rochacbr...@gmail.com wrote:
  which database engine?
 
  http://zerp.ly/rochacbruno
  Em 13/11/2011 22:38, Archibald Linx archibaldl...@gmail.com
 escreveu:
 
 
 
 
 
 
 
   Dear Web2py users,
 
   How can I reset the database of my Web2py project ?
 
   Thanks,
   Archibald


[web2py] Re: How to change the position of submit button in a SQLFORM

2011-11-14 Thread Dominique
Hi,

Thanks DenesL, Anthony and Massimo for your help.
I appreciate.
That works fine !
Thanks a lot

Dominique


Re: [web2py] Re: Detecting if a session has ended

2011-11-14 Thread Richard Vézina
Hello Sathvik,

Do you use the RBAC web2py feature?

How you last_in get update as user logon?


Ok, just re-read your email you don't use the auth...

I think personnalise the auth_user table (or any other name you give it)
and append a boolean loged_on (TRUE/FALSE) field could do it in
conjunction with :

auth.settings.login_onaccept = lambda form: user_logged_on_update('True')


auth.settings.logout_onlogout - lambda user: user_logged_on_update('False')

Since we can't assign in lambda using a sub-function that update the
auth_user.logged_on=True or auth_user.logged_on=False will do it.

Note : It's just pseudo code... I can report here when I get a working
implementation...

:)

Richard


On Fri, Nov 11, 2011 at 1:06 AM, Sathvik Ponangi psath...@gmail.com wrote:

 I'm using a Users table  sessions to handle users.

 db.define_table('users',
 db.Field('name', 'string'),
 db.Field('password', 'password'),#If local user
 db.Field('active', 'boolean', default=False),
 db.Field('uid', 'string'),
 db.Field('slinked', 'string', default=),#Redirect
 to a linked account
 db.Field('last_in', 'datetime', default=request.now),
 db.Field('date', 'datetime', default=request.now,
 writable=False)
 )


 Is it a good idea to switch-over to auth? If so, how do I do it?


 On Thu, Nov 10, 2011 at 3:44 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Thank you!

 Richard


 On Wed, Nov 9, 2011 at 4:23 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 They are usually called

 auth.settings.login_onaccept = lambda form: ..
 auth.settings.profile_onaccept = lambda form: ..
 auth.settings.method_onaccept = lambda form: ..

 and they all take the form.

 the name exception is

 auth.settings.logout_onlogout - lambda user: ...

 because there is no form to fill on logout but there is a user.

 On Nov 9, 1:37 pm, Richard Vézina ml.richard.vez...@gmail.com wrote:
  Nice approach so I could update a custom field in auth_user and put it
 true
  or false at login and logout?
 
  How I may set my flag to true?
 
  Is there a auth.settings.login_onlogin ??
 
  Thanks
 
  Richard
 
  On Wed, Nov 9, 2011 at 2:14 PM, Massimo Di Pierro 
 
 
 
 
 
 
 
  massimo.dipie...@gmail.com wrote:
   Sessions never end. Do you want to detect logout?
 
   auth.settings.logout_onlogout = lambda user: do_something_with(user)
 
   On Nov 9, 11:58 am, Sathvik Ponangi psath...@gmail.com wrote:
Is there someway that I could call a function when the user ends
 their
session?





 --
 Sathvik Ponangi



[web2py] Re: SQLForm.grid - How do I use it properly?

2011-11-14 Thread Cliff
As for 1.99.2, grid is stable.

Using fields = [db.table.field, db.table.otherfield] does not work on
the index table.  I am using columns and planning to update my
controllers when the next release becomes available.

On Nov 14, 12:13 pm, Jim Steil j...@qlf.com wrote:
 Ok, columns are gone again...

 Might just be best to stick with using fields.

      -Jim

 On 11/14/2011 8:47 AM, Jim Steil wrote:







  I stand corrected on the 'columns' comment.  Massimo added it back in
  this morning.

      -Jim

  On 11/14/2011 8:45 AM, Jim Steil wrote:
  here are a few thoughts...

  1.  Make sure you create this test in a new app.  If you're updating
  or adding functionality to an already existing app, then your layout
  and base.css need to be updated.
  2.  If using jquery-ui, then you need to download jquery-ui and
  include it in your layout.html with a line like this:

  {{response.files.append(URL('static','jquery-ui/js/jquery-ui-1.8.16.custom.
   min.js'))}}

  {{response.files.append(URL('static','jquery-ui/css/sunny/jquery-ui-1.8.16.
   custom.css'))}}

  3.  Don't use the 'columns' argument.  It is going away in the next
  release.  Instead, use 'fields'.  In your case, use the following:

  fields = [db.projects_posts.title, db.projects_posts.project_details,
  db.projects_posts.estimated_worth]

  4.  I typically do not specify the 'headers' arg.  Instead, set the
  'label' on your table definition.  That way you only have to do it
  once and can use it all over.  If you need to override it for a
  particular function, then just set the 'label' attribute in that
  function.

  5.  At this time there is no documentation available for SQLFORM.grid
  or SQLFORM.smartgrid.  The best thing to do would be to look through
  this group for all the posts.  Massimo is working on an updated
  version of that manual that he is hoping to have complete by the end
  of this month.  That should contain information on .grid and .smartgrid.

  6.  If you are going to be playing around with this I would recommend
  that you work with the code in trunk.  I don't recall what state the
  .grid was in when 1.99.2 was released.

  As for answers for your specific questions:

  Q: What is the exact proper method to use SQLForm.grid -
  I think your on the right track.  Just need to clean up your css and
  layout.html files to get the proper formatting.

  Q: What all libraries do I need to include? where?
  If you want to use jquery-ui then you need to download it and
  reference it in your layout.html.

  Q: How to make links work the way they should ?
  I'd like some more information on what is going on here before giving
  an answer.

  Q: Can search be customized? How?
  I don't remember if the search_form is implemented in 1.99.2, but
  there is a search facility built in that allows the users to create a
  custom search.  I am not a fan of it and have some other ideas how
  developers could be allowed to create custom search forms, but I
  haven't opened a ticket on it yet.

  Q: Is this documented in online book?  - did not find much about it in
  version 3.2 though.

  Documentation will be coming with the next version of the book
  targeted for the end of the month.

  Hope this helps.

      -Jim

  On 11/14/2011 6:54 AM, Rahul wrote:
  Hi All,
         Can anyone let me know how to use SQLForm.grid properly or tell
  me what I am missing. I have not installed any jquery plugin for the
  same (assuming that it is part of 1.99.2 by default). I cannot see the
  complete grid, just some buttons and data as per my query below. Also
  the links do not function when clicked. The table does not show any
  backgroud color or anything. Simply it doesnt look like a jquery
  grid.  My code is as below -

  My machine - Windows7 , IE9 and Firefox 7.0, Chrome.
  Web2py- Latest stable (1.99.1)

  #-Controller- (default.py)---
  def index():
       
       example action using the internationalization operator T and flash
       rendered by views/default/index.html or views/generic.html
       
       #Posts grid - SQLForm.grid
       #grid = SQLFORM.grid(db.projects_posts)
       query = ((db.projects_posts.post_visibility==Classified))
       columns = ('projects_posts.title',
                  'projects_posts.project_details',
                  'projects_posts.estimated_worth'
                 )
       headers ={'projects_posts.title': 'Title',
                 'projects_posts.project_details': 'Details',
                 'projects_posts.estimated_worth': 'Worth'}

       form = SQLFORM.grid( query=query, columns=columns,
  headers=headers,
                            deletable=False, editable=False, csv=False,
  maxtextlength=64 )

       return dict(form=form)

  #- View ---  (index.html)
  {{extend 'layout.html'}}
  {{=form}}

  Also, if possible please refer me to the proper documentation for
  SQLForm.grid. Again, if I include the parameter  form =
  SQLForm.grid(.,  ui=jquery-ui) in above code, 

[web2py] book typo or bizzard explanation...

2011-11-14 Thread Richard
Hello,

In the book section :

http://web2py.com/book/default/chapter/06?search=update#update_record

We talk about single record...

But command 1 is not selecting a single record so if there is other id
then 3 (4, 5, 6, etc.) there will be a error in what we expect to
update...

Book extract :
update_record
update_record web2py also allows updating a single record that is
already in memory using update_record
1.
2.
 row = db(db.person.id  2).select().first()
 row.update_record(name='Curt')

Should be :
 row = db(db.person.id == 2).select().first()

Maybe it's not going to do bad thing because of .first(), but I think
it clearer with ==

Richard


[web2py] workaround for SQLFORM and list:string bug (undocumented feature?)

2011-11-14 Thread Cliff
The SQLFORM options widget ignores the value in the database when
editing the field.  The following code shows the failure:

Model:
db.define_table('product_types', Field('name', length=32,
label='Type'))

product_type_list = [r.name for r in
db().select(db.product_types.name)]
db.define_table(
'products',
Field('name', length=256, required=True, notnull=True),
Field('product_type', 'list:string'),
format = '%(name)s',
)

db.products.product_type.requires = IS_IN_SET(product_type_list,
zero='Choice required')

Controller:
grid = SQLFORM.grid(...)
return dict(grid=grid)

To work around add something like this before the call to grid:
  if len(request.args)2 and request.args[-3] == 'edit':

product_type_value =
db.products[request.args[-1]].product_type

rows = db((db.product_types.is_active==True) 
 
(db.product_types.tenant_link==session.auth.user.tenant_link)
 ).select(db.product_types.name)

product_type_list = [r.name for r in rows]

db.products.product_type.widget = lambda field,value: \
SELECT(product_type_list, value=product_type_value)



Re: [web2py] Re: Resetting the database

2011-11-14 Thread Vinicius Assef
SQLite? Just delete your database file.

Web2py will recreate it next time you execute your app.

If it doesn't help, try something like that in web2py shell:
http://pastebin.com/w0q4yKkK

--
Vinicius Assef.



On Mon, Nov 14, 2011 at 10:56 AM, Archibald Linx
archibaldl...@gmail.com wrote:
 Thank you Bruno.

 I am using SQLite.

 I want to reset all the tables of my project.

 Thanks,
 Archibald

 On 14 nov, 01:44, Bruno Rocha rochacbr...@gmail.com wrote:
 which database engine?

 http://zerp.ly/rochacbruno
 Em 13/11/2011 22:38, Archibald Linx archibaldl...@gmail.com escreveu:







  Dear Web2py users,

  How can I reset the database of my Web2py project ?

  Thanks,
  Archibald


[web2py] Using the same form in multiple pages

2011-11-14 Thread Chris
Hello,

I'd like to make a login form and have it be accessible in multiple
pages, without having to rewrite the same code in every single
controller action:

login_form = auth.login()
if login_form.accepts(...

Is this possible?

Thanks,
Chris


[web2py] Re: Using the same form in multiple pages

2011-11-14 Thread Cliff
If you want to force user login on the page, use the
@auth.requires_login decorator on the corresponding functions.

If you use SQLFORM.grid, you may need to do that only one time per
controller.

You can find out all about it in Chapter 8 of the book.

http://www.web2py.com/book/default/chapter/08#Decorators

A link to the login page is already there.

On Nov 14, 3:58 pm, Chris zuzfrexkg...@spammotel.com wrote:
 Hello,

 I'd like to make a login form and have it be accessible in multiple
 pages, without having to rewrite the same code in every single
 controller action:

 login_form = auth.login()
 if login_form.accepts(...

 Is this possible?

 Thanks,
 Chris


Re: [web2py] Re: Detecting if a session has ended

2011-11-14 Thread Richard Vézina
Here it is :

Redefine auth table like this :
auth_table = db.define_table(
auth.settings.table_user_name,


Append to default auth user field this field :

Field('logged_on','boolean', writable=False, readable=False,
default=None),


Then I put those lines into db.py that contain my auth redefined table
that's it (other models files contain the rest of my tables models)

auth.settings.login_onaccept = lambda form: user_logged_on_update('True',
auth.user and auth.user.id)
auth.settings.logout_onlogout = lambda user: user_logged_on_update('False',
user.id)

def user_logged_on_update(flag, user_id):

Update of logged_on auth_user field. True = logged on.

if user_id != None and flag != None:
db.auth_user[user_id] = dict(logged_on = flag)
return

I know that function don't go into model so it properly best fitting into
module... But to allow lambda functions to call it I will have to import
them so... Don't know what best pratice...

Also I get user id at login accept by calling : auth.user and auth.user.id

But is the form containing user id?

What do you think about that?

Richard


On Mon, Nov 14, 2011 at 2:37 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 Hello Sathvik,

 Do you use the RBAC web2py feature?

 How you last_in get update as user logon?


 Ok, just re-read your email you don't use the auth...

 I think personnalise the auth_user table (or any other name you give it)
 and append a boolean loged_on (TRUE/FALSE) field could do it in
 conjunction with :

 auth.settings.login_onaccept = lambda form: user_logged_on_update('True')


 auth.settings.logout_onlogout - lambda user:
 user_logged_on_update('False')

 Since we can't assign in lambda using a sub-function that update the
 auth_user.logged_on=True or auth_user.logged_on=False will do it.

 Note : It's just pseudo code... I can report here when I get a working
 implementation...

 :)

 Richard


 On Fri, Nov 11, 2011 at 1:06 AM, Sathvik Ponangi psath...@gmail.comwrote:

 I'm using a Users table  sessions to handle users.

 db.define_table('users',
 db.Field('name', 'string'),
 db.Field('password', 'password'),#If local user
 db.Field('active', 'boolean', default=False),
 db.Field('uid', 'string'),
 db.Field('slinked', 'string', default=),#Redirect
 to a linked account
 db.Field('last_in', 'datetime', default=request.now),
 db.Field('date', 'datetime', default=request.now,
 writable=False)
 )


 Is it a good idea to switch-over to auth? If so, how do I do it?


 On Thu, Nov 10, 2011 at 3:44 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Thank you!

 Richard


 On Wed, Nov 9, 2011 at 4:23 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 They are usually called

 auth.settings.login_onaccept = lambda form: ..
 auth.settings.profile_onaccept = lambda form: ..
 auth.settings.method_onaccept = lambda form: ..

 and they all take the form.

 the name exception is

 auth.settings.logout_onlogout - lambda user: ...

 because there is no form to fill on logout but there is a user.

 On Nov 9, 1:37 pm, Richard Vézina ml.richard.vez...@gmail.com wrote:
  Nice approach so I could update a custom field in auth_user and put
 it true
  or false at login and logout?
 
  How I may set my flag to true?
 
  Is there a auth.settings.login_onlogin ??
 
  Thanks
 
  Richard
 
  On Wed, Nov 9, 2011 at 2:14 PM, Massimo Di Pierro 
 
 
 
 
 
 
 
  massimo.dipie...@gmail.com wrote:
   Sessions never end. Do you want to detect logout?
 
   auth.settings.logout_onlogout = lambda user: do_something_with(user)
 
   On Nov 9, 11:58 am, Sathvik Ponangi psath...@gmail.com wrote:
Is there someway that I could call a function when the user ends
 their
session?





 --
 Sathvik Ponangi





[web2py] Re: Using the same form in multiple pages

2011-11-14 Thread Anthony
auth.login() handles its own processing, so you don't need to do 
login_form.accepts(). So, just use auth.login() wherever you need it.

Anthony

On Monday, November 14, 2011 3:58:52 PM UTC-5, Chris wrote:

 Hello, 

 I'd like to make a login form and have it be accessible in multiple 
 pages, without having to rewrite the same code in every single 
 controller action: 

 login_form = auth.login() 
 if login_form.accepts(... 

 Is this possible? 

 Thanks, 
 Chris



[web2py] Re: Using the same form in multiple pages

2011-11-14 Thread Chris
Cool, thanks guys.

I do have decorators on certain login-only pages, but I want a page
that's visible to both members and guests. The idea is to have a login
form that shows up only under certain circumstances.

I've done some further tests, and I think auth.login() is working in-
template, but it doesn't seem to work if there's already a login form
on the page. Can I only call auth.login() once?


Here's how I'm attempting to do login now:

{{if user_id:}}
spanWelcome {{=user_current().first_name }}!/span
form
input type=button id=logoutBtn value=Log Out
onclick=window.location.href =
'{{=URL('default','user',args=['logout'])}}'; /
/form
{{else:}}
{{top_login_form = auth.login()}}
{{=top_login_form.custom.begin}}
{{=top_login_form.custom.widget.email}}
{{=top_login_form.custom.widget.password}}
{{top_login_form.custom.widget.login}}
input type=image src=/init/static/images/buttons/
login.png id=loginBtn value=Log In /
!--input type=text placeholder=email name=email
input type=password placeholder=password
name=password
input type=image src=/init/static/images/buttons/
login.png id=loginBtn value=Log In--
{{=top_login_form.custom.end}}
{{pass}}


On Nov 14, 4:07 pm, Anthony abasta...@gmail.com wrote:
 auth.login() handles its own processing, so you don't need to do
 login_form.accepts(). So, just use auth.login() wherever you need it.

 Anthony







 On Monday, November 14, 2011 3:58:52 PM UTC-5, Chris wrote:

  Hello,

  I'd like to make a login form and have it be accessible in multiple
  pages, without having to rewrite the same code in every single
  controller action:

  login_form = auth.login()
  if login_form.accepts(...

  Is this possible?

  Thanks,
  Chris


[web2py] Re: Using the same form in multiple pages

2011-11-14 Thread Chris
After doing some more digging, it appears that each time you call
auth.login(), you generate a new formkey. The first formkey must get
overloaded, so the XSRF protection prevents either form from
submitting.

Any way I can get around this? Sample code:

{{top_login_form = auth.login()}}
{{=top_login_form.custom.begin}}
{{=top_login_form.custom.widget.email}}
{{=top_login_form.custom.widget.password}}
input type=image src=/init/static/images/buttons/
login.png id=loginBtn value=Log In /
{{=top_login_form.custom.end}}
h
{{top_login_form2 = auth.login()}}
{{=top_login_form2.custom.begin}}
{{=top_login_form2.custom.widget.email}}
{{=top_login_form2.custom.widget.password}}
input type=image src=/init/static/images/buttons/
login.png id=loginBtn value=Log In /
{{=top_login_form2.custom.end}}

On Nov 14, 4:24 pm, Chris zuzfrexkg...@spammotel.com wrote:
 Cool, thanks guys.

 I do have decorators on certain login-only pages, but I want a page
 that's visible to both members and guests. The idea is to have a login
 form that shows up only under certain circumstances.

 I've done some further tests, and I think auth.login() is working in-
 template, but it doesn't seem to work if there's already a login form
 on the page. Can I only call auth.login() once?

 Here's how I'm attempting to do login now:

         {{if user_id:}}
             spanWelcome {{=user_current().first_name }}!/span
             form
                 input type=button id=logoutBtn value=Log Out
                     onclick=window.location.href =
 '{{=URL('default','user',args=['logout'])}}'; /
             /form
         {{else:}}
             {{top_login_form = auth.login()}}
             {{=top_login_form.custom.begin}}
             {{=top_login_form.custom.widget.email}}
             {{=top_login_form.custom.widget.password}}
             {{top_login_form.custom.widget.login}}
             input type=image src=/init/static/images/buttons/
 login.png id=loginBtn value=Log In /
             !--input type=text placeholder=email name=email
             input type=password placeholder=password
 name=password
             input type=image src=/init/static/images/buttons/
 login.png id=loginBtn value=Log In--
             {{=top_login_form.custom.end}}
         {{pass}}

 On Nov 14, 4:07 pm, Anthony abasta...@gmail.com wrote:







  auth.login() handles its own processing, so you don't need to do
  login_form.accepts(). So, just use auth.login() wherever you need it.

  Anthony

  On Monday, November 14, 2011 3:58:52 PM UTC-5, Chris wrote:

   Hello,

   I'd like to make a login form and have it be accessible in multiple
   pages, without having to rewrite the same code in every single
   controller action:

   login_form = auth.login()
   if login_form.accepts(...

   Is this possible?

   Thanks,
   Chris


[web2py] Re: SQLForm.grid - How do I use it properly?

2011-11-14 Thread JaapP
One more reason to stick to using fields could be that with fields you
can specify the order in which the columns are shown, this didn't work
for 'columns'

On 14 nov, 18:13, Jim Steil j...@qlf.com wrote:
 Ok, columns are gone again...

 Might just be best to stick with using fields.

      -Jim

 On 11/14/2011 8:47 AM, Jim Steil wrote:

  I stand corrected on the 'columns' comment.  Massimo added it back in
  this morning.

      -Jim

  On 11/14/2011 8:45 AM, Jim Steil wrote:
  here are a few thoughts...

  1.  Make sure you create this test in a new app.  If you're updating
  or adding functionality to an already existing app, then your layout
  and base.css need to be updated.
  2.  If using jquery-ui, then you need to download jquery-ui and
  include it in your layout.html with a line like this:

  {{response.files.append(URL('static','jquery-ui/js/jquery-ui-1.8.16.custom.min.js'))}}

  {{response.files.append(URL('static','jquery-ui/css/sunny/jquery-ui-1.8.16.custom.css'))}}

  3.  Don't use the 'columns' argument.  It is going away in the next
  release.  Instead, use 'fields'.  In your case, use the following:

  fields = [db.projects_posts.title, db.projects_posts.project_details,
  db.projects_posts.estimated_worth]

  4.  I typically do not specify the 'headers' arg.  Instead, set the
  'label' on your table definition.  That way you only have to do it
  once and can use it all over.  If you need to override it for a
  particular function, then just set the 'label' attribute in that
  function.

  5.  At this time there is no documentation available for SQLFORM.grid
  or SQLFORM.smartgrid.  The best thing to do would be to look through
  this group for all the posts.  Massimo is working on an updated
  version of that manual that he is hoping to have complete by the end
  of this month.  That should contain information on .grid and .smartgrid.

  6.  If you are going to be playing around with this I would recommend
  that you work with the code in trunk.  I don't recall what state the
  .grid was in when 1.99.2 was released.

  As for answers for your specific questions:

  Q: What is the exact proper method to use SQLForm.grid -
  I think your on the right track.  Just need to clean up your css and
  layout.html files to get the proper formatting.

  Q: What all libraries do I need to include? where?
  If you want to use jquery-ui then you need to download it and
  reference it in your layout.html.

  Q: How to make links work the way they should ?
  I'd like some more information on what is going on here before giving
  an answer.

  Q: Can search be customized? How?
  I don't remember if the search_form is implemented in 1.99.2, but
  there is a search facility built in that allows the users to create a
  custom search.  I am not a fan of it and have some other ideas how
  developers could be allowed to create custom search forms, but I
  haven't opened a ticket on it yet.

  Q: Is this documented in online book?  - did not find much about it in
  version 3.2 though.

  Documentation will be coming with the next version of the book
  targeted for the end of the month.

  Hope this helps.

      -Jim

  On 11/14/2011 6:54 AM, Rahul wrote:
  Hi All,
         Can anyone let me know how to use SQLForm.grid properly or tell
  me what I am missing. I have not installed any jquery plugin for the
  same (assuming that it is part of 1.99.2 by default). I cannot see the
  complete grid, just some buttons and data as per my query below. Also
  the links do not function when clicked. The table does not show any
  backgroud color or anything. Simply it doesnt look like a jquery
  grid.  My code is as below -

  My machine - Windows7 , IE9 and Firefox 7.0, Chrome.
  Web2py- Latest stable (1.99.1)

  #-Controller- (default.py)---
  def index():
       
       example action using the internationalization operator T and flash
       rendered by views/default/index.html or views/generic.html
       
       #Posts grid - SQLForm.grid
       #grid = SQLFORM.grid(db.projects_posts)
       query = ((db.projects_posts.post_visibility==Classified))
       columns = ('projects_posts.title',
                  'projects_posts.project_details',
                  'projects_posts.estimated_worth'
                 )
       headers ={'projects_posts.title': 'Title',
                 'projects_posts.project_details': 'Details',
                 'projects_posts.estimated_worth': 'Worth'}

       form = SQLFORM.grid( query=query, columns=columns,
  headers=headers,
                            deletable=False, editable=False, csv=False,
  maxtextlength=64 )

       return dict(form=form)

  #- View ---  (index.html)
  {{extend 'layout.html'}}
  {{=form}}

  Also, if possible please refer me to the proper documentation for
  SQLForm.grid. Again, if I include the parameter  form =
  SQLForm.grid(.,  ui=jquery-ui) in above code, the buttons
  disappear and it only shows me links for 'view' etc.

  Q: What is 

[web2py] Re: Using the same form in multiple pages

2011-11-14 Thread Anthony
On Monday, November 14, 2011 4:24:12 PM UTC-5, Chris wrote:

 {{if user_id:}} 


Note, auth.user_id returns the id of the current logged in user or None 
otherwise, so you can use:

{{if auth.user_id}}
 

 spanWelcome {{=user_current().first_name }}!/span 


Also, auth.user returns the full user record of the current logged in user, 
or None otherwise, so you can do:

{{=auth.user.first_name}}

Anthony 


[web2py] Re: Using the same form in multiple pages

2011-11-14 Thread Anthony
Why do you need two distinct login forms in the same page? Can it be just 
one login form (i.e., one call to auth.login()) that you display twice? For 
example:

def myaction():
[do stuff]
return dict(..., login_form=auth.login())

View:

{{=login_form # show it here}}
...
{{=login_form # show it somewhere else}}

Anthony

On Monday, November 14, 2011 4:29:24 PM UTC-5, Chris wrote:

 After doing some more digging, it appears that each time you call 
 auth.login(), you generate a new formkey. The first formkey must get 
 overloaded, so the XSRF protection prevents either form from 
 submitting. 

 Any way I can get around this? Sample code: 

 {{top_login_form = auth.login()}} 
 {{=top_login_form.custom.begin}} 
 {{=top_login_form.custom.widget.email}} 
 {{=top_login_form.custom.widget.password}} 
 input type=image src=/init/static/images/buttons/ 
 login.png id=loginBtn value=Log In / 
 {{=top_login_form.custom.end}} 
 h 
 {{top_login_form2 = auth.login()}} 
 {{=top_login_form2.custom.begin}} 
 {{=top_login_form2.custom.widget.email}} 
 {{=top_login_form2.custom.widget.password}} 
 input type=image src=/init/static/images/buttons/ 
 login.png id=loginBtn value=Log In / 
 {{=top_login_form2.custom.end}} 

 On Nov 14, 4:24 pm, Chris zuzfre...@spammotel.com wrote: 
  Cool, thanks guys. 
  
  I do have decorators on certain login-only pages, but I want a page 
  that's visible to both members and guests. The idea is to have a login 
  form that shows up only under certain circumstances. 
  
  I've done some further tests, and I think auth.login() is working in- 
  template, but it doesn't seem to work if there's already a login form 
  on the page. Can I only call auth.login() once? 
  
  Here's how I'm attempting to do login now: 
  
  {{if user_id:}} 
  spanWelcome {{=user_current().first_name }}!/span 
  form 
  input type=button id=logoutBtn value=Log Out 
  onclick=window.location.href = 
  '{{=URL('default','user',args=['logout'])}}'; / 
  /form 
  {{else:}} 
  {{top_login_form = auth.login()}} 
  {{=top_login_form.custom.begin}} 
  {{=top_login_form.custom.widget.email}} 
  {{=top_login_form.custom.widget.password}} 
  {{top_login_form.custom.widget.login}} 
  input type=image src=/init/static/images/buttons/ 
  login.png id=loginBtn value=Log In / 
  !--input type=text placeholder=email name=email 
  input type=password placeholder=password 
  name=password 
  input type=image src=/init/static/images/buttons/ 
  login.png id=loginBtn value=Log In-- 
  {{=top_login_form.custom.end}} 
  {{pass}} 
  
  On Nov 14, 4:07 pm, Anthony abas...@gmail.com wrote: 
  
  
  
  
  
  
  
   auth.login() handles its own processing, so you don't need to do 
   login_form.accepts(). So, just use auth.login() wherever you need it. 
  
   Anthony 
  
   On Monday, November 14, 2011 3:58:52 PM UTC-5, Chris wrote: 
  
Hello, 
  
I'd like to make a login form and have it be accessible in multiple 
pages, without having to rewrite the same code in every single 
controller action: 
  
login_form = auth.login() 
if login_form.accepts(... 
  
Is this possible? 
  
Thanks, 
Chris



[web2py] Re: Oreilly python-Certification

2011-11-14 Thread mikech
Thanks, very useful.

Re: [web2py] Re: web2py dal not creating database

2011-11-14 Thread Jimmy Stewpot
Hi Bruno,

Thanks so much, deleting the files in the database folder fixed this problem. 
Is it normal that those files would have been copied over between systems or 
was it a botch somewhere?

- Original Message -
From: Bruno Rocha rochacbr...@gmail.com
To: web2py@googlegroups.com
Sent: Monday, 14 November, 2011 10:41:53 AM
Subject: Re: [web2py] Re: web2py dal not creating database



as you are using mysql. try to delete everything you has in /databases folder 
(the .table files) backup it. 

then try again with table definitions and migrate=True 

http://zerp.ly/rochacbruno 
Em 13/11/2011 21:33, Jimmy Stewpot  mail...@oranged.to  escreveu: 


Hi, 

I have nothing set in my model at all for migrate so I assume that it's True by 
being ommited. 

It has got me stumped.. I have not had problems like this in the past with my 
previous testing. 


- Original Message - 
From: Bruno Rocha  rochacbr...@gmail.com  
To: web2py@googlegroups.com 
Sent: Sunday, 13 November, 2011 5:53:52 PM 
Subject: Re: [web2py] Re: web2py dal not creating database 

what is in your: define_table(..., migrate=? ) and db = DAL(, 
migrate_enabled=? ) 


It needs to be setted to True or ommited to create the tables. 


On Sun, Nov 13, 2011 at 4:14 AM, Jimmy Stewpot  mail...@oranged.to  wrote: 


Hi, 

Thanks for the quick response.. 

I have the DB created in mysql. The user has rights (using the root user).. 
still no luck. 

I've turned on query logging in mysql, the app queries are all working as 
expected but it won't create the model. 

Regards, 

Jimmy 








- Original Message - 
From: Anthony  abasta...@gmail.com  
To: web2py@googlegroups.com 
Sent: Sunday, 13 November, 2011 3:54:58 PM 
Subject: [web2py] Re: web2py dal not creating database 

web2py will only create the db for you if you're using SQLite -- otherwise you 
have to create the db (once the db is created, though, web2py will create 
tables for you). See 
http://web2py.com/book/default/chapter/06#Connection-Strings . 


Anthony 

On Saturday, November 12, 2011 11:10:18 PM UTC-5, Jimmy Stewpot wrote: 

Hello, 

I have been playing around with web2py for about a month.. I have 
finally got to the point where I wanted to test the packing of my app 
to test the install on another system. However when I load the app 
into web2py on the new system the database is never created. I've even 
gone so far as to use the root mysql database user to see where any 
possible issues could arise.. I can't see any errors except a ticket 
which says.. 

ProgrammingError: (1146, uTable 'app03.auth_user' doesn't exist) 

I loaded the app via the administrative interface over the loopback.. 
The sqllog has nothing interesting it.. I've restarted mysql, apache, 
the management interface with no success. 

Any advice would be greatly appreciated. 

Regards, 

Jimmy. 




-- 






Bruno Rocha 
[ http://rochacbruno.com.br ] 


[web2py] Problem with 'unique' in DAL and validators

2011-11-14 Thread mdorval
Hi,
So regarding web2py validators:
When I define my model using the unique=True constraint on a field, it
adds an IS_NOT_IN_DB validator to that field. But if I try to do a
validate_and_update on that field, it throws an error in the following
examples:

Case 1: Passing in the whole record

Say I have a row:
name: production (unique)
tag: large

And I want to make a change to tag to say small
If I try to pass in validate_and_update(tag='small',name='production')
I get an error saying production is already in the database.

Case 2: Changing case

Say I have a row:
name: production (unique)
tag: large

And I want to change the name to start with an uppercase letter.

If I try to pass in validate_and_update(name='Production') I get an
error saying Production is already in the database (as it appears to
be case-insenstive) but if I update without the validator it works.

So any ideas on how to properly validate my updates for both cases?


[web2py] autocomplete widget

2011-11-14 Thread Jim Steil

Hi

Are many people using the autocomplete widget out there?

I'm having some inconvenient behavior with it.  First off, I think it 
would be great if it would do a .contains instead of a .like when it 
filters the data being returned.  Second, when using the control I'm 
seeing the following:


1.  Type in a couple characters and a dropdown list appears
2.  I would like to use the arrow key to navigate up and down through 
the list.  This doesn't work.  I have to tab to the list before arrow 
keys work.
3.  I would like to select my desired option using the space bar, enter 
key or single-clicking with the mouse.  None of these work.
4.  There seems to be a select delay or timeout where whatever list item 
is currently highlighted is selected and the list goes away without me 
doing anything.  I'm still thinking about which one I want to select and 
the list disappears and the currently highlighted selection is chosen 
(regardless of whether or not I'm actively scrolling through the list).  
I'd prefer to have to do something to make it select something.


Is it possible I'm using some old CSS or web2py_ajax.html file?  I don't 
recall what version I was on when my app was initially created.


-Jim


[web2py] Can't use custom classes in cache

2011-11-14 Thread Michael Toomim
Hi all, it appears I can't use any of my own classes in the cache:

   class Blah:
   pass

   b = blah()
   cache.disk('blah', lambda: b)

This results in:

   AttributeError: 'module' object has no attribute 'Blah'

I think this is because the things I'm defining (e.g. in models/)
isn't accessible from cache.py in gluon/. Is there a way around this?


Re: [web2py] autocomplete widget

2011-11-14 Thread Jim Steil
Just created a test app with trunk from this morning.  I see that the 
arrow keys now work appropriately but I'm not sure how to select an item 
when I have it in the list.


Thoughts?

-Jim

On 11/14/2011 4:27 PM, Jim Steil wrote:

Hi

Are many people using the autocomplete widget out there?

I'm having some inconvenient behavior with it.  First off, I think it 
would be great if it would do a .contains instead of a .like when it 
filters the data being returned.  Second, when using the control I'm 
seeing the following:


1.  Type in a couple characters and a dropdown list appears
2.  I would like to use the arrow key to navigate up and down through 
the list.  This doesn't work.  I have to tab to the list before arrow 
keys work.
3.  I would like to select my desired option using the space bar, 
enter key or single-clicking with the mouse.  None of these work.
4.  There seems to be a select delay or timeout where whatever list 
item is currently highlighted is selected and the list goes away 
without me doing anything.  I'm still thinking about which one I want 
to select and the list disappears and the currently highlighted 
selection is chosen (regardless of whether or not I'm actively 
scrolling through the list).  I'd prefer to have to do something to 
make it select something.


Is it possible I'm using some old CSS or web2py_ajax.html file?  I 
don't recall what version I was on when my app was initially created.


-Jim


[web2py] SQLFORM.grid: show reference table

2011-11-14 Thread Omi Chiba
I want to show the reference field value ('Name' in Model table) on
the grid instead of the original value (Model_ID in Product table).

Is there easy way to do it ?


Controller
---
def admin():
db.Product.id.readable = False
products =
SQLFORM.grid(db.Product,create=False,editable=False,deletable=False,
paginate=10)
return dict(products = products)
-

Model
--
db.define_table('Model',
Field('Name'),
Field('Unit'))

db.define_table('Product',
Field('Part_Number',label='Part Number'),
Field('Model_ID', db.Model ,label='Model Number'),
Field('List_Price', 'decimal(13,2)' ,label='List Price'),
Field('FOB', 'decimal(13,2)' ,label='FOB'),
Field('Weight', 'decimal(13,2)' ,label='Weight'))
--




[web2py] Re: Problem with 'unique' in DAL and validators

2011-11-14 Thread nick name
add requires=[] on the unique field to disable the vaidation, if you need 
the validate_and_update for any of the other fields.
The database itself should validate it for you (you'll get an sql error, 
rather than a web2py error).

In your first case, just dropping the name='') from the update would work.

The 2nd case is much more intricate, and would require a lot of logic in 
web2py to properly validate it -- which the underlying database should 
already have (pgsql has, mysq has for inno tables, most databases have, 
though sqlite doesn't and mysql myisam tables don't either).


[web2py] Re: Using the same form in multiple pages

2011-11-14 Thread Chris
Indeed, I don't. That's the solution I actually came to before I
rechecked the forum! Thanks much.

For future reference, I checked whether the login_form was already
defined as follows (the two instances of the form are formatted
differently):
{{if not 'login_form' in locals():}}
form code
{{pass}}

On Nov 14, 4:48 pm, Anthony abasta...@gmail.com wrote:
 Why do you need two distinct login forms in the same page? Can it be just
 one login form (i.e., one call to auth.login()) that you display twice? For
 example:

 def myaction():
     [do stuff]
     return dict(..., login_form=auth.login())

 View:

 {{=login_form # show it here}}
 ...
 {{=login_form # show it somewhere else}}

 Anthony







 On Monday, November 14, 2011 4:29:24 PM UTC-5, Chris wrote:

  After doing some more digging, it appears that each time you call
  auth.login(), you generate a new formkey. The first formkey must get
  overloaded, so the XSRF protection prevents either form from
  submitting.

  Any way I can get around this? Sample code:

              {{top_login_form = auth.login()}}
              {{=top_login_form.custom.begin}}
              {{=top_login_form.custom.widget.email}}
              {{=top_login_form.custom.widget.password}}
              input type=image src=/init/static/images/buttons/
  login.png id=loginBtn value=Log In /
              {{=top_login_form.custom.end}}
  h
              {{top_login_form2 = auth.login()}}
              {{=top_login_form2.custom.begin}}
              {{=top_login_form2.custom.widget.email}}
              {{=top_login_form2.custom.widget.password}}
              input type=image src=/init/static/images/buttons/
  login.png id=loginBtn value=Log In /
              {{=top_login_form2.custom.end}}

  On Nov 14, 4:24 pm, Chris zuzfre...@spammotel.com wrote:
   Cool, thanks guys.

   I do have decorators on certain login-only pages, but I want a page
   that's visible to both members and guests. The idea is to have a login
   form that shows up only under certain circumstances.

   I've done some further tests, and I think auth.login() is working in-
   template, but it doesn't seem to work if there's already a login form
   on the page. Can I only call auth.login() once?

   Here's how I'm attempting to do login now:

           {{if user_id:}}
               spanWelcome {{=user_current().first_name }}!/span
               form
                   input type=button id=logoutBtn value=Log Out
                       onclick=window.location.href =
   '{{=URL('default','user',args=['logout'])}}'; /
               /form
           {{else:}}
               {{top_login_form = auth.login()}}
               {{=top_login_form.custom.begin}}
               {{=top_login_form.custom.widget.email}}
               {{=top_login_form.custom.widget.password}}
               {{top_login_form.custom.widget.login}}
               input type=image src=/init/static/images/buttons/
   login.png id=loginBtn value=Log In /
               !--input type=text placeholder=email name=email
               input type=password placeholder=password
   name=password
               input type=image src=/init/static/images/buttons/
   login.png id=loginBtn value=Log In--
               {{=top_login_form.custom.end}}
           {{pass}}

   On Nov 14, 4:07 pm, Anthony abas...@gmail.com wrote:

auth.login() handles its own processing, so you don't need to do
login_form.accepts(). So, just use auth.login() wherever you need it.

Anthony

On Monday, November 14, 2011 3:58:52 PM UTC-5, Chris wrote:

 Hello,

 I'd like to make a login form and have it be accessible in multiple
 pages, without having to rewrite the same code in every single
 controller action:

 login_form = auth.login()
 if login_form.accepts(...

 Is this possible?

 Thanks,
 Chris


Re: [web2py] SQLFORM.grid: show reference table

2011-11-14 Thread Jim Steil

Here's what I would do.

(not tested)

db.define_table('Model',
Field('Name'),
Field('Unit'),
format='%(name)s')

-Jim

On 11/14/2011 4:55 PM, Omi Chiba wrote:

I want to show the reference field value ('Name' in Model table) on
the grid instead of the original value (Model_ID in Product table).

Is there easy way to do it ?


Controller
---
def admin():
 db.Product.id.readable = False
 products =
SQLFORM.grid(db.Product,create=False,editable=False,deletable=False,
paginate=10)
 return dict(products = products)
-

Model
--
db.define_table('Model',
 Field('Name'),
 Field('Unit'))

db.define_table('Product',
 Field('Part_Number',label='Part Number'),
 Field('Model_ID', db.Model ,label='Model Number'),
 Field('List_Price', 'decimal(13,2)' ,label='List Price'),
 Field('FOB', 'decimal(13,2)' ,label='FOB'),
 Field('Weight', 'decimal(13,2)' ,label='Weight'))
--




[web2py] Re: Resetting the database

2011-11-14 Thread Archibald Linx
Thanks to everybody.

Archibald

On 14 nov, 21:33, Vinicius Assef vinicius...@gmail.com wrote:
 SQLite? Just delete yourdatabasefile.

 Web2py will recreate it next time you execute your app.

 If it doesn't help, try something like that in web2py 
 shell:http://pastebin.com/w0q4yKkK

 --
 Vinicius Assef.

 On Mon, Nov 14, 2011 at 10:56 AM, Archibald Linx







 archibaldl...@gmail.com wrote:
  Thank you Bruno.

  I am using SQLite.

  I want to reset all the tables of my project.

  Thanks,
  Archibald

  On 14 nov, 01:44, Bruno Rocha rochacbr...@gmail.com wrote:
  whichdatabaseengine?

 http://zerp.ly/rochacbruno
  Em 13/11/2011 22:38, Archibald Linx archibaldl...@gmail.com escreveu:

   Dear Web2py users,

   How can I reset thedatabaseof my Web2py project ?

   Thanks,
   Archibald


[web2py] Re: SQLForm.grid - How do I use it properly?

2011-11-14 Thread Massimo Di Pierro
true. fields should also work with expressions
db.table.field1*db.table.field2+1 although I did not try.

On Nov 14, 3:36 pm, JaapP j...@tetra.nl wrote:
 One more reason to stick to using fields could be that with fields you
 can specify the order in which the columns are shown, this didn't work
 for 'columns'

 On 14 nov, 18:13, Jim Steil j...@qlf.com wrote:







  Ok, columns are gone again...

  Might just be best to stick with using fields.

       -Jim

  On 11/14/2011 8:47 AM, Jim Steil wrote:

   I stand corrected on the 'columns' comment.  Massimo added it back in
   this morning.

       -Jim

   On 11/14/2011 8:45 AM, Jim Steil wrote:
   here are a few thoughts...

   1.  Make sure you create this test in a new app.  If you're updating
   or adding functionality to an already existing app, then your layout
   and base.css need to be updated.
   2.  If using jquery-ui, then you need to download jquery-ui and
   include it in your layout.html with a line like this:

   {{response.files.append(URL('static','jquery-ui/js/jquery-ui-1.8.16.custom.
min.js'))}}

   {{response.files.append(URL('static','jquery-ui/css/sunny/jquery-ui-1.8.16.
custom.css'))}}

   3.  Don't use the 'columns' argument.  It is going away in the next
   release.  Instead, use 'fields'.  In your case, use the following:

   fields = [db.projects_posts.title, db.projects_posts.project_details,
   db.projects_posts.estimated_worth]

   4.  I typically do not specify the 'headers' arg.  Instead, set the
   'label' on your table definition.  That way you only have to do it
   once and can use it all over.  If you need to override it for a
   particular function, then just set the 'label' attribute in that
   function.

   5.  At this time there is no documentation available for SQLFORM.grid
   or SQLFORM.smartgrid.  The best thing to do would be to look through
   this group for all the posts.  Massimo is working on an updated
   version of that manual that he is hoping to have complete by the end
   of this month.  That should contain information on .grid and .smartgrid.

   6.  If you are going to be playing around with this I would recommend
   that you work with the code in trunk.  I don't recall what state the
   .grid was in when 1.99.2 was released.

   As for answers for your specific questions:

   Q: What is the exact proper method to use SQLForm.grid -
   I think your on the right track.  Just need to clean up your css and
   layout.html files to get the proper formatting.

   Q: What all libraries do I need to include? where?
   If you want to use jquery-ui then you need to download it and
   reference it in your layout.html.

   Q: How to make links work the way they should ?
   I'd like some more information on what is going on here before giving
   an answer.

   Q: Can search be customized? How?
   I don't remember if the search_form is implemented in 1.99.2, but
   there is a search facility built in that allows the users to create a
   custom search.  I am not a fan of it and have some other ideas how
   developers could be allowed to create custom search forms, but I
   haven't opened a ticket on it yet.

   Q: Is this documented in online book?  - did not find much about it in
   version 3.2 though.

   Documentation will be coming with the next version of the book
   targeted for the end of the month.

   Hope this helps.

       -Jim

   On 11/14/2011 6:54 AM, Rahul wrote:
   Hi All,
          Can anyone let me know how to use SQLForm.grid properly or tell
   me what I am missing. I have not installed any jquery plugin for the
   same (assuming that it is part of 1.99.2 by default). I cannot see the
   complete grid, just some buttons and data as per my query below. Also
   the links do not function when clicked. The table does not show any
   backgroud color or anything. Simply it doesnt look like a jquery
   grid.  My code is as below -

   My machine - Windows7 , IE9 and Firefox 7.0, Chrome.
   Web2py- Latest stable (1.99.1)

   #-Controller- (default.py)---
   def index():
        
        example action using the internationalization operator T and flash
        rendered by views/default/index.html or views/generic.html
        
        #Posts grid - SQLForm.grid
        #grid = SQLFORM.grid(db.projects_posts)
        query = ((db.projects_posts.post_visibility==Classified))
        columns = ('projects_posts.title',
                   'projects_posts.project_details',
                   'projects_posts.estimated_worth'
                  )
        headers ={'projects_posts.title': 'Title',
                  'projects_posts.project_details': 'Details',
                  'projects_posts.estimated_worth': 'Worth'}

        form = SQLFORM.grid( query=query, columns=columns,
   headers=headers,
                             deletable=False, editable=False, csv=False,
   maxtextlength=64 )

        return dict(form=form)

   #- View ---  (index.html)
   {{extend 'layout.html'}}
   

[web2py] Re: Can't use custom classes in cache

2011-11-14 Thread Massimo Di Pierro
there are two problems:
you are creating the instance before you cache, so the caching does
nothing (would do nothing if it worked). It does not work because it
cannot be serialized since Blah is not defined in a module but in a
model/controller. You will avoid lots of headaches if you cache
dictionaries instead of objects.


On Nov 14, 4:36 pm, Michael Toomim too...@gmail.com wrote:
 Hi all, it appears I can't use any of my own classes in the cache:

    class Blah:
        pass

    b = blah()
    cache.disk('blah', lambda: b)

 This results in:

    AttributeError: 'module' object has no attribute 'Blah'

 I think this is because the things I'm defining (e.g. in models/)
 isn't accessible from cache.py in gluon/. Is there a way around this?


Re: [web2py] Re: Can't use custom classes in cache

2011-11-14 Thread Bruno Rocha
I am caching my configuration class, I am passing the class to cache.ram()
and it will be called to create a new instance, and the instance will be
cached.

/modules/config.py

class Config():
  def __init__(self, db):
  # inside config I use cache to read config from db and sometimes
 from ConfigParser
  self.objects =
 self.db(self.db.configtable).select(cache=(cache.ram, 300))


In other modules

/modules/datamodel/user.py

class User(BaseModel):
 def __init__(self):
 from gluon import current
 self.cache = current.cache
 from config import Config
 self.config = self.cache('config', *Config*, time_expire=300)
 #caching an instance of Config


in controller:

def index():
  from datamodel.user import User
  user = User()
  return user.get_user_list()  # this function implements
 parse_template and also caches the html.


[web2py] Plugins and how to use them

2011-11-14 Thread P3llin0r3
Ok, so i'm writing a plugin write now that is a wrapper for a certain
api. So, I've written the api. I've tested my methods and such, and
they work.

So, now I have a few questions:

1.
 I'd like to call terminal commands from web2py. Is there a way to do
this? Specifically i'd like to start a secondary server from web2py
without having to ask the user.
2.
 So I have this plugin, but I don't know how to call the functions I
defined in the main controller of my app. I see in the book that it
says there is a naming convention, but I'm not quite sure what the
heck that is actually saying. Should I have it like this?

../appName/models/plugin_name.py
../appName/controllers/plugin_name.py

or does it refer to the Plug-in folder?

Thanks!


Re: [web2py] Re: Can't use custom classes in cache

2011-11-14 Thread Bruno Rocha
I notice that if you are planning to run on GAE, your cached object needs
to be Pickable, in my case, the config object instance is a king of
Storage, which acts like a dict.

So follow what Massimo said, and store only dict like objects in GAE,
otherwise you will heve this issue:


PicklingError: Can't pickle the object foo.bar.baz


[web2py] Re: Can't use custom classes in cache

2011-11-14 Thread Massimo Di Pierro
Even if they are pickable. it is possible that they get pickled but
web2py cannot unpickle them.

On Nov 14, 9:10 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 I notice that if you are planning to run on GAE, your cached object needs
 to be Pickable, in my case, the config object instance is a king of
 Storage, which acts like a dict.

 So follow what Massimo said, and store only dict like objects in GAE,
 otherwise you will heve this issue:

 PicklingError: Can't pickle the object foo.bar.baz


[web2py] Re: help please on adding jquery-ui theme to SQLFORM.grid

2011-11-14 Thread tomt
Thanks for the responses,

After reading the notes, I dug around and discovered the following
list of themes that can be used in layout.html.

base
black-tie
blitzer
cupertino
dark-hive
dot-luv
eggplant
excite-bike
flick
hot-sneaks
humanity
le-frog
mint-choc
overcast
pepper-grinder
redmond
smoothness
south-street
start
sunny
swanky-purse
trontastic
ui-darkness
ui-lightness
vader

Simply substitute any of these theme names in place of the ''
below.
(This is the line in layout.html referenced in the earlier note)

!-- uncomment here to load jquery-ui --
link rel=stylesheet href=http://ajax.googleapis.com/ajax/libs/
jqueryui/1.8.16/themes//jquery-ui.css type=text/css
media=all /

(I imagine you already know this, but I thought I'd include the list I
found for other interested users)

- Tom

On Nov 13, 9:15 pm, Anthony abasta...@gmail.com wrote:
 CSS files typically go in your app's /static/css folder, and you then have
 to make sure the CSS file gets linked in the page head (like any other CSS
 file). An easy way to include the CSS file is to do:

 response.files.append(URL('static', 'cs/your_theme_file.css'))

 in the controller action that needs the jquery-ui theme (or in your
 layout.html file if needed on most/all pages).

 Anthony

 On Sunday, November 13, 2011 9:45:45 PM UTC-5, tomt wrote:

  Hi,

  I'm looking for an example of how to install and use a jquery theme
  for SQLFORM.grid

  I see that I can implement jquery-ui by defining:
  form = SQLFORM.grid(query=db.table.field=='3',ui='jquery-ui')

  I see that I can download a theme fromhttp://jqueryui.com/download
  but I don't know where to install it, or how to enable it.  I searched
  the web2py group for examples, but I failed to find any.

  I'd appreciate it if someone could post a working example of this
  feature.

  Thanks in advance,  - Tom




[web2py] Re: help please on adding jquery-ui theme to SQLFORM.grid

2011-11-14 Thread Anthony
Yes, those are the pre-built jQuery UI themes (see Gallery 
tab): http://jqueryui.com/themeroller/. You can also create your own using 
ThemeRoller.

On Monday, November 14, 2011 10:52:40 PM UTC-5, tomt wrote:

 Thanks for the responses, 

 After reading the notes, I dug around and discovered the following 
 list of themes that can be used in layout.html. 

 base 
 black-tie 
 blitzer 
 cupertino 
 dark-hive 
 dot-luv 
 eggplant 
 excite-bike 
 flick 
 hot-sneaks 
 humanity 
 le-frog 
 mint-choc 
 overcast 
 pepper-grinder 
 redmond 
 smoothness 
 south-street 
 start 
 sunny 
 swanky-purse 
 trontastic 
 ui-darkness 
 ui-lightness 
 vader 

 Simply substitute any of these theme names in place of the '' 
 below. 
 (This is the line in layout.html referenced in the earlier note) 

 !-- uncomment here to load jquery-ui -- 
 link rel=stylesheet href=http://ajax.googleapis.com/ajax/libs/ 
 jqueryui/1.8.16/themes//jquery-ui.csshttp://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes//jquery-ui.css
  
 type=text/css 
 media=all / 

 (I imagine you already know this, but I thought I'd include the list I 
 found for other interested users) 

 - Tom 

 On Nov 13, 9:15 pm, Anthony abas...@gmail.com wrote: 
  CSS files typically go in your app's /static/css folder, and you then 
 have 
  to make sure the CSS file gets linked in the page head (like any other 
 CSS 
  file). An easy way to include the CSS file is to do: 
  
  response.files.append(URL('static', 'cs/your_theme_file.css')) 
  
  in the controller action that needs the jquery-ui theme (or in your 
  layout.html file if needed on most/all pages). 
  
  Anthony 
  
  On Sunday, November 13, 2011 9:45:45 PM UTC-5, tomt wrote: 
  
   Hi, 
  
   I'm looking for an example of how to install and use a jquery theme 
   for SQLFORM.grid 
  
   I see that I can implement jquery-ui by defining: 
   form = SQLFORM.grid(query=db.table.field=='3',ui='jquery-ui') 
  
   I see that I can download a theme fromhttp://jqueryui.com/download 
   but I don't know where to install it, or how to enable it.  I searched 
   the web2py group for examples, but I failed to find any. 
  
   I'd appreciate it if someone could post a working example of this 
   feature. 
  
   Thanks in advance,  - Tom 
  
 



[web2py] Re: Can't use custom classes in cache

2011-11-14 Thread Michael Toomim
So let me tease these problems apart.

1. Some objects are not pickleable. These cannot be cached to disk.
2. If the object's class is not defined in the scope available to
gluon/cache.py, then the object cannot be unpickled.

Both of these problems can be avoided by using cache.ram. (That's what
I'm doing, and probably why Bruno's works.)

Another workaround would be for the user to pickle and unpickle
objects himself, in his own code, and then pass the string to the
cache.

We could also eliminate problem #2 by making the set of additional
class definitions available to gluon/cache.py. Perhaps with something
like cache.set_custom_class_definitions([Blah]). This solution seems
like the shortest path... but adding new APIs like this feels
distasteful. :P

(Massimo, I'm not sure what the problem is you're referring to with
creating an instance before I cache.)

On Nov 14, 7:41 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Even if they are pickable. it is possible that they get pickled but
 web2py cannot unpickle them.

 On Nov 14, 9:10 pm, Bruno Rocha rochacbr...@gmail.com wrote:







  I notice that if you are planning to run on GAE, your cached object needs
  to be Pickable, in my case, the config object instance is a king of
  Storage, which acts like a dict.

  So follow what Massimo said, and store only dict like objects in GAE,
  otherwise you will heve this issue:

  PicklingError: Can't pickle the object foo.bar.baz


Re: [web2py] Re: Oreilly python-Certification

2011-11-14 Thread Kiem Nguyen
Thanks, I have been looking for something like this.

On Mon, Nov 14, 2011 at 3:57 PM, mikech mp.ch...@gmail.com wrote:

 Thanks, very useful.




-- 
Best regards,
Kiem Nguyen
www.KiemNguyen.com


Re: [web2py] Re: Can't use custom classes in cache

2011-11-14 Thread Bruno Rocha
On Tue, Nov 15, 2011 at 2:00 AM, Michael Toomim too...@gmail.com wrote:

 (Massimo, I'm not sure what the problem is you're referring to with
 creating an instance before I cache.)


Cache expects a callable object, instances are not callable, they have to
be called inside cache logic.



-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: application installation problem

2011-11-14 Thread petrasadi
this was it.
Thank you much


[web2py] response.stream on GAE

2011-11-14 Thread Bruno Rocha
Hi,


I have this code working on localhost:

*def download():
 **import os
 **response.stream(os.path.join(request.folder, 'uploads',
 request.args(0)))*


But does not works on GAE

Any hint?


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: response.stream on GAE

2011-11-14 Thread Bruno Rocha
forget about it, it is working now... using retrieve (dahhh GAE stores a
blob)

On Tue, Nov 15, 2011 at 2:40 AM, Bruno Rocha rochacbr...@gmail.com wrote:


 Hi,


 I have this code working on localhost:

  *def download():
 **import os
 **response.stream(os.path.join(request.folder, 'uploads',
 request.args(0)))*


 But does not works on GAE

 Any hint?


 --

 Bruno Rocha
 [http://rochacbruno.com.br]




-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Download file and redirect (or redirect and auto-download file)

2011-11-14 Thread Wes Hall
You're right.  In short, I was just looking for the typical, easy web2py 
method for http-equiv; something similar to response.meta.refresh().

I think if I spend some more time wrapping my head around response, I'll be 
able to better determine what I should do. In simple terms, I want to issue 
multiple responses, but this is probably, and rightfully so, frowned upon.


[web2py] Re: Download file and redirect (or redirect and auto-download file)

2011-11-14 Thread Massimo Di Pierro
This may help

http://stackoverflow.com/questions/822707/php-generate-file-for-download-then-redirect

I think the easiest solution is to have a page with an iframe. The
iframe is hidden (size zero) and links the file to download (this will
initiate the download automatically). The page containing the iframe
can have a meta http-equiv=refresh content=5;url=http://...; to
redirect to the next page while downloads continue.

Massimo

On Nov 14, 11:56 pm, Wes Hall wesh...@gmail.com wrote:
 You're right.  In short, I was just looking for the typical, easy web2py
 method for http-equiv; something similar to response.meta.refresh().

 I think if I spend some more time wrapping my head around response, I'll be
 able to better determine what I should do. In simple terms, I want to issue
 multiple responses, but this is probably, and rightfully so, frowned upon.


Re: [web2py] Re: Removal of 'columns' in grid/smartgrid creates problems for search function

2011-11-14 Thread Johann Spies
On 14 November 2011 17:53, Massimo Di Pierro massimo.dipie...@gmail.comwrote:

 On a second thought... all readable fields should be searchable even
 if not displayed. I fixed this and columns is gone again.


Thanks.  The original functionality is back again.  Ths also solved another
problem I had with the query-widget which offered searchable fields which
were not displayed and then the query ended in an 'invalid query' error
when they were used.

I can think of situations where one does not want all fields to be
searchable and even less displayed.  As Anthony suggested it will be
advantageous if one can clearly specify which fields should show up in the
grid and which can be searched.

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


Re: [web2py] autocomplete widget

2011-11-14 Thread Johann Spies
 On 15 November 2011 00:37, Jim Steil j...@qlf.com wrote:

 Just created a test app with trunk from this morning.  I see that the
 arrow keys now work appropriately but I'm not sure how to select an item
 when I have it in the list.

 Thoughts?


Some time ago I had problems with the autocomplete widget: clients using IE
complained that it was malfunctioning.  I then switched to the
suggest-widget-plugin (http://dev.s-cubism.com/plugin_suggest_widget) which
works in IE also.

Maybe you can try it out.

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


[web2py] Wrapping text in SQLFORM.grid

2011-11-14 Thread Johann Spies
I have found one solution which works for me:

In static/css/basic.css I commented:

/*.web2py_grid td { white-space:nowrap; }*/

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


Re: [web2py] autocomplete widget

2011-11-14 Thread José Luis Redrejo Rodríguez
Hi
I've worked in a plugin using part of the code of autocomplete widget
but using jquery autocomplete and contains insted of like when a third
parameter (search_field) is used. It works perfectly in GAE.
The idea is being able to look in a field of kind list:string to
retrieve the id in the associated table.
I'd like to clean it up a little bit before publishing it in
web2pyslices, but if you're in a hurry I can send the dirty version to
you in a private email.


Regards.
José L.

2011/11/14 Jim Steil j...@qlf.com:
 Hi

 Are many people using the autocomplete widget out there?

 I'm having some inconvenient behavior with it.  First off, I think it would
 be great if it would do a .contains instead of a .like when it filters the
 data being returned.  Second, when using the control I'm seeing the
 following:

 1.  Type in a couple characters and a dropdown list appears
 2.  I would like to use the arrow key to navigate up and down through the
 list.  This doesn't work.  I have to tab to the list before arrow keys work.
 3.  I would like to select my desired option using the space bar, enter key
 or single-clicking with the mouse.  None of these work.
 4.  There seems to be a select delay or timeout where whatever list item is
 currently highlighted is selected and the list goes away without me doing
 anything.  I'm still thinking about which one I want to select and the list
 disappears and the currently highlighted selection is chosen (regardless of
 whether or not I'm actively scrolling through the list).  I'd prefer to have
 to do something to make it select something.

 Is it possible I'm using some old CSS or web2py_ajax.html file?  I don't
 recall what version I was on when my app was initially created.

    -Jim



[web2py] Re: Oreilly python-Certification

2011-11-14 Thread Gour
On Mon, 14 Nov 2011 14:29:52 +0630
Phyo Arkar phyo.arkarl...@gmail.com
wrote:

 Cool , i am so bored to study for certs but i think this one is cool!

Huh... $400 bucks for one course...I believe I'm going to buy 4th ed. of
web2py book and learn. :-D


Sincerely,
Gour


-- 


signature.asc
Description: PGP signature