[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-05-28 Thread Paolo Caruccio
Andrew,

I, just now, proposed a patch through issue tracker (
http://code.google.com/p/web2py/issues/detail?id=824) that should resolve 
the problems with IE7 noted by you. Moreover the auth_navbar is more 
compliant with bootstrap (check the image). I tested the new welcome layout 
replacing the default web2py bootstrap.min.css with some from bootswatch 
and it seems work good now. 
<>

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-05-28 Thread Paolo Caruccio
Andrew,

a solution for sidebar issue is to add "span12" class to the section#main 
of layout.html in views folder

About the auth nav bar a first solution is to set a specific color because 
IE7 ignore "inherit". Please add the below two lines at the bottom of 
bootswatch.css file in static/css folder
 

Il giorno lunedì 28 maggio 2012 01:40:53 UTC+2, Andrew ha scritto:
>
> Testing the "United" Bootswatch at the moment.  ( I can test it but 
> unfortunately I can't really offer suggested fixes -> CSS Rookie )
>
> The Login | Register | Lst Password text is not visible.  
>
> My Left sidebar now comes first, and the Welcome App's Admin button is now 
> at the bottom.
>
> Does Bootstrap mean that the left_sidebar_enabled type techniques no 
> longer work, or do we need to get this fixed ?
>
>
>

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-05-27 Thread Paolo Caruccio
A small look improvement . Please replace code for  .icon-chevron-right in 
bootswatch.css with

.icon-chevron-right {
  border-left: 4px solid #000;
  border-right: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-top: 4px solid transparent;
  content: "";
  display: inline-block;
  height: 0;
  opacity: 0.7;
  vertical-align: top;
  width: 0;
  margin-right:-13px;
  margin-top: 7px;
  float:right;
}


Il giorno domenica 27 maggio 2012 12:23:54 UTC+2, Paolo Caruccio ha scritto:
>
> Small patch - not deeply tested - to make the menu working when javascript 
> is disabled.
>
> Il giorno venerdì 25 maggio 2012 22:06:38 UTC+2, Massimo Di Pierro ha 
> scritto:
>>
>> I managed to fix it. Now the carets and class are added automatically via 
>> JS and there is no need to tweak menus.
>>
>> Cons: nested menus break if JS disabled.
>>
>> Anyway, I feel this is a big step closer to web2py 2.0.
>>
>> massimo
>>
>> On Friday, 25 May 2012 14:53:24 UTC-5, Massimo Di Pierro wrote:
>>>
>>> I added this trunk but with one change. Instead of the attached menu.py 
>>> (which is not backward compatible), I added some jQuery code layout.html 
>>> that attempts to reproduce the same effect. It works something is wrong 
>>> with alignment and I cannot figure out what. Can you take a look?
>>>
>>> Massimo
>>>
>>> On Thursday, 24 May 2012 18:16:37 UTC-5, Paolo Caruccio wrote:
>>>>
>>>> Andrew, I played a bit on this subject. Please replace the below files 
>>>> (before backup them) with attached ones:
>>>>
>>>> 1. welcome > models > menu.py (check the changes in response.menu)
>>>> 2. welcome > views > layout.html (heavily changed)
>>>> 3. welcome > static > css > web2py.css (find the comment "bootswatch" 
>>>> to see the changes)
>>>>
>>>> Now, if you download a css from bootswatch.com or built it from  
>>>> http://stylebootstrap.info, replacing default one you shouldn't have 
>>>> problems. For the menu I used one of solutions that Anthony proposed.
>>>>
>>>> In attachement also some images to show how several themes are rendered 
>>>> in several modern browsers.
>>>>
>>>> Last notes:
>>>> a) this is an experiment. You have to obtain official changes from 
>>>> web2py developers
>>>> b) my enviroment: windows 7, python 2.7.2, web2py version 2.0.00 
>>>> (2012-05-23 09:27:57) dev
>>>>
>>>>
>>>> Il giorno lunedì 21 maggio 2012 20:42:38 UTC+2, Andrew ha scritto:
>>>>>
>>>>> Hello,
>>>>> I'm trying a few bootswatch themes over a new "welcome" app.see 
>>>>> http://bootswatch.com/
>>>>> The first thing I noticed is that the menus don't display correctly.  
>>>>>
>>>>> Is anyone playing with this ?  Seeing that web2py uses bootstrap, it 
>>>>> would be great to drop in a bootswatch theme.
>>>>>
>>>>>

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-05-27 Thread Paolo Caruccio
Small patch - not deeply tested - to make the menu working when javascript 
is disabled.

Il giorno venerdì 25 maggio 2012 22:06:38 UTC+2, Massimo Di Pierro ha 
scritto:
>
> I managed to fix it. Now the carets and class are added automatically via 
> JS and there is no need to tweak menus.
>
> Cons: nested menus break if JS disabled.
>
> Anyway, I feel this is a big step closer to web2py 2.0.
>
> massimo
>
> On Friday, 25 May 2012 14:53:24 UTC-5, Massimo Di Pierro wrote:
>>
>> I added this trunk but with one change. Instead of the attached menu.py 
>> (which is not backward compatible), I added some jQuery code layout.html 
>> that attempts to reproduce the same effect. It works something is wrong 
>> with alignment and I cannot figure out what. Can you take a look?
>>
>> Massimo
>>
>> On Thursday, 24 May 2012 18:16:37 UTC-5, Paolo Caruccio wrote:
>>>
>>> Andrew, I played a bit on this subject. Please replace the below files 
>>> (before backup them) with attached ones:
>>>
>>> 1. welcome > models > menu.py (check the changes in response.menu)
>>> 2. welcome > views > layout.html (heavily changed)
>>> 3. welcome > static > css > web2py.css (find the comment "bootswatch" to 
>>> see the changes)
>>>
>>> Now, if you download a css from bootswatch.com or built it from  
>>> http://stylebootstrap.info, replacing default one you shouldn't have 
>>> problems. For the menu I used one of solutions that Anthony proposed.
>>>
>>> In attachement also some images to show how several themes are rendered 
>>> in several modern browsers.
>>>
>>> Last notes:
>>> a) this is an experiment. You have to obtain official changes from 
>>> web2py developers
>>> b) my enviroment: windows 7, python 2.7.2, web2py version 2.0.00 
>>> (2012-05-23 09:27:57) dev
>>>
>>>
>>> Il giorno lunedì 21 maggio 2012 20:42:38 UTC+2, Andrew ha scritto:
>>>>
>>>> Hello,
>>>> I'm trying a few bootswatch themes over a new "welcome" app.see 
>>>> http://bootswatch.com/
>>>> The first thing I noticed is that the menus don't display correctly.  
>>>>
>>>> Is anyone playing with this ?  Seeing that web2py uses bootstrap, it 
>>>> would be great to drop in a bootswatch theme.
>>>>
>>>>Title: {{=response.title or request.application}}






  



	
	
		
			

	
	
	

web2py™ 
{{='auth' in globals() and auth.navbar(separators=(' ',' | ',''))}}

	{{is_mobile=request.user_agent().is_mobile}}
	{{if response.menu:}}
	{{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}}
	{{pass}}

			
		
	

	{{=response.flash or ''}}

	
		
		
			
			
Share
			
			 
			

{{=response.title or request.application}}
{{=response.subtitle or ''}}

			
		

		
			
{{if left_sidebar_enabled:}}

  {{block left_sidebar}}
  Left Sidebar
  
  {{end}}

{{pass}}


  {{block center}}
  {{include}}
  {{end}}


{{if right_sidebar_enabled:}}

  {{block right_sidebar}}
  Right Sidebar
  
  {{end}}

{{pass}}
			
		

		
		
			{{block footer}} 
			
{{=T('Copyright')}} © 2011

	Powered by
	web2py

			
			{{end}}
		

	 

	
	
	

	
	{{if response.google_analytics_id:}} {{pass}}



