[web2py] Re: Images not laoded

2012-11-10 Thread Julien Courteau
I realized, all of a sudden, that the images of my home page didn't use the 
{{=URL()}} notation...
That's why web2py didn't know how to fetch them (img 
src=../static/img.png /).
Thanks!

On Friday, November 9, 2012 11:33:30 PM UTC-5, pbreit wrote:

 Are you doing images like this?

 IMG(_src=URL('static','logo.png'), _alt=My Logo)

 or

 img src=URL('static','logo.png') alt=My Logo


 On Friday, November 9, 2012 7:20:03 PM UTC-8, Julien Courteau wrote:

 Hello All,

 The images of my home page didn't load if I try to access it with the 
 following URLs: 

 localhost:8000/
 localhost:8000/mm/

 but loaded fine with:

 localhost:8000/mm/default/ or
 localhost:8000/mm/default/index/

 the name of my application being, of course, mm and my home page is 
 displayed by
 default/index.
 In the console of Firebug I've got the following error message for each 
 images 
 of the home page (when I try to access it by / or /mm) :

 NetworkError: 404 NOT FOUND - 
 http://127.0.0.1:8000/static/images/image.jpg;.

 My folder image is under: ~/web2py/applications/mm/static/images.

 It is a problem if I want to set deafult_application = mm (in routes.py)...

 Could you help me understand that situation?

 Thanks.



-- 





[web2py] Re: DAL and Pivot Tables

2012-11-10 Thread Rocco
I found a solution, I don't know if it is the good one, but works enough 
for me.

My real data structure is slightly different about the above example:

db.define_table('ctd',
Field('station'),
Field('parameter'),
Field('value','integer'))

It contains oceanographic information about sea water.
This is a recordset example:

ctd.id station param. ctd.value
1 1 depth 5
2 1 depth 10
3 1 depth 15
4 1 depth 20
5 1 depth 25
6 1 C 44
7 1 C 56
8 1 C 66
9 1 C 62
10 1 C 77
11 1 q 13
12 1 q 22
13 1 q 41
14 1 q 63
15 1 q 52


This is the controller I used:
def ctd():   
   r=[]
   fields=[]
   for row in  db(db.ctd.station==1).select(db.ctd.parameter,distinct=True):
  d=[]
  fields.append(row.parameter)
  for col in db(db.ctd.station==1 and 
db.ctd.parameter==row.parameter).select(db.ctd.value):
 d.append(col.value)
  r.append(d)
   return dict(fields=fields, rows=r)

And this one is the view (default/ctd.html)
{{extend 'layout.html'}}
table
thead
tr
{{for f in fields:}}
{{=TH(f)}}
{{pass}}
/tr
/thead
tbody
{{for j in range(0,len(rows[0])):}}
tr
   {{for i in range(0,len(rows)):}}
   {{=TD(rows[i][j])}}
{{pass}}
/tr
{{pass}}
/tbody
/table

The result is what I wanted:

C depth q
44 5 13
56 10 22
66 15 41
62 20 63
77 25 52


If someone knows a better way... please tell us!

-- 





[web2py] Re: calendar display

2012-11-10 Thread dhmorgan
I think you may find an answer here, but the original question is difficult 
to understand.

Are you saying you want the calendar to be built into the form and always 
visible? Or do you want it to be a pop-up and already activated upon page 
load, as though the user had clicked in the date field?

Are you saying you want the calendar that typically pops up when entering 
dates in a form? It is calendar.js and is located in (welcome)/static/js. 
It also uses calendar.css. Both are usually loaded automatically as part 
of views/web2py_ajax.html. 

In your new layout.html file, you will need to have something like:

{{
response.files.insert(0,URL('static','js/jquery.js'))
response.files.insert(1,URL('static','css/calendar.css'))
response.files.insert(2,URL('static','js/calendar.js'))
response.files.insert(3,URL('static','js/web2py.js'))
}}






On Friday, November 9, 2012 9:01:04 PM UTC-6, dantuluri jaganadha raju 
wrote:




 Please reply to this as soon as possible.Thank you in advance





 On Sunday, November 4, 2012 8:03:20 AM UTC+5:30, dantuluri jaganadha raju 
 wrote:

 Hi,
   I want to display the calendar that will display when we click on some 
 field(appropriate) of a form .One thing is that I will not click on 
 field.,what I mean is that ,it should appear as soon as I entered that page 
 and should have same functions(dynamic) that is in normal calendar that 
 displays in web2py.Moreover I am NOT USING EXTENDED LAYOUT.HTML and using 
 new layout. please reply as soon as possible what changes I have to make.