.nav > li.dropdown > a:after {
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #00;
content: "";
display: inline-block;
height: 0;
opacity: 0.7;
vertical-align: top;
width: 0;

margin-left: 2px;
margin-top: 8px;

border-bottom-color: #FF;
border-top-color: #FF;
}


ul.dropdown-menu li.dropdown > a:after {
border-left: 4px solid #000;
border-right: 4px solid transparent;
border-bottom: 4px solid transparent;
border-top: 4px solid transparent;
content: "";
display: inline-block;
height: 0;
opacity: 0.7;
vertical-align: top;
width: 0;

margin-left: 8px;
margin-top: 6px;
}

ul.nav li.dropdown:hover ul.dropdown-menu {
   display: block;
}

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-05-26 Thread Paolo Caruccio
JS. After all, we are replacing superfish.

Il giorno domenica 27 maggio 2012 00:06:55 UTC+2, Massimo Di Pierro ha 
scritto:
>
> These no record boostrap and the new menu logic is staying in trunk. The 
> only issue is whether the weird menu structure should be generated by MENU 
> helper or by the JS in layout.html.
>
> On Saturday, 26 May 2012 12:33:52 UTC-5, Niphlod wrote:
>>
>> Until some time ago web2py mantained the "burden" of it's own template, 
>> it's own css, it's own javascript functions based on jquery.
>> I think I started using web2py when it contained only ez.css's classes.
>> Having to be a CSS/JS coder better than all peoples around the world can 
>> be hard ;-)
>>
>> Then superfish was added, css3 buttons were included, skeleton was 
>> adopted, grids can be serialized in a friendly jquery-ui style, etc. etc. 
>> etc. Let's be real: css frameworks and ui js are included in every 
>> application someone is starting coding out there. You're not forced to be 
>> an HTML guru to be a web programmer, and still have some nice user 
>> interface. 
>>
>> From where I am standing, both as a simple and a long time web2py user, 
>> I'm happy to "infiltrate" in all code that web2py generates and explore 
>> practically every flexibility it has to offer, but "sane defaults" are 
>> provided right now and maybe are ok for ultra-small apps. 
>>
>> Now, I'm not saying to follow every css and js library out there, but 
>> bootstrap is 160K of css (counting images and some nice js), largely 
>> adopted and very well supported, probably not going "under" within the 
>> year, mobile-friendly and in general easily understandable and to work with.
>>
>> web2py should leave defaults as always, but it's nice to see it "ready" 
>> to integrate with the major players out there.
>>
>> I think that a "style" argument can be added to every bit of code will 
>> need to change in the code regarding serialization without much problems. 
>> web2py 2.0 will be bootstrap-menu ready, if users want to start with 
>> welcome and edit that, it'll be ready. Maybe 2.1 will be bootstrap-forms 
>> ready, and so on...
>> Backward compatibility is not broken, old behaviour is maintained. If 
>> someone wants bootstrap's form he'll set a style parameter and voila.
>>
>> Il giorno sabato 26 maggio 2012 16:37:05 UTC+2, Massimo Di Pierro ha 
>> scritto:
>>>
>>> For now this is in trunk. Your implementation looks good.
>>>
>>> For me the problem whether we want to do this or not. Most of the 
>>> conventions implemented in web2py core are web2py own conventions or 
>>> standard protocol.  Bootstrap is a css library. very popular today but will 
>>> disappear tomorrow as a better one comes out. Now everybody will use it. Is 
>>> it a good idea to include code which is designed exclusively for bootstap 
>>> conventions and specifically refers to bootstrap css classes? Or is it 
>>> better to handle it from the layout only using js?
>>>
>>> So we need to think about this some more. I cannot promise this will 
>>> stay in web2py 2.0 in this form.
>>>
>>> Massimo
>>>
>>>
>
>>>

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-05-26 Thread Paolo Caruccio
Massimo,
from my point of view - a simple user - the web2py core must remain tied to 
its conventions and use standard protocols.
As you say, "bootstrap twitter" is one of the possible choices and then we 
will do? we will have so many switches as are the web frameworks?
For my little experience in web framework - above all those having 
javascript plugin - the html layout and css style are indispensable to each 
other.
We are discussing about the menu, but there are also the grids, forms and 
so on:should, therefore, change the code for sqlform.grid, 
sqlform.smartgrid, sqlform, or also apply a javascript function to fit this 
elements to the conventions of the preferred framework?
For me, the best choice is to have a "welcome app" as a basis for 
introducing own web2py features with its own css and layout 
and, if deemed appropriate, make an entry in the welcome app menu that link 
to different layouts inspired from several web framework (bootstrap, 
skeleton and so on) wich the user can choose to apply and adapt for his/her 
application.


Il giorno sabato 26 maggio 2012 16:37:05 UTC+2, Massimo Di Pierro ha 
scritto:
>
> For now this is in trunk. Your implementation looks good.
>
> For me the problem whether we want to do this or not. Most of the 
> conventions implemented in web2py core are web2py own conventions or 
> standard protocol.  Bootstrap is a css library. very popular today but will 
> disappear tomorrow as a better one comes out. Now everybody will use it. Is 
> it a good idea to include code which is designed exclusively for bootstap 
> conventions and specifically refers to bootstrap css classes? Or is it 
> better to handle it from the layout only using js?
>
> So we need to think about this some more. I cannot promise this will stay 
> in web2py 2.0 in this form.
>
> Massimo
>
>
>
> On Saturday, 26 May 2012 08:53:53 UTC-5, Paolo Caruccio wrote:
>>
>> Here attached the html.py with modified class MENU.
>> This is only a draft not deeply tested. 
>>
>> Il giorno sabato 26 maggio 2012 03:40:26 UTC+2, Massimo Di Pierro ha 
>> scritto:
>>>
>>> We can include this in MENU and eliminate the JS. What do you think?
>>>
>>> On Friday, 25 May 2012 15:52:50 UTC-5, Niphlod wrote:
>>>>
>>>> I may be a little lateI implemented it for my app but never used 
>>>> because my menu has only 4 items :-P
>>>> include bootstrap.css and add to css this (took from 
>>>> https://github.com/twitter/bootstrap/issues/424)
>>>>
>>>> .nav li.dropdown ul.dropdown-menu li:HOVER ul {
>>>> display:block;
>>>> position:absolute;
>>>> left:100%;
>>>> -webkit-border-radius: 3px;
>>>> -moz-border-radius: 3px;
>>>> border-radius: 3px;
>>>> }
>>>> .nav li.dropdown ul.dropdown-menu ul {
>>>> display: none;
>>>> float:right;
>>>> position: relative;
>>>> top: auto;
>>>> margin-top: -30px;
>>>> }
>>>>
>>>> .nav li.dropdown ul.dropdown-menu .dropdown-menu::before {
>>>> content: '';
>>>> display: inline-block;
>>>> border-top: 7px solid transparent;
>>>> border-bottom: 7px solid transparent;
>>>> border-right:7px solid #CCC;
>>>> border-right-color: rgba(0, 0, 0, 0.2);
>>>> position: absolute;
>>>> top: 9px;
>>>> left: -14px;
>>>> }
>>>>
>>>> .nav li.dropdown ul.dropdown-menu .dropdown-menu::after {
>>>> content: '';
>>>> display: inline-block;
>>>> border-top: 6px solid transparent;
>>>> border-bottom: 6px solid transparent;
>>>> border-right:6px solid white;
>>>> position: absolute;
>>>> top: 10px;
>>>> left: -12px;
>>>> }
>>>>
>>>>
>>>> def twitter_menu(menu, level=0):
>>>> """
>>>> Generates twitter bootstrap's compliant menu
>>>> """
>>>> lis = []
>>>> for li in menu:
>>>> (text, active, href) = li[:3]
>>>> sub =  len(li) > 3 and li[3] or []
>>>> if len(sub) == 0:
>>>> li_class = None
>>>> el = LI(A(text, _href=href), _class=li_class)
>>>> else:
>>>> li_class = 'dropdown'
>>>> caret = level == 0 and B(_class='caret') or 
>>>> I(_class='icon-chevron-right')
>>>> sub_ul = twitter_menu(sub, level=level+1)
>>>> el = LI(A(text, caret, _href=href, 
>>>> _class="dropdown-toggle", **{'_data-toggle' : 'dropdown'}), sub_ul, 
>>>> _class=li_class)
>>>> lis.append(el)
>>>>
>>>> if level == 0:
>>>> return UL(*lis, _class='nav')
>>>> else:
>>>> return UL(*lis, _class="dropdown-menu")
>>>>
>>>>

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-05-26 Thread Paolo Caruccio
Do you mean to add a new MENU attribute (i.e. 'bootstrap_menu') like 
'mobile' and to switch by menu types?
I think that's a good option.

Il giorno sabato 26 maggio 2012 03:40:26 UTC+2, Massimo Di Pierro ha 
scritto:
>
> We can include this in MENU and eliminate the JS. What do you think?
>
> On Friday, 25 May 2012 15:52:50 UTC-5, Niphlod wrote:
>>
>> I may be a little lateI implemented it for my app but never used 
>> because my menu has only 4 items :-P
>> include bootstrap.css and add to css this (took from 
>> https://github.com/twitter/bootstrap/issues/424)
>>
>> .nav li.dropdown ul.dropdown-menu li:HOVER ul {
>> display:block;
>> position:absolute;
>> left:100%;
>> -webkit-border-radius: 3px;
>> -moz-border-radius: 3px;
>> border-radius: 3px;
>> }
>> .nav li.dropdown ul.dropdown-menu ul {
>> display: none;
>> float:right;
>> position: relative;
>> top: auto;
>> margin-top: -30px;
>> }
>>
>> .nav li.dropdown ul.dropdown-menu .dropdown-menu::before {
>> content: '';
>> display: inline-block;
>> border-top: 7px solid transparent;
>> border-bottom: 7px solid transparent;
>> border-right:7px solid #CCC;
>> border-right-color: rgba(0, 0, 0, 0.2);
>> position: absolute;
>> top: 9px;
>> left: -14px;
>> }
>>
>> .nav li.dropdown ul.dropdown-menu .dropdown-menu::after {
>> content: '';
>> display: inline-block;
>> border-top: 6px solid transparent;
>> border-bottom: 6px solid transparent;
>> border-right:6px solid white;
>> position: absolute;
>> top: 10px;
>> left: -12px;
>> }
>>
>>
>> def twitter_menu(menu, level=0):
>> """
>> Generates twitter bootstrap's compliant menu
>> """
>> lis = []
>> for li in menu:
>> (text, active, href) = li[:3]
>> sub =  len(li) > 3 and li[3] or []
>> if len(sub) == 0:
>> li_class = None
>> el = LI(A(text, _href=href), _class=li_class)
>> else:
>> li_class = 'dropdown'
>> caret = level == 0 and B(_class='caret') or 
>> I(_class='icon-chevron-right')
>> sub_ul = twitter_menu(sub, level=level+1)
>> el = LI(A(text, caret, _href=href, _class="dropdown-toggle", 
>> **{'_data-toggle' : 'dropdown'}), sub_ul, _class=li_class)
>> lis.append(el)
>>
>> if level == 0:
>> return UL(*lis, _class='nav')
>> else:
>> return UL(*lis, _class="dropdown-menu")
>>
>>

[web2py] Re: Conditional represent

2012-05-19 Thread Paolo Caruccio
please try:

db.Register.repliedOn.represent = lambda v, row: v.strftime('%d/%m/%Y 
%H:%M:%S') if v else ""


Il giorno sabato 19 maggio 2012 09:00:37 UTC+2, Annet ha scritto:
>
> In a model I have the following validator:
>
> db.Register.repliedOn.requires=IS_EMPTY_OR(IS_DATETIME(format='%Y-%m-%d 
> %H:%M:%S'))
> db.Register.repliedOn.represent = lambda v, row: v.strftime('%d/%m/%Y 
> %H:%M:%S')
>
> When repliedOn is empty I get the following error:
>
> File 
> "/Library/Python/2.5/site-packages/web2py/applications/bootstrap/models/10_table_db.py"
>  , 
> line 389, in 
> db.Register.repliedOn.represent = lambda v, row: v.strftime('%d/%m/%Y 
> %H:%M:%S')
> AttributeError: 'NoneType' object has no attribute 'strftime'
>
>
> Is there a way to make represent conditional?
>
>
> Kind regards,
>
> Annet
>


Re: [web2py] Re: Multi computed fields

2012-05-17 Thread Paolo

This is perfect! Thank you very much Anthony.

Paolo

Il 17.05.2012 16:47 Anthony ha scritto:

def compute_geoCode(r, component):
 g = geocoders.Google()
 place, (lat, lng) = cache.ram(r.name, lambda: g.geocode(r.name [9]),
None)
 return eval(component)

Anthony

On Thursday, May 17, 2012 11:44:16 AM UTC-4, Gabriella Canavesi 
wrote:



Hi Anthony, thanks for the answer,
Your solution is pretty nice but I am still calling it 3 times which

actually is the main problem since I am asking 'google' 3 times the
same
stuff.
Is it possible to store the answer somewhere (cache?) the first time

and then use the cache copy for the latter calls?

Regards,
Paolo

Il 17.05.2012 15:09 Anthony ha scritto:

To get it down to it down to one function, how about:

def compute_geoCode(r, component):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [1] [4])
return eval(component)

db.cities.full_address.compute = lambda r: compute_geoCode(r,
'place')
db.cities.lat.compute = lambda r: compute_geoCode(r, 'lat')
db.cities.lgt.compute = lambda r: compute_geoCode(r, 'lng')

Anthony

On Thursday, May 17, 2012 4:35:46 AM UTC-4, Gabriella Canavesi

wrote:



Hi all,
I have a simple table with 3 computed fields, the function that

set

their values is almost the same. However, unfortunately I had to

set

up
three different functions because I didn't find a better

approach.

The code:
db.define_table('cities',
Field('name', 'string', requires=IS_TRIM()),
Field('full_address', 'string',requires=IS_TRIM()),
Field("lat", "double", label=T('Latitude')),
Field("lgt", "double", label=T('Longitude')))

db.cities.full_address.compute = compute_geoCode_place
db.cities.lat.compute = compute_geoCode_lat
db.cities.lgt.compute = compute_geoCode_lng

def compute_geoCode_place(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [2] [1])
return place

def compute_geoCode_lat(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [3] [2])
return lat

def compute_geoCode_lng(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [4] [3])
return lng

What I would like to find is a way to fire the execution of a
function
when the form is submitted. More or less something like a compute



action
at table level.

Regards,

--
Paolo



Links:
--
[1] http://r.name [5]
[2] http://r.name [6]
[3] http://r.name [7]
[4] http://r.name/ [8]


--
Paolo



Links:
--
[1] http://r.name
[2] http://r.name
[3] http://r.name
[4] http://r.name
[5] http://r.name
[6] http://r.name
[7] http://r.name
[8] http://r.name/
[9] http://r.name/


Re: [web2py] Re: Multi computed fields

2012-05-17 Thread Paolo

Hi Anthony, thanks for the answer,
Your solution is pretty nice but I am still calling it 3 times which 
actually is the main problem since I am asking 'google' 3 times the same 
stuff.
Is it possible to store the answer somewhere (cache?) the first time 
and then use the cache copy for the latter calls?


Regards,
Paolo

Il 17.05.2012 15:09 Anthony ha scritto:

To get it down to it down to one function, how about:

def compute_geoCode(r, component):
 g = geocoders.Google()
 place, (lat, lng) = g.geocode(r.name [4])
 return eval(component)

db.cities.full_address.compute = lambda r: compute_geoCode(r, 
'place')

db.cities.lat.compute = lambda r: compute_geoCode(r, 'lat')
db.cities.lgt.compute = lambda r: compute_geoCode(r, 'lng')

Anthony

On Thursday, May 17, 2012 4:35:46 AM UTC-4, Gabriella Canavesi wrote:


Hi all,
I have a simple table with 3 computed fields, the function that set
their values is almost the same. However, unfortunately I had to set
up
three different functions because I didn't find a better approach.
The code:
db.define_table('cities',
Field('name', 'string', requires=IS_TRIM()),
Field('full_address', 'string',requires=IS_TRIM()),
Field("lat", "double", label=T('Latitude')),
Field("lgt", "double", label=T('Longitude')))

db.cities.full_address.compute = compute_geoCode_place
db.cities.lat.compute = compute_geoCode_lat
db.cities.lgt.compute = compute_geoCode_lng

def compute_geoCode_place(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [1])
return place

def compute_geoCode_lat(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [2])
return lat

def compute_geoCode_lng(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [3])
return lng

What I would like to find is a way to fire the execution of a
function
when the form is submitted. More or less something like a compute
action
at table level.

Regards,

--
Paolo



Links:
--
[1] http://r.name
[2] http://r.name
[3] http://r.name
[4] http://r.name/


--
 Paolo


Re: [web2py] Re: Multi computed fields

2012-05-17 Thread Paolo

Hi Niphlod, thanks for your answer.
Actually, I am looking for something that I can put in my model without 
touch the code of the forms, e.g., I don't want to change the code of 
the admin application to solve the problem.


Paolo

Il 17.05.2012 13:14 Niphlod ha scritto:

The onsuccess parameter of form.process() seems to cover your
problems: from http://web2py.com/books/default/chapter/29/7
"""
onsuccess and onfailure can be functions like lambda form:
do_something(form)
"""

Il giorno giovedì 17 maggio 2012 10:35:46 UTC+2, Gabriella Canavesi
ha scritto:


Hi all,
I have a simple table with 3 computed fields, the function that set
their values is almost the same. However, unfortunately I had to set
up
three different functions because I didn't find a better approach.
The code:
db.define_table('cities',
Field('name', 'string', requires=IS_TRIM()),
Field('full_address', 'string',requires=IS_TRIM()),
Field("lat", "double", label=T('Latitude')),
Field("lgt", "double", label=T('Longitude')))

db.cities.full_address.compute = compute_geoCode_place
db.cities.lat.compute = compute_geoCode_lat
db.cities.lgt.compute = compute_geoCode_lng

def compute_geoCode_place(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [1])
return place

def compute_geoCode_lat(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [2])
return lat

def compute_geoCode_lng(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [3])
return lng

What I would like to find is a way to fire the execution of a
function
when the form is submitted. More or less something like a compute
action
at table level.

Regards,

--
Paolo



Links:
--
[1] http://r.name
[2] http://r.name
[3] http://r.name





[web2py] Multi computed fields

2012-05-17 Thread Paolo

Hi all,
I have a simple table with 3 computed fields, the function that set 
their values is almost the same. However, unfortunately I had to set up 
three different functions because I didn't find a better approach.

The code:
db.define_table('cities',
Field('name', 'string', requires=IS_TRIM()),
Field('full_address', 'string',requires=IS_TRIM()),
Field("lat", "double", label=T('Latitude')),
Field("lgt", "double", label=T('Longitude')))

db.cities.full_address.compute = compute_geoCode_place
db.cities.lat.compute = compute_geoCode_lat
db.cities.lgt.compute = compute_geoCode_lng

def compute_geoCode_place(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name)
return place

def compute_geoCode_lat(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name)
return lat

def compute_geoCode_lng(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name)
return lng

What I would like to find is a way to fire the execution of a function 
when the form is submitted. More or less something like a compute action 
at table level.


Regards,

--
 Paolo


[web2py] response.menu with bootstrap dropdown menu

2012-03-07 Thread Paolo

Hi all,
I have a simple problem that I haven't solved yet. Using the twitter 
bootstrap theme I am not able to create a dropdown menu playing with the 
MENU helper. According to [1], an anchor to create the dropdown menu 
needs the attributed data-toggle equal to "dropdown"; the problem is 
that I am not able to set up correctly response.menu in order to 
generate html code with that field inside. What I can do?

Best regards

--
 Paolo

[1] http://twitter.github.com/bootstrap/javascript.html#dropdowns


[web2py] Re: Problem with DB2 and text field type when accessing db2 using ODBC ...

2012-01-20 Thread Paolo Caruccio
I use pyodbc (http://code.google.com/p/pyodbc/) and my connection string is:

db = DAL('db2://DSN=MYDATABASE;UID=userid;PWD=password')

For other details you could read this thread 
https://groups.google.com/d/topic/web2py/HMVE9S2a6sQ/discussion


[web2py] Re: Problem with DB2 and text field type when accessing db2 using ODBC ...

2012-01-19 Thread Paolo Caruccio
On  windows7 I solved the issue by adding to db2cli.ini these rows (replace 
MYDATABASE and MYDATABASEALIAS with your data):

[MYDATABASE]
dbalias=MYDATABASEALIAS
LONGDATACOMPAT=1
LOBMAXCOLUMNSIZE=1048575

if you need more info about db2cli.ini go to this page
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.db2.luw.apdv.cli.doc%2Fdoc%2Fc0007882.html


[web2py] Re: redirecting python console output to web browser page

2012-01-02 Thread Paolo Caruccio
There is another HTML5 technology to push stream from server to client : 
EventSource aka Sent-Server Events (http://dev.w3.org/html5/eventsource/). 
Its behaviour is like ajax long polling.
I'm - just now - experimenting a simple mechanism to send to clients a 
message when the database changes.
Pros : The implementation is enough simple.
Cons : IE9 doesn't support EventSource.





[web2py] Re: small display problem when using wizard

2011-12-30 Thread Paolo Caruccio
fixed in trunk

http://code.google.com/p/web2py/source/detail?r=25d5f65ce920ed2c6089097122caa7ded3d63d8a
 


[web2py] Re: write view into an html file

2011-12-29 Thread Paolo Caruccio
The plugin has all needed libraries to work and not requires that you 
install others.

I used it in a my app and worked like a charm.

Give it a try.




[web2py] Re: write view into an html file

2011-12-28 Thread Paolo Caruccio
try the solution in this discussion 
https://groups.google.com/d/topic/web2py/GyQ8_szQFoI/discussion

Happy Holidays.




[web2py] Re: assigning class name to SQLform element parent gives error

2011-12-19 Thread Paolo Caruccio
ticket http://code.google.com/p/web2py/issues/detail?id=574 submitted


[web2py] Re: assigning class name to SQLform element parent gives error

2011-12-19 Thread Paolo Caruccio
no one else has encountered same problem?


[web2py] Re: deployment problem with mod_wsgi

2011-12-19 Thread Paolo Caruccio
Maybe this helps 

http://jdoe.asidev.com/2009/02/26/configure-web2py-to-run-behind-apache-with-wsgi-mod_wsgi/
 



[web2py] Re: assigning class name to SQLform element parent gives error

2011-12-18 Thread Paolo Caruccio
My fault.
I omitted to say that the error occurs after some options have been 
selected and form is submitted leaving empty the text input.

Thank you for your consideration.

Paolo


[web2py] assigning class name to SQLform element parent gives error

2011-12-18 Thread Paolo Caruccio
*Scenario*

1. #model db.py
db.define_table('specializzazioni',
Field('specializzazione', 
type='string',notnull=True,label=T('Specialization')),
format='%(specializzazione)s',
)

db.define_table('t_valutazione_risorsa',
Field('f_specializzazione',type='list:reference 
specializzazioni',notnull=True,label=T('Specialization')),

Field('f_valutazione_qualifica',type='string',notnull=True,label=T('Rating')),
)
db.t_valutazione_risorsa.f_specializzazione.requires = [IS_IN_DB(db, 
db.specializzazioni.id, db.specializzazioni._format, 
multiple=True),IS_NOT_EMPTY()]
db.t_valutazione_risorsa.f_specializzazione.widget = 
SQLFORM.widgets.multiple.widget

2. # controller default.py
def test():
form = SQLFORM(db.t_valutazione_risorsa)

if form.accepts(request, session):
response.flash = T('resource rating added')

if isinstance(form,FORM):
ms = form.element("select", _name='f_specializzazione')
ms["_class"]="chosen"
ms.parent["_class"]="multi"

return dict(form=form)

*Error traceback*

Traceback (most recent call last):
  File "M:\UniServer\www\web2py_trunk\gluon\restricted.py", line 204, in 
restricted
exec ccode in environment
  File "M:/UniServer/www/web2py_trunk/applications/test/controllers/default.py" 
, line 
85, in 
  File "M:\UniServer\www\web2py_trunk\gluon\globals.py", line 172, in 
self._caller = lambda f: f()
  File "M:/UniServer/www/web2py_trunk/applications/test/controllers/default.py" 
, line 
81, in test
ms.parent["_class"]="multi"
TypeError: 'NoneType' object does not support item assignment


Wondering why this happens?

Thank you for your reply.


Re: [web2py] 1.99.4 is OUT

2011-12-14 Thread Paolo Caruccio
I already wrote how i fixed the issue (tested only IE9, chrome 15, firefox 
8 and Opera 11.60 on windows7) in a previous thread (
https://groups.google.com/d/msg/web2py/AjoKneQCOEA/rFYgbg7GMLAJ).

to correct the ugly display I modified this file
admin\static\plugin_multiselect\jquery.multiselect.css
line 14 becomes
.ui-multiselect-checkboxes { position:relative /* fixes bug in IE6/7 */; 
overflow-y:scroll; margin-left:0; width:100%; }
line 16 becomes 
.ui-multiselect-checkboxes label input { position:relative; top:1px; 
right:2px; }

to make working uncheckall button I modified the file
admin\static\plugin_multiselect\jquery.multiselect.js
on line 21 replace toggleChecked func with
toggleChecked:function(b,c,d){(d&&d.length?d:k.find("input")).not(":disabled").attr("checked",c);r()}})

attached the fixed files.

Let me know if it works for you too.
Thanks.

.ui-multiselect { font-weight:normal !important; display:-moz-inline-block; display:inline-block; cursor:default; text-decoration:none !important; padding:0 }
.ui-multiselect input { float:left; padding:3px 0 3px 6px; margin:0; border:none !important /* important fixes bug when inside ui-widget-content */; cursor:default; background:transparent }
.ui-multiselect span { float:right; margin-top:-18px; }

.ui-multiselect-header { margin-bottom:3px; padding:3px 0 3px 6px }
.ui-multiselect-header ul { font-size:0.9em }
.ui-multiselect-header ul li { float:left; padding:0 10px 0 0 }
.ui-multiselect-header a { text-decoration:none }
.ui-multiselect-header a:hover { text-decoration:underline }
.ui-multiselect-header .ui-icon { float:left }
.ui-multiselect-header li.ui-multiselect-close { float:right; text-align:right; padding-right:0 }

.ui-multiselect-options { display:none; padding:3px; position:relative; z-index:1; background: white; border: 1px solid #66;}
.ui-multiselect-checkboxes { position:relative /* fixes bug in IE6/7 */; overflow-y:scroll; margin-left:0; width:100%; }
.ui-multiselect-checkboxes label { cursor:default; display:block; border:1px solid transparent; padding:3px }
.ui-multiselect-checkboxes label input { position:relative; top:1px; right:2px; }
.ui-multiselect-checkboxes li { clear:both; font-size:0.9em; padding-right:3px }
.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label { text-align:center; font-weight:bold; border-bottom:1px solid }
.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label a { display:block; padding:3px; margin:1px 0; text-decoration:none }

/* remove label borders in IE6 because IE6 does not support transparency */
* html .ui-multiselect-checkboxes label { border:none }

/* shadow effect */
.ui-multiselect-shadow { box-shadow:0 0 10px #777; -moz-box-shadow:0 0 10px #777; -webkit-box-shadow:0 0 10px #777; -ms-filter: "progid:DXImageTransform.Microsoft.Glow(color=#66,strength=3) progid:DXImageTransform.Microsoft.Shadow(color=#77,direction=135,strength=3)"; filter: progid:DXImageTransform.Microsoft.Glow(color=#66,strength=3) progid:DXImageTransform.Microsoft.Shadow(color=#77,direction=135,strength=3); }



jquery.multiselect.js
Description: JavaScript source


[web2py] Re: web2py 1.99.3 is OUT

2011-12-09 Thread Paolo Caruccio
I solved so:

admin\static\plugin_multiselect\jquery.multiselect.css
line 14 becomes
.ui-multiselect-checkboxes { position:relative /* fixes bug in IE6/7 */; 
overflow-y:scroll; margin-left:0; width:100%; }
line 16 becomes 
.ui-multiselect-checkboxes label input { position:relative; top:1px; 
right:2px; }

admin\static\plugin_multiselect\jquery.multiselect.js
on line 21 replace toggleChecked func with
toggleChecked:function(b,c,d){(d&&d.length?d:k.find("input")).not(":disabled").attr("checked",c);r()}})


[web2py] Re: new welcome app - need help with css

2011-11-11 Thread Paolo Caruccio
Anthony,

since IE (any version), in some circumstances, has a behavior different 
from other browsers, we need to detect it in css rules. So any solution is 
good.

Paolo


[web2py] Re: new welcome app - need help with css

2011-11-10 Thread Paolo Caruccio
Anthony,

I made some tests after your observations. (web2py Version 1.99.3 
(2011-11-08 22:28:53) dev last trunk)

What do you think about the following:

.web2py_console {position: relative;} /* for #w2p_query_panel positioning */
#web2py_keywords{margin:0 5px;min-width:390px;width:62%;}
#w2p_query_panel{width:99%;}
#w2p_query_panel input, #w2p_query_panel select{margin:2px 10px 2px 5px;}
#w2p_query_panel input[type="text"]{margin:0 5px 0 0;}
.ie9 #web2py_keywords:focus {border-color:#ccc;} /* fix to prevent border 
vanishing in ie9 */

Moreover I want suggest this change in layout.html:


  

Paolo



[web2py] Re: new welcome app - need help with css

2011-11-10 Thread Paolo Caruccio
Other css rules are related to the specific case and override the general 
css rules applied to web2py_grid.
But I'm agreed with you: the best solution is to give a class or an id to 
the container div.

Paolo


[web2py] Re: new welcome app - need help with css

2011-11-10 Thread Paolo Caruccio
We still need to identify the div container to prevent the CSS rules apply 
to generic tags (such as table and div).
In the case under discussion, I used div.columns because it already existed in 
the html layout.
I noticed that the table is inside another div generic. We could give a 
identities to it (eg"grid_container") and apply to this the css rules.
In other words, if you remove the .columns references it will still work but 
the css rules will also apply to all html table elements.

Paolo


[web2py] Re: new welcome app - need help with css

2011-11-10 Thread Paolo Caruccio
Anthony you're right. the class .columns is Skeleton.
I repeated the case indicated by Massimo without modify other than 
static/css/ 
web2py.css (the html code is generated automatically from web2py).
The ugly layout depended on the width of the table (containing web2py_grid) 
inserted in div.columns. 
So I  adjusted the width of the table to that of  its container (
div.columns).
To avoid misunderstandings I used the selector .columns in css rules.

Paolo


[web2py] Re: new welcome app - need help with css

2011-11-09 Thread Paolo Caruccio
Please try this for problem #2 (tested on windows7 IE9, 
Chrome 15.0.874.106, FF8.0, Opera 11.52, web2py 1.99.3 <2011-11-08 
22:28:53> dev) 

.web2py_console {position: relative;} 
.columns table{width:100%;}
.columns table td:last-child{width:100%;}
.columns table input#web2py_keywords{display:inline;margin:0 
5px;width:350px;}
.columns table #w2p_query_panel 
{left:0;height:26px;bottom:-4px;min-width:539px;}
.columns table #w2p_query_panel input, .columns table #w2p_query_panel 
select{margin:2px 10px 2px 5px;}
.columns table #w2p_query_panel input[type="text"]{margin:-2px 5px 0 0;}

Paolo


[web2py] Re: Windows + Apache + mod_proxy

2011-11-08 Thread Paolo Caruccio
Omi,

please try the following:

in vhost_web2py.conf replace
 

ServerName ochiba-183

with

ServerName ochiba-183

where LIP is the server's IP

See for reference my previous post (STEP D)

Let me know if it works.

Paolo

P.S. Moreover what do you think about to change the thread title  to Windows 
+ Apache + mod_wsgi ?

 


[web2py] Re: Windows7 python2.7 SQLite web2py

2011-11-02 Thread Paolo Caruccio
Can you provide a packed .w2p web2py application?

Paolo


[web2py] Re: Windows7 python2.7 SQLite web2py

2011-11-02 Thread Paolo Caruccio
I also have no problem.
Windows 7 64bit
Python 2.7 32 bit (64-bit version gave me problems)
Pywin 32-bit

Paolo


Re: [web2py] Suggestions for multiple files upload in form

2011-10-29 Thread Paolo Caruccio
Bruno,

thanks.

What do you think about the upload mechanism? Can it be translate in a 
web2py widget? or is it better to use a different javascript/jquery library?

Regards.

Paolo


Re: [web2py] Suggestions for multiple files upload in form

2011-10-28 Thread Paolo Caruccio
Ovidio thank you for your consideration.

In fact, I have not given much attention to the results grid because the 
goal of my work was to create a control for uploading multiple files.
In addition, the visual aspect is only demonstration. The essential css 
rules are on the top of multiuploads.css (before /* CUSTOMIZATION */ 
comment).
However, I am preparing a packed .w2p web2py small application as required 
by Bruno.
Maybe, there you will see something nicer.

Ciao.

Paolo


[web2py] Suggestions for multiple files upload in form

2011-10-27 Thread Paolo Caruccio
I wasn't able to find in the web, even in this group, a multiple files 
upload system with the followings requirements:

- upload the files together with form submit
- no frame, no flash, no ajax form submit but only jquery and python
- give a title to the uploading files
- simple to integrate and control in web2py 

so, inspired by 
http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/,
 
I wrote one by my self.
It's minimalist and the code isn't optimized (I'm not a programmer), but it 
works for my purposes.

If you would like to test it in default welcome web2py app:
 - put jquery.multiuploads.js in static/js folder
 - put multiuploads.css in static/css folder
 - append the functions to default.py in controllers folder
 - append the table definition to db.py in models folder
 - put upload_documents.html in views folder

You'll find some comments in the code and also many errors.

I look forward to your suggestions and opinions.

Ciao.

Paolo
{{response.files.extend([URL('static','css/multiuploads.css'),URL('static','js/jquery.multiuploads.js')])}}
{{extend 'layout.html'}}

{{=form}}




jquery.multiuploads.js
Description: JavaScript source
/* CAUTION: essential rules don't remove */
div.multiupload_widget 
{
	display:inline-block; /* fix the div.error issue */
}

ul.mw_list
{
	display:block;
}

input.mw_fileTitle
{
	float:left;
}

div.mw_fileBrowserWrapper
{
	float:left;
}

a.mw_addBtn
{
	display:block;
	position:relative;
	overflow:hidden;
	max-width:70px;
	min-height:22px;
	text-align:center;
	margin-right:2px;
}

a.mw_clearBtn
{
	float:left;
	max-width:70px;
	min-height:22px;
	text-align:center;
	margin-left:2px;
}

a.mw_delItem
{
	display:block;
	float:right;
}

ul.mw_list ul
{
	width:90%; /* to avoid elastic when we slide it */
}
li.mw_group
{
	cursor:pointer;
}

/* CUSTOMIZATION */

div.multiupload_widget
{
width:280px;
margin: 2px 15px 2px 5px;
padding:0 1px;
}

ul.mw_list
{
margin:0 0 4px 0;
padding:0;
min-height:32px;
border:1px solid #e1e1e1;
border-radius:2px;
overflow:auto;
list-style:none;
}

ul.mw_list>li
{
font-weight:bold;
display:block;
margin:2px 0;
}

ul.mw_list li:hover
{
background-color:lightyellow;
}

ul.mw_list ul
{
list-style:none;
margin-top:2px;
margin-left:22px;
width:256px; /*div.multiupload_widget - (margin-left + 2*(border width)) => 280-(22+2) */
}

ul.mw_list ul li
{
font-weight:normal;
}

ul.mw_list span
{
word-wrap:break-word;
display:inline-block;
width:80%;
margin:0 0 0 10px;
}

li.mw_group
{

}

li.mw_group span
{

}

div.mw_bar{}

input[type="text"].mw_fileTitle
{
width:69%;
padding-left:3px;
}

div.mw_fileBrowserWrapper{}

a.mw_addBtn, a.mw_clearBtn
{
width:24px;
height:22px;
background:#EAEAEA;
border:1px solid #DEDEDE;
border-radius:2px;
margin:0 2px 0 2px;
font-size:16px;
font-weight:bold;
line-height:22px;
}

a.mw_addBtn
{
line-height:24px;
}

a.mw_addBtn:hover, a.mw_clearBtn:hover
{
text-decoration:none;
}

a.mw_addBtn > span {}
a.mw_clearBtn > span {}

a.mw_delItem
{
width:16px;
height:16px;
background-color:silver;
color:white;
font-weight:bold;
border-radius:10px;
text-align:center;
font-size:13px;
line-height:13px;
text-decoration:none;
margin:2px 4px 0 0;
}

a.mw_delItem:hover
{
text-decoration:none;
color:#275B90;
background-color:#aaa;
}

/*--*/
/* FILE ICON - based on http://nicolasgallagher.com/pure-css-gui-icons/
/*--*/

ul.mw_list i
{
display: block;
float: left;
width: 12px;
height: 17px;
background: #eee;
margin-left: 4px;
margin-top: 2px;
position: relative;
}

ul.mw_list b
{
	z-index:1;
	overflow:hidden;
	padding:0;
}

ul.mw_list b em
{
	border-bottom: 1px solid #275B90;
	color: #275B90;
	display: block;
}

ul.mw_list b em::before, ul.mw_list b em::after
{
margin: -8px 0 0;
background: #275B90;
}

ul.mw_list b em::before
{
left: 5px;
width: 8px;
height: 12px;
border: 2px solid #275B90;
background: transparent;
}

ul.mw_list b em::after
{
left: 4px;
border-width: 3px;
border-style: solid;
border-color: white #275B90 #275B90 white;
margin-top: -9px;
background: transparent;
}

ul.mw_list b::before, ul.mw_list b::after, ul.mw_list b em::before, ul.mw_list b em::after 
{
	content:"";
	position:absolute;
	top:50%;
	left:0;
}

/*--*/def check(form):
# check if file list is empty. We, indeed, set notnull=False for f_document Field 
for var in request.vars:
if var.startswith('f_document') and request.vars[var] != '': return
form.errors.f_document = T("file list is empty")


def upload_documents():
# only SQLFORM.factory tested
form=SQLFORM.factory(db.t_documents)

if form.accepts(request, session, 

[web2py] Re: AppReport using web2py view.

2011-10-27 Thread Paolo Caruccio
I have done it this way (code abstract not tested):

### model

db.define_table('t_persons',
Field('f_surname', type='string', notnull=True, label=T('Surname'), 
length=32),
Field('f_name', type='string', notnull=True, label=T('Name'), length=32),
)

### controller

def myreport():
persons = db(db.t_persons.id > 0).select()
logourl = URL('static','images/mylogo.jpg',host=True)
html = response.render('resources/myreport.html', dict(persons = persons, 
tdy=date.today(), logo=logourl))
return plugin_appreport.REPORTPISA(html = html)

### view myreport.html





@page {
margin: 1cm;
margin-bottom:2.5cm;
@frame footer {
-pdf-frame-content: footerContent;
/*-pdf-frame-border: 1;*/
bottom: 0cm;
margin-left: 1cm;
margin-right: 1cm;
height: 1cm;
}
}
h2 {font-width:bold;text-align:center;}
tr td{}
.section{border:1px solid #000;font-weight:bold;padding:4px 6px 0;}
.label{width:45%;}
.data{width:54%;}




Titolo
 


 
 
 



{{for p in persons:}}

 


SECTION TITLE
 


 


Surname
{{=p.f_surname}}
 


Given Name
{{=p.f_name}}
 

{{pass}}



page # printed on {{=tdy}}



### in view print_report.html

{{=A(SPAN(T('print report'), _class='printer_ico'), _href=URL('myreport'), 
_class="button")}}


Let me know if this works.

Ciao,

Paolo


[web2py] Re: From html view to pdf.

2011-10-25 Thread Paolo Caruccio
I used succesfully web2py-appreport.

https://github.com/lucasdavila/web2py-appreport

Ciao.

Paolo


[web2py] Re: Menus and Selected Tab

2011-10-18 Thread Paolo Caruccio
Richard,

could you post not working code sample?

Ciao.

Paolo


[web2py] Re: Menus and Selected Tab

2011-10-17 Thread Paolo Caruccio
If you're using respone.menu to build your menu and in line with 
http://www.web2py.com/book/default/search?search=response.menu
you could replace the second item (the boolean value)in the tuple with the 
check (request.function=='index') where index is your active page.
In this way web2py automatically add to li tag (your menu tab) the 
class="web2py-menu-active". So in .css file you can customize it.

For example (I'm using default w2p application "welcome"):

### in menu.py (welcome app models folder) ###

response.menu = [
(T('Home'), False, URL('default','index'), [])
]

becomes

response.menu = [
(T('Home'), (request.function=='index'), URL('default','index'), [])
]

### in layout.html (welcome app views folder ###

change this

{{=MENU(response.menu,_class='sf-menu')}}

to 

{{=MENU(response.menu,_class='sf-menu',li_active="tab_highlighted")}}

li_active allows to change default class "web2py-menu-active" to your 
preference. In the above example "tab_highlighted".

### in base.css (welcome app static/css subfolder) 

append the css rule

.web2py-menu-active a, .tab_highlighted a{color:red}

Ciao.

Paolo


[web2py] Re: Windows + Apache + mod_proxy

2011-10-12 Thread Paolo Caruccio
Well done!

Paolo


[web2py] Re: Display "Loading' animated gif or js : How to

2011-10-12 Thread Paolo Caruccio
Hi Vineet,

as juanduke has suggested, I use the following jquery function (I put it in 
web2py_ayax.js) instead of standard w2p ajax function to show a loading 
image:

function web2py_polling(u,s,t){
$('#'+t).html('');
ajax(u,s,t);
}

Of course you can set some css rules to custom div#loading_gif_container.

How to use:
I insert at the bottom of the view :


//<!--
jQuery(document).ready(function(){
web2py_polling('get_output',[args],'output_target');
//-->


### controller ###

def get_output():
the_output = "I'm the output"
return the_output


You could also use a standard ajax call to a function that returns 
web2py_polling function that, optionally, calls another action.

For example:

### in the view ###


//<!--
jQuery(document).ready(function(){
ajax('get_output',[args],':eval');
//-->


### controller ###

def get_output():
# make evaluation 
return "web2py_polling('another_action',[args],'output_target');"

def another_action():
the_output = "I'm the output"
return the_output


Ciao.

Paolo


Re: [web2py] Re: new feature - need help

2011-10-11 Thread Paolo Caruccio
Richard, thank you.

[web2py] Re: new feature - need help

2011-10-10 Thread Paolo Caruccio
The result is splendid with your changes.
I want only suggest to replace the row # 1344 in /gluon/sqlhtml.py with this

jQuery('#w2p_query_fields').val('').change();

so the change event is fired and when you query again the .w2p_query_row is 
hidden.

Ciao.

Paolo


[web2py] Re: Windows + Apache + mod_proxy

2011-10-10 Thread Paolo Caruccio
I am very glad I helped

Ciao.

Paolo


[web2py] Re: Windows + Apache + mod_proxy

2011-10-10 Thread Paolo Caruccio
Hi Omi,

>I wasn't sure this part, so I just add "127.0.0.1 ochiba-183" to my hosts.

Try to replace with "10.30.6.122 ochiba-183"

Let me know if it works.

Ciao.

Paolo


[web2py] Re: new feature - need help

2011-10-09 Thread Paolo Caruccio
I'm glad you like it, but it is necessary to point out that the css rules 
must be adapted to single layout. Especially with regard to positioning. As 
you can see from the picture, I used as a reference the layout of your 
application 
"issue tracker".

Ciao.

Paolo


[web2py] Re: Windows + Apache + mod_proxy

2011-10-09 Thread Paolo Caruccio
My enviroment
windows7 64 bit
Apache/2.2.21 (Win32) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0e mod_wsgi/3.3
Python/2.7.2 PHP/5.3.8
pywin32-216.win32-py2.7
pyodbc-2.1.11.win32-py2.7
web2py 1.99.2 stable
db2exc_974_WIN_x86_64 - IBM DB2 Express-C

httpd.conf is the same as that one comes with uniform server, I only
added to it two rows:
# to load mod_wsgi
LoadModule wsgi_module modules/mod_wsgi.so
# vhost_web2py is a separated file (see my previous message for its
content)
Include conf/vhost_web2py.conf

so it's simple compare it with your, downloading uniform server (that
is portable and install less)

Regarding db2 driver after I installed IBM DB2 Express-C I made the
following steps:

1) in db2 control center I created a new empty database and named it
"TEST" alias "TEST"
2) activated IBM DB2 ODBC DRIVER :
2a) in win7 control panel > administrative tools > Data Sources
(ODBC)
2b) in opened window > tab "User DSN" > "Add" button
2c) in new popup window select "IBM DB2 ODBC DRIVER" > "End" button
2d) in next window
2d1) Data Name Source = "TEST"
2d2) Database alias = "TEST"
2d3) Pressed OK button

In web2py I created a new simple application and connected to database
through the string:

db = DAL('db2://DSN=TEST;UID=userid;PWD=password')

where userid and password are the same as accessing to IBM DB2 Express-
C.

At the end I succesfully registered a new user, so all worked fine for
me.

Ciao.
Paolo

On 7 Ott, 21:31, Omi Chiba  wrote:
> Paolo,
>
> You gave me a hope because it looks you tried it recently and it's
> very similar to my environment. (Is your OS Windows 7, XP, or Windows
> Server ??)
>
> My environment:
> OS: Windows 7 SP1 - 32bit
> Python: 2.7.2
> Apache: httpd-2.2.21-win32-x86-openssl-0.9.8r.msi
> mod_wsgi: mod_wsgi-win32-ap22py27-3.3.so
> pyodbc: pyodbc-2.1.11.win32-py2.7.exe
> pywin32: pywin32-216.win32-py2.7.exe
>
> I was keep thinking what makes the difference. I know you use Uniform
> Server but
> the version of apache included is the same as mine. So it should be
> the same.
>
> Only possible difference is an apache config, The below is the part of
> httpd.conf  let me know if you find anything wrong. It's running fine
> except pyodbc cannot make connection to mssql/db2 under wsgi but it
> does connect under Rocket server and console.
>
> =
> NameVirtualHost *:80
> 
>   DocumentRoot "C:/web2py/applications"
>   ServerName ochba-183
>
>   
>     Order allow,deny
>     Deny from all
>   
>
>   
>     Order deny,allow
>     Allow from all
>   
>
>   
>     Order Allow,Deny
>     Allow from all
>   
>
>   WSGIScriptAlias / "C:/web2py/wsgihandler.py"
>
> 
>
> NameVirtualHost *:443
> 
>   DocumentRoot "C:/web2py/applications"
>   ServerName ochiba-183
>
>   
>     Order allow,deny
>     Deny from all
>   
>
>   
>     Order deny,allow
>     Allow from all
>   
>
>   
>     Order Allow,Deny
>     Allow from all
>   
>
>   WSGIScriptAlias / "C:/web2py/wsgihandler.py"
>
>   SSLEngine On
>   SSLCertificateFile conf/server.crt
>   SSLCertificateKeyFile conf/server.key
>
> 
> 
> On Oct 6, 6:47 pm, Paolo Caruccio  wrote:
>
>
>
>
>
>
>
> > The following istructions have been adapted 
> > fromhttp://jdoe.asidev.com/2009/02/26/configure-web2py-to-run-behind-apac...
> > for my dev enviroment Windows + Apache + mod_wsgi.
> > I  succesfully tested connection to db2 express from IMB through
> > pyodbc. Maybe it could help you.
> > I premise that I'm not a programmer and computer development is an
> > hobby for me, so my support will be very poor.
> > Below enviroment has been used for development only, not in
> > production.
>
> > PREREQUISITES: python 2.7 installed on Windows
>
> > STEP A - webserver preparation [http://sourceforge.net/projects/
> > miniserver/files/Uniform%20Server/7.1.11-Orion/]
> > a1 - download and install uniformserver;
> > a2 - after installation, access to the server administrator panel and
> > "SECURE" all entries in the "Server Security" page;
> > a3 - generate a new SSL certificate by "Tools > Server Key & Cert Gen"
> > link on right sidebar;
> > a4 - create a certificate signed by our CA using UniServer_CA_1.0
> > plugin [http://sourceforge.net/projects/miniserver/files/Plugins/
> > UniServer_CA/];
> > a5 - replace the files created in t

[web2py] Re: Windows + Apache + mod_proxy

2011-10-06 Thread Paolo Caruccio
The following istructions have been adapted from
http://jdoe.asidev.com/2009/02/26/configure-web2py-to-run-behind-apache-with-wsgi-mod_wsgi/
for my dev enviroment Windows + Apache + mod_wsgi.
I  succesfully tested connection to db2 express from IMB through
pyodbc. Maybe it could help you.
I premise that I'm not a programmer and computer development is an
hobby for me, so my support will be very poor.
Below enviroment has been used for development only, not in
production.

PREREQUISITES: python 2.7 installed on Windows

STEP A - webserver preparation [http://sourceforge.net/projects/
miniserver/files/Uniform%20Server/7.1.11-Orion/]
a1 - download and install uniformserver;
a2 - after installation, access to the server administrator panel and
"SECURE" all entries in the "Server Security" page;
a3 - generate a new SSL certificate by "Tools > Server Key & Cert Gen"
link on right sidebar;
a4 - create a certificate signed by our CA using UniServer_CA_1.0
plugin [http://sourceforge.net/projects/miniserver/files/Plugins/
UniServer_CA/];
a5 - replace the files created in the a3 step in X:\UniServer\usr\local
\apache2\conf folder ( X is the drive where uniformserver has been
installed );
a6 - install new certificate in Trusted Certification Authorities.
Usually I put ca.crt file in main folder of my website, start the
server, and by browser go to http://localhost/ca.crt
 ( replace localhost with website name to simulate real situation )
and install the certificate following browser instructions;
a7 - start the server and check that https pages are accessible
without certificate errors.
Notes: when upgrade the server simply copy in their folders on the new
server the SSL files created in the previous version of the server

STEP B - mod_wsgi [http://code.google.com/p/modwsgi/wiki/
DownloadTheSoftware?tm=2]
b1 - download Windows binary selecting the correct one for the version
of Python and Apache that is being used ( I use mod_wsgi-win32-
ap22py27-3.3.so - Apache 2.2 / Python 2.7 );
b2 - stop UniServer, rename downloaded file in "mod_wsgi.so" and put
it in X:\UniServer\usr\local\apache2\modules folder ( X is the drive
where uniformserver has been installed );
b3 - add to X:\UniServer\usr\local\apache2\conf\httpd.conf file
following row: "LoadModule wsgi_module modules/mod_wsgi.so"( without
quotation marks );
b4 - restart UniServer and check that mod_wsgi is succesfully
installed.
Notes: when upgrade the server repeat the step B

STEP C - web2py (for sure you know where download it)
c1 - download web2py source code and unzip it in X:\UniServer\www
folder ( X is the drive where uniformserver has been installed );
c2 - stop UniServer, start web2py server in standard way by double
clicking X:\UniServer\www\web2py\web2py.py in order that it create its
own files (don't change default settings);
c3 - stop web2py server and check that in web2py folder there are
"options_std.py" e "parameters_8000.py";
c4 - open options_std.py and make sure of row "password = ''"
is present;
c5 - create following symlinks (only in windows7 by "mklink" command
or using "Symlink Creator" [http://code.google.com/p/symlinker/
downloads/list]):
 1) options_std.py -> options.py
 2) parameters_8000.py -> parameters_80.py
 3) parameters_8000.py -> parameters_443.py
Notes: in windowsXP copy files listed above on the left and rename
them with the names on the right.
   When upgrade web2py, rename or delete previous web2py folder, but
in the latter case make sure of backup your web2py apps.

STEP D - apache vhost file
d1 - stop UniServer, create a new "vhost_web2py.conf" file in X:
\UniServer\usr\local\apache2\conf folder ( X is the drive where
uniformserver has been installed ) with following content :

##VIRTUAL HOST SETUP##
# WEB2PY.LOCALHOST

ServerName SVN:80
DocumentRoot DIR/www/web2py
WSGIScriptAlias / DIR/www/web2py/wsgihandler.py
ServerAdmin EMAIL
# static files do not need WSGI

Order Allow,Deny
Allow from all

# everything else goes to web2py via wsgi

Order deny,allow
Allow from all

# Log. Can be disabled
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogLevel notice
CustomLog DIR/tmp/web2py.access.log common
ErrorLog DIR/tmp/web2py.error.log


#

ServerName SVN:4

Re: [web2py] Re: chrome beta admin problem

2011-03-16 Thread Paolo Comitini
Hi Massimo,

the problem is moderinizr 1.6
upgrade to 1.7 or don't use it  ;-)

Latest release:1.7
February 20: Version 1.7 nerfs the WebGL/Chrome9 issue, Opera color
input fix, faster (no release notes yet).

Paolo


2011/3/16 Ross Peoples 
>
> I have been running Chrome dev channel (11.0.696.3) for a while and never had 
> this problem. Chrome does sometimes have a problem pulling data from its own 
> cache. Try emptying the cache on it, close, and reopen to see if that solves 
> it. Otherwise, you might have to manually delete Chrome's cache database.


[web2py] Re: chrome beta admin problem

2011-03-16 Thread Paolo Comitini
Hi Massimo,

the problem is modernizr-1.6.min.js,

upgrade to modernizr 1.7


Latest release: 1.7
February 20: Version 1.7 nerfs the WebGL/Chrome9 issue, Opera color
input fix, faster (no release notes yet).

or dont'use modernizr.

Paolo

On Mar 16, 4:33 pm, Massimo Di Pierro 
wrote:
> I am using chrome 10.0.648.134 beta and I ma having navigation
> problems with admin. For example I login in admin and it freezes the
> page until I click reload.
>
> I do not have the problem with other browsers.
>
> Has anybody experienced similar problem with chorme beta or other
> browsers?
>
> Massimo


<    2   3   4   5   6   7