Thank you in advance ...
 Raju.



-- 





[web2py] Re: gitpython module error

2012-11-10 Thread dhmorgan
Is the failure to find gitpython module happening with development server 
or Apache/other? If you start Python interpreter and can you import git, 
perhaps web server is using a different Python.



On Friday, November 9, 2012 1:19:23 AM UTC-6, Luc Chase wrote:

 When trying to install a package from github I get an error saying that I 
 need to have the gitpython module. But when I execute the following it 
 seems it is already there...
  sudo pip install gitpython
 Password:
 Requirement already satisfied (use --upgrade to upgrade): gitpython in 
 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/GitPython-0.3.2.RC1-py2.7.egg
 Requirement already satisfied (use --upgrade to upgrade): gitdb=0.5.1 in 
 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gitdb-0.5.4-py2.7-macosx-10.5-intel.egg
  
 (from gitpython)
 Requirement already satisfied (use --upgrade to upgrade): async=0.6.1 in 
 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/async-0.6.1-py2.7-macosx-10.5-intel.egg
  
 (from gitdb=0.5.1-gitpython)
 Requirement already satisfied (use --upgrade to upgrade): smmap=0.8.0 in 
 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/smmap-0.8.2-py2.7.egg
  
 (from gitdb=0.5.1-gitpython)
 Cleaning up...


 So what do I need to do to ensure it is available to Web2py ? 

 By the way... gitpython is a requirement of web2py so how come it isn't 
 included?
 It also can't be used as a tag in this group?



-- 





[web2py] web2py process terminates without reason

2012-11-10 Thread BlueShadow
Hi,
I installed web2py on my unix server and started it but in less than 8 
hours the process is terminated. Is there some sort of log where I can find 
out why this happens? Is there a way I can make it run forever? After all 
it is a server and my site should be reacheable 24/7

Server Ubuntu 12.04 Lts
web2py 2.2.1 (2012-10-21 16:57:04)

thats my shell script I start it with:
#!/usr/bin/env sh

cd $HOME/lib/python/web2py
python web2py.py -i xxx.xxx.xxx.xxx -a pw -p 2323 -c /root/ssl/server.crt -k 
/root/ssl/server.key


I got a second question is it possible to visit the sites without the https 
and only go to the admin panel via ssl?

thanks for your help!

-- 





[web2py] web2py woes

2012-11-10 Thread Daniele
I just started using web2py and am having lots of trouble with things that 
I think should be quite simple. I will enumerate them here in the hopes 
they can be answered:

1) I had made a design in Twitter bootstrap 2.2.1 which was working fine as 
a plain .html file. I saw that web2py used an older version of bootstrap so 
I replaced the defauly boostrap.min.css with the latest version. Upon 
uploading my views, everything seemed to work fine. However, when I 
switched from one page to the next I realized that the container size was 
changing. I finally discovered that changing the {{if 
left_sidebar_enabled:}} to {{if not left_sidebar_enabled:}} or {{if 
right_sidebar_enabled:}} to {{if not right_sidebar_enabled:}} solved the 
container problem: every page remained the same width. What gives? How can 
I prevent having to check whether the sidebar is there in order to get my 
templates to all format nicely?

2) With the vanilla Twitter bootstrap 2.2.1, my thumbnails class was 
leaving a nice padding between thumbnails. Now, it's not. Is this a problem 
with the web2.py css files??

3) How can I get rid of the annoying page.com/default/goal structure? I 
just would like to have page.com/goal

4) The navbar by default has an Index link. How can I get rid of it? I 
don't see any index in the layout.html file so I don't know where this is 
coming from.

Thanks in advance!!!

-- 





[web2py] Re: table id tag in SQLFORM.grid()

2012-11-10 Thread HP
Thank you. 

On Thursday, November 8, 2012 4:43:12 PM UTC-5, Paolo Caruccio wrote:

 In the controller:

 myGrid = SQLFORM.grid(db.tablename)
 w2p_grid_tbl = myGrid.element('table')
 w2p_grid_tbl['_id'] = 'table_id'

 return dict(grid=myGrid)

 or in the view:

 {{extend 'layout.html'}}
 {{w2p_grid_tbl = grid.element('table')}}
 {{w2p_grid_tbl['_id'] = 'table_id'}}

 {{=grid}}


 Il giorno giovedì 8 novembre 2012 18:22:20 UTC+1, HP ha scritto:

 I am creating a table using SQLFROM.grid() and want to set the table id 
 attribute in the created HTML table,
 how can I do that?



-- 





Re: [web2py] proper way to mobile and desktop 'skins'

2012-11-10 Thread Ray (a.k.a. Iceberg)
Hi there,

I just come across this old post. I solve this problem in a slightly 
different way. With all the same *.mobile views ready, I just explicitly 
use .mobile extension name as my visiting url, such as 
http://.../app/controller/action.mobile, therefore I don't need those if 
is_mobile code snippet in my every controller functions.

Hope that helps.

Regards,
Ray


On Tuesday, June 28, 2011 4:21:26 PM UTC+8, demetrio wrote:

 Sorry, i sent the message incomplete:

 Hi!

 I'm using jQueryMobile to make the mobile skin, and the way that i do
 is this:

 if is_mobile and request.extension == html :
 #Its mobile 
 response.view = %s/%s.%s % (request.controller,
 request.function, mobile)
 if not os.path.exists(os.path.join(request.folder, 'views',
 request.controller, request.function+.mobile)):
 response.view = '%s.%s' % (generic, mobile) 


 The 'request.extension == html' condition is because if you
 use .load, .json extensions or so, it can crash

 With this code, you only have to make .mobile extensions of your
 views:

 for example if you have:

 layout.html
 generic.html
 controller/funct1.hmtl
 controller/funct2.html

 You only have to make the views:

 layout.mobile
 generic.mobile
 controller/funct1.mobile
 controller/funct2.mobile

 If you keep your editor's syntax highlighting maybe you can change
 .mobile extension with .mobile.html (editing the code that i pasted
 at the begginig too, to make this change work)

 I hope this solution will be useful

 El lun, 27-06-2011 a las 16:28 -0700, Luis Goncalves escribió:
  Hello!
  
  I need to customize my views so that they look good on a computer
  screen and on a smart phone.
  
  One way to do so, It think, is to have separate layout definitions and
  then do something like:
  
  {{if session.platform == 'mobile':}}
  {{extend 'mobile-layout.html}}
  {{else:}}
  {{extend 'desktop-layout.html'}}
  {{pass}}
  
  This does not seem to be working -  I get lots of syntax errors (can't
  even figure out where they are!)
  
  Is this approach wrong?   Is it possible to have a conditional
  extend ?
  
  Is there a smarter/better way to make the view rendering platform
  dependent?
  
  Thanks,
  Luis.




-- 





[web2py] conditional update after form is submitted

2012-11-10 Thread Simon Carr
Hi,
I want to run some code after an update form is submitted but before the 
record in the database is updated. 

Where can I put the code so that I know the values in the form have passed 
validation before I run my code.

Thanks
Simon 

-- 





Re: [web2py] web2py woes

2012-11-10 Thread Vasile Ermicioi
hi,

1)
since you already have a plain html design my advice is to remove all files
from static folder of your app and to put your bootstrap files there,
then replace the content of layout.html from view folder with your content
(from html file) and adjust links of css and js files
then put {{include}} somewhere in the middle

2) will be fixed by 1) :)

3) don't worry about, you can rewrite urls
http://web2py.com/books/default/chapter/29/04#URL-rewrite
 better to do that before deploying,

4) will be fixed by 1) :)

-- 





[web2py] expressions and update

2012-11-10 Thread Martin Weissenboeck
I have tried this example

def visit():
db(db.person1.id0).update(
visits = db.person1.visits + 1,
   )

It is in the book and works fine.
Now I have added another line...

def visit():
db(db.person1.id0).update(
visits = db.person1.visits + 1,
name = db.person1.name.capitalize(),
)

.. and I got an error:
type 'exceptions.AttributeError' 'Field' object has no attribute
'capitalize'(1) I do not understand why it is possible to add 1 to a field,
but not to do something other with a string.

(2) Is there any simple solution? Of course I could write something like

for r in db(db.person1.id0).select():
   ... update ...

Regards, Martin

-- 





[web2py] Re: expressions and update

2012-11-10 Thread Niphlod
that's because db.person1.visits in an expressions is turned to the string 
'person1.visits' and all databases understand

update person1
set person1.visits = person1.visits + 1

when you do db.person1.name.capitalize(), you are willing to have a 
database that executes a python function (capitalize()): that is not 
supported by databases, so web2py doesn't let you do that.
 
if you want to exploit the potentials of python functions, you need to 
update one record at a time passing the pre-calculated value to the 
database.

On Saturday, November 10, 2012 7:02:42 PM UTC+1, mweissen wrote:

 I have tried this example 

 def visit():
 db(db.person1.id0).update(
 visits = db.person1.visits + 1,
)
 
 It is in the book and works fine.
 Now I have added another line...

 def visit():
 db(db.person1.id0).update(
 visits = db.person1.visits + 1,
 name = db.person1.name.capitalize(),
 )

 .. and I got an error:
 type 'exceptions.AttributeError' 'Field' object has no attribute 
 'capitalize'(1) I do not understand why it is possible to add 1 to a 
 field, but not to do something other with a string.

 (2) Is there any simple solution? Of course I could write something like

 for r in db(db.person1.id0).select():
... update ...

 Regards, Martin



-- 





Re: [web2py] conditional update after form is submitted

2012-11-10 Thread Niphlod
or use the onvalidation callback on form.process

form.process(onvalidation=yourfunction).accepted

On Saturday, November 10, 2012 6:57:10 PM UTC+1, Vasile Ermicioi wrote:

 if form.validate(request.vars):
 #your code
 form.accepts(request.vars) 

-- 





Re: [web2py] conditional update after form is submitted

2012-11-10 Thread Simon Carr
Hi Vasile,

Thanks for the reply, but that code seems to generate an error

if form.validate(request.vars):
TypeError: validate() takes exactly 1 argument (2 given)


Here is my full function that I am trying to run if it helps

@auth.requires_login()   
def edit_chart():
record = db.section_charts(request.vars['scid'])
form = 
SQLFORM(db.section_charts,record,Fields=('title','description','width','position'),deletable=True,hidden=dict(oldposition=record.position))
if form.validate(request.vars):
if request.vars['oldposition'] != form.vars['position']:
sql = update section_charts set position = position + 1 where 
position =  + str(form.vars['position'])
db.executesql(sql)
if form.process().accepted:
response.flash = Chart Updated
redirect(URL('manage_dashboard'),client_side=True)
elif form.errors:
response.flash = The forms has errors
else:
response.flash = Please complete the form
return form






On Saturday, 10 November 2012 17:57:10 UTC, Vasile Ermicioi wrote:

 if form.validate(request.vars):
 #your code
 form.accepts(request.vars) 

-- 





Re: [web2py] conditional update after form is submitted

2012-11-10 Thread Simon Carr
Thanks Batman,

That is what I was looking for. I thought I had seen it before, but could 
not find it again when searching the documentation.

Cheers
Simon

On Saturday, 10 November 2012 19:47:00 UTC, Niphlod wrote:

 or use the onvalidation callback on form.process

 form.process(onvalidation=yourfunction).accepted

 On Saturday, November 10, 2012 6:57:10 PM UTC+1, Vasile Ermicioi wrote:

 if form.validate(request.vars):
 #your code
 form.accepts(request.vars) 



-- 





[web2py] deploying web2py apache wsgi

2012-11-10 Thread BlueShadow
Hi I used the setup-web2py-ubuntu.sh to install web2py. It installed it but 
when I access my server on the specified port get the welcome app but I 
can't access the admin panel!
It says app admin is deactivated because of unsecure channel.
when I try to access it with an https:// infront of my severs ip I get an 
ssl error.
web2py wath started with this command:
python ./web2py.py -i xxx.xxx.xxx.xxx -a password -p 2323
I did nothing else but install web2py with this script.
In the deployment recipes: http://web2py.com/books/default/chapter/32/13 
there is quite a lot about making apace config files but I got no clue ho 
to do that even with these recipes and from my understanding the 
setupsh should have done all this?

-- 





Re: [web2py] deploying web2py apache wsgi

2012-11-10 Thread Kenneth Lundström

Hi Kevin,

the setup script does not change Apaches SSL configuration at all, if I 
remember correctly. So you need to configure your Apache to use SSL. You 
need to generate a self-generated certificate, if you havn't bought one.



Kenneth

Hi I used the setup-web2py-ubuntu.sh to install web2py. It installed 
it but when I access my server on the specified port get the welcome 
app but I can't access the admin panel!

It says app admin is deactivated because of unsecure channel.
when I try to access it with an https:// infront of my severs ip I get 
an ssl error.

web2py wath started with this command:
python ./web2py.py -i xxx.xxx.xxx.xxx -a password -p 2323
I did nothing else but install web2py with this script.
In the deployment recipes: 
http://web2py.com/books/default/chapter/32/13 there is quite a lot 
about making apace config files but I got no clue ho to do that even 
with these recipes and from my understanding the setupsh should 
have done all this?


--





--





[web2py] Plugin installation without admin

2012-11-10 Thread David Sorrentino
Hello everybody,

I am wondering if there is a way to install a plugin without using the
admin interface.
Can anybody help me in that?

Cheers,
David

-- 





Re: [web2py] Plugin installation without admin

2012-11-10 Thread Massimo Di Pierro
cd applications/yourapp
tar zxvf /path/to/web2py.plugin.name.w2p

On Saturday, 10 November 2012 16:34:21 UTC-6, David Sorrentino wrote:

 Hello everybody,

 I am wondering if there is a way to install a plugin without using the 
 admin interface.
 Can anybody help me in that?

 Cheers,
 David


-- 





[web2py] xhtml2pdf / pisa in a web2py view

2012-11-10 Thread chris_g

Has anyone had any luck running Pisa in a web2py view?
I've only had success with using it at the command line:
  pisa example.html
-- pisa.pdf

I've tried putting the following in a view, but I am getting an empty 
string returned.

{{
import logging
import os
import StringIO
import xhtml2pdf.pisa as pisa
filename = '%s/%s.html' % (request.controller,request.function)
if os.path.exists(os.path.join(request.folder,'views',filename)):
   html=response.render(filename)
else:
   html=BODY(BEAUTIFY(response._vars)).xml()
pass
result = StringIO.StringIO() 
pdf = pisa.CreatePDF(html, result)
=result.read()
}}



-- 





[web2py] Re: xhtml2pdf / pisa in a web2py view

2012-11-10 Thread chris_g
I believe I need to use a file reference to the html like this:
pdf = pisa.CreatePDF( StringIO.StringIO(html) , result)

But I am still getting an empty string.

-- 





Re: [web2py] deploying web2py apache wsgi

2012-11-10 Thread BlueShadow
OK can you tell me how I do configure the apache2 server? I got the ssl crt 
and key.

On Saturday, November 10, 2012 10:35:36 PM UTC+1, Kenneth wrote:

  Hi Kevin, 

 the setup script does not change Apaches SSL configuration at all, if I 
 remember correctly. So you need to configure your Apache to use SSL. You 
 need to generate a self-generated certificate, if you havn't bought one.


 Kenneth

  Hi I used the setup-web2py-ubuntu.sh to install web2py. It installed it 
 but when I access my server on the specified port get the welcome app but I 
 can't access the admin panel!
 It says app admin is deactivated because of unsecure channel.
 when I try to access it with an https:// infront of my severs ip I get an 
 ssl error.
 web2py wath started with this command:
 python ./web2py.py -i xxx.xxx.xxx.xxx -a password -p 2323
 I did nothing else but install web2py with this script.
 In the deployment recipes: http://web2py.com/books/default/chapter/32/13there 
 is quite a lot about making apace config files but I got no clue ho 
 to do that even with these recipes and from my understanding the 
 setupsh should have done all this?

 -- 
  
  
  


  

-- 





Re: [web2py] Plugin installation without admin

2012-11-10 Thread David Sorrentino
Easier than expected! :)

Thank you Massimo.

I wish you a good Sunday.
David


On 11 November 2012 01:15, Massimo Di Pierro massimo.dipie...@gmail.comwrote:

 cd applications/yourapp
 tar zxvf /path/to/web2py.plugin.name.w2p


 On Saturday, 10 November 2012 16:34:21 UTC-6, David Sorrentino wrote:

 Hello everybody,

 I am wondering if there is a way to install a plugin without using the
 admin interface.
 Can anybody help me in that?

 Cheers,
 David

  --





--