Re: [web2py] Apostrophe's disapperaing

2013-12-13 Thread peter
Thank you Jonathon for taking the time to make two good suggestions. The 
first did not get the apostrophes to appear. WRT the second, one can only 
control the encoding of Word when outputting txt files.

I have now created a work around, a bit ugly but the best I can achieve for 
the moment.

smart apostrophes should be *#8217 *for html. So I use textpad and replace 
all smart apostrophe's with  *#8217.  *I have to do this twice, once for 
the left leaning apostrophe and once for the right leaning one.

This is not a nice solution but it does work.

Peter

On Friday, 13 December 2013 02:20:31 UTC, Jonathan Lundell wrote:

 On 12 Dec 2013, at 6:12 PM, Jonathan Lundell jlun...@pobox.comjavascript: 
 wrote:

 On 12 Dec 2013, at 4:16 PM, peter peterchu...@gmail.com javascript: 
 wrote:

 I have a word document that I output as a .'.mht; file  ie, a 'single file 
 web page'.

 I can put sections of this into a string field in a database and then 
 display the field through a view, and the formatting in the word document 
 is preserved. 

 here is a line from the file that I read into web2py and insert into a 
 field in a database.

 p class=3DStyle7 
 style=3D'line-height:11.5pt;mso-line-height-rule:exactly'span 
 lang=3DEN-US style=3D'font-family:Adobe 
 Garamond,serif;mso-bidi-font-family: Adobe Garamond'‘One Lettuce Does 
 Not a Salad Make’ is similar to Jones’ story  ...


 Everything works fine except the apostrophes in the text disappear.

 When I display the field on the screen, there are no apostrophes. I f I 
 'view source', it is as above, but without the apostrophe's before One, 
 after Make and after Jones.

 Clearly this is an encoding problem. If I read the .mht file into textpad, 
 the apostrophe's appear, and textpad says the file is 'ANSI'. The question 
 is how do I read the file in such as way as to correctly encode the 
 apostrophes?

 I have tried various encodings including 'locale.getpreferredencoding()'.


 Does anyone know how to solve this problem


 Your email headers suggest that the string (at least in the email) is 
 encoded as windows-1252.

 So if s is your encoded string, you might try 
 s.decode('cp1252').encode('utf8'). Assuming that UTF-8 is OK for output.



 Alternatively, you might try to persuade Word to emit UTF-8 directly. This 
 might help: 
 http://office.microsoft.com/en-us/outlook-help/choose-text-encoding-when-you-open-and-save-files-HA010121249.aspx


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Can't edit default.py after upgrade to 2.8.2

2013-12-13 Thread Paolo Valleri
Please, let us know what you have changed in the last days, if today 
nothing work and in the early days only default.py.
@devs we should try to update response.static_version for each new major 
release at least.

Paolo

On Friday, December 13, 2013 10:27:04 AM UTC+1, Richard Brown wrote:


 Another update... today I cannot open *any* files for Editing- including 
 views - in either Chrome, IE or Torch. And on another PC.

 All files can be opened for viewing.

 I have attached the output from Inspect Element and the Debugger as I load 
 the page.

 Help!






-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] count amount of times a field is present in selection and fetch a record for each

2013-12-13 Thread Ivo
I have a list containing record id's and need to select those records from 
a table. then I need to count how many different values are contained in 
the fields and for each select the first record of an other table.

ids = session.people.keys()
persons = {}

for id in ids: persons[id]=db(db.people.id==id).select()[0]

the rows contain a field user_name
now I want to check(count) how many different user_name's are in my 
selected records.
(and retrieve the first record, with a bool set to False, from db.parking 
for each. 
db.parking records contain a bool which I want to toggle to true)

can someone help me (with at least the counting part)?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: list:reference painfull to fill

2013-12-13 Thread Kevin Bethke
thanks but to be honest now I'm even more confused.
why do you need a piece of jquery code in a javascript variable. I sopose
you included the entire jquery library.
Why do you do the ordering with javascript and not with python is there a
special reason for this? I think I just explained the last question  by
looking at the code again. The document ready function is executed every
time you add or remove an element from the list?
the javascript variable ordered_values=%s is filled from the represent
python variable?
And my last question do you implement the multiple select into a form?
Sry for all those questions but I'm still learning and the need for this to
work really pushes my skills and knowledge beyond its limits.


On Thu, Dec 12, 2013 at 3:49 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 It's a bit hacky but it works...

 :)

 Richard


 On Thu, Dec 12, 2013 at 9:48 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Don't bother with the php thing...

 Just look the data structure of the select...

 Here what I do to restore proper order on update form :

 controller_view_js += 
 var ordered_values = ''%s'';
 $(document).ready(function() {
 if(ordered_values != None) {
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]).append(option
 value=\'+ordered_values[i]+\'+
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).text()+/option);
 });
 $(select[name=field_name] option:selected).remove();
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).attr(selected, selected);
 });
 };
 }); % [int(ID) for ID in ordered_values_query]

 controller_view_js is a variable containing a piece of jquery that I pass
 to the view from the controller... What it does put the options into the
 proper order or how they were ordered at the input... All this is because
 web2py don't use ol list out of the box... So I manage thing to not
 require ol.

 The ordered_values_query contain the value of the field field_name for
 the given record...

 I had to set a representation like this too :

 represent=lambda values, row: ', '.join(map(lambda id:
 db.ref_referenced_table(id).represent_field, values)) if values != [] or
 None else T('N/A')

 Hope it helps.

 Richard


 On Thu, Dec 12, 2013 at 4:07 AM, BlueShadow kevin.bet...@gmail.comwrote:

 thanks for your offer I'm working my way through the example code but my
 biggest problem is that php site. I don't know php. But from what I get
 from the php code is that all the sample cities need to be in an unordered
 list environment ulli/li.../ul
 but this form part of the bsmselect example really confuses me.

 h1Example 1: Typical Usage/h1

 form action=./example_results.php method=post


 label for=cities1What are your favorite cities?/label

 select id=cities1 multiple=multiple name=cities[] title=Click 
 to Select a City class=sminit

   optionAmsterdam/option

 /select
 pinput type=submit name=submit value=submit //p

   /form


 especially the php file in form action=
 ?php

 if(!empty($_POST['submit'])) {

   echo html\nbody style='width: 400px; margin: 2em auto;
 font-family: Arial;';

   if(!empty($_POST['cities'])) {

 echo \npstrongYou selected the following
 cities:/strong/p\nul;

 foreach($_POST['cities'] as $city) {

   // exclude any items with chars we don't want, just in case
 someone is playing
   if(!preg_match('/^[-A-Z0-9\., ]+$/iD', $city)) continue;

   // print the city
   echo \n\tli . htmlspecialchars($city) . /li;
 }

 echo \n/ul;

   } else {
 echo \npNo items selected/p;
   }

   echo \npa href='index.html'Try Again?/a/p;

   echo \n/body\n/html;

 } else {
   // if someone arrived here not having started at example.html
   // then show example.html instead
   require(index.html);

 }


 It seems to me that there is an entire html document in this php file.

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google
 Groups web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/3HTTdoGnCAA/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 

[web2py] Customization of the SQLFORM in html

2013-12-13 Thread curly
Hello!

I'm new to web2py and have just started running web2py 2.8.1 in ubuntu 
12.04.

I am trying to customize the style of SQLFORM in web2py views. Tried to do 
this using SQLFORM in HTML. What I have is:-

model:
db.define_table(
register,
Field('pi_id',db.pi),
Field('name',requires=[IS_NOT_EMPTY(), IS_ALPHANUMERIC()]),
Field('grp_name'),
Field('req_date','date', requires = IS_DATE(format=('%d-%m-%Y'))),
Field('email',requires=[IS_EMAIL()]))
db.register.grp_name.widget = SQLFORM.widgets.autocomplete(
 request, db.pi.name, limitby=(0,10), min_length=1)

controller:
def display_your_form():
form = 
SQLFORM(db.register,fields=['name','grp_name','req_date','email'])
if form.process(session=None,formname=test).accepted:
response.flash = 'Reg saved.'
redirect(URL('samples', 'default', 'index'))
elif form.errors:
response.flash = 'form has errors'  
return dict()

view:
{{extend 'layout.html'}}
form action=# enctype=multipart/form-data method=post
ul
  liYour name is input name=name //li
  liYour group is input name=grp_name //li
  liYour request date is input name=req_date //li
  liYour email is input name=email //li
/ul
  input type=submit /
  input type=hidden name=_formname value=test /
/form


Unfortunately, I now no longer get error messages for fields that are left 
empty, a date app to help insert a date, and the autocomplete doesn't work 
(all of these worked fine with the default view of SQLFORM). Am I missing 
something obvious?

Would custom forms be a better way of doing this?

Many thanks.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Dropdown list in form

2013-12-13 Thread Warrick
Thanks guys,

Both worked!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: REF: Ajax Authentication

2013-12-13 Thread Leonel Câmara
That's a horrible idea Derek.

You could however have the controller check auth.is_logged_in() instead of 
using the decorator. 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Customization of the SQLFORM in html

2013-12-13 Thread Massimo Di Pierro
Yes. Replace

form action=# enctype=multipart/form-data method=post
ul
  liYour name is input name=name //li
  liYour group is input name=grp_name //li
  liYour request date is input name=req_date //li
  liYour email is input name=email //li
/ul
  input type=submit /
  input type=hidden name=_formname value=test /
/form

with

{{=form.custom.begin}}
ul
  liYour name is {{=form.custom.widget.name}}/li
...
{{=form.custom.end}}

On Friday, 13 December 2013 05:03:34 UTC-6, curly wrote:

 Hello!

 I'm new to web2py and have just started running web2py 2.8.1 in ubuntu 
 12.04.

 I am trying to customize the style of SQLFORM in web2py views. Tried to do 
 this using SQLFORM in HTML. What I have is:-

 model:
 db.define_table(
 register,
 Field('pi_id',db.pi),
 Field('name',requires=[IS_NOT_EMPTY(), IS_ALPHANUMERIC()]),
 Field('grp_name'),
 Field('req_date','date', requires = IS_DATE(format=('%d-%m-%Y'))),
 Field('email',requires=[IS_EMAIL()]))
 db.register.grp_name.widget = SQLFORM.widgets.autocomplete(
  request, db.pi.name, limitby=(0,10), min_length=1)

 controller:
 def display_your_form():
 form = 
 SQLFORM(db.register,fields=['name','grp_name','req_date','email'])
 if form.process(session=None,formname=test).accepted:
 response.flash = 'Reg saved.'
 redirect(URL('samples', 'default', 'index'))
 elif form.errors:
 response.flash = 'form has errors'  
 return dict()

 view:
 {{extend 'layout.html'}}
 form action=# enctype=multipart/form-data method=post
 ul
   liYour name is input name=name //li
   liYour group is input name=grp_name //li
   liYour request date is input name=req_date //li
   liYour email is input name=email //li
 /ul
   input type=submit /
   input type=hidden name=_formname value=test /
 /form


 Unfortunately, I now no longer get error messages for fields that are left 
 empty, a date app to help insert a date, and the autocomplete doesn't work 
 (all of these worked fine with the default view of SQLFORM). Am I missing 
 something obvious?

 Would custom forms be a better way of doing this?

 Many thanks.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Apostrophe's disapperaing

2013-12-13 Thread Jonathan Lundell
On 13 Dec 2013, at 2:29 AM, peter peterchutchin...@gmail.com wrote:
 Thank you Jonathon for taking the time to make two good suggestions. The 
 first did not get the apostrophes to appear. WRT the second, one can only 
 control the encoding of Word when outputting txt files.
 
 I have now created a work around, a bit ugly but the best I can achieve for 
 the moment.
 
 smart apostrophes should be #8217 for html. So I use textpad and replace all 
 smart apostrophe's with  #8217.  I have to do this twice, once for the left 
 leaning apostrophe and once for the right leaning one.
 
 This is not a nice solution but it does work.

One more thing to try: the mht file should have one or more charset 
declarations. What do they say?

It occurs to me that a couple of other things could be going wrong. One is that 
my re-coding suggestion isn't working because even though it might change the 
*character* encoding to UTF-8, the internal declarations are telling the 
browser to treat it as something else.

Another problem is that the database itself might be doing some 
encoding/decoding, depending on how the field is defined. You probably want to 
make sure you're using a field that treats its contents as binary data, or else 
store it as base64 text.

Yet another thing to try: rather than using your browser's view-source to see 
what you're getting back, fetch the result with curl or wget and look at the 
result in a text editor. 

BTW, your html entities should be terminated with a semicolon. Depending on the 
next character in the string, most browsers will try to do the right thing 
without it, but don't count on it. And FWIW you can use rsquo; and lsquo; 
instead.

One last thing. In Word for Mac 2011, when I save to .mht I get a dialog with a 
Web Options button. That button give me a dialog with several tabs. One of the 
tabs is Encoding, which lets me save as UTF-8 (and set the default to UTF-8). 
Hopefully Word for Windows has something similar.

 
 Peter
 
 On Friday, 13 December 2013 02:20:31 UTC, Jonathan Lundell wrote:
 On 12 Dec 2013, at 6:12 PM, Jonathan Lundell jlun...@pobox.com wrote:
 On 12 Dec 2013, at 4:16 PM, peter peterchu...@gmail.com wrote:
 I have a word document that I output as a .'.mht; file  ie, a 'single file 
 web page'.
 
 I can put sections of this into a string field in a database and then 
 display the field through a view, and the formatting in the word document 
 is preserved. 
 
 here is a line from the file that I read into web2py and insert into a 
 field in a database.
 
 p class=3DStyle7 
 style=3D'line-height:11.5pt;mso-line-height-rule:exactly'span 
 lang=3DEN-US style=3D'font-family:Adobe 
 Garamond,serif;mso-bidi-font-family: Adobe Garamond'‘One Lettuce Does 
 Not a Salad Make’ is similar to Jones’ story  ...
 
 
 Everything works fine except the apostrophes in the text disappear.
 
 When I display the field on the screen, there are no apostrophes. I f I 
 'view source', it is as above, but without the apostrophe's before One, 
 after Make and after Jones.
 
 Clearly this is an encoding problem. If I read the .mht file into textpad, 
 the apostrophe's appear, and textpad says the file is 'ANSI'. The question 
 is how do I read the file in such as way as to correctly encode the 
 apostrophes?
 
 I have tried various encodings including 'locale.getpreferredencoding()'.
 
 
 Does anyone know how to solve this problem
 
 
 Your email headers suggest that the string (at least in the email) is 
 encoded as windows-1252.
 
 So if s is your encoded string, you might try 
 s.decode('cp1252').encode('utf8'). Assuming that UTF-8 is OK for output.
 
 
 
 Alternatively, you might try to persuade Word to emit UTF-8 directly. This 
 might help: 
 http://office.microsoft.com/en-us/outlook-help/choose-text-encoding-when-you-open-and-save-files-HA010121249.aspx
 
 -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: list:reference painfull to fill

2013-12-13 Thread Richard Vézina
I am sorry about that...

Web2py default behavior for list:reference or reference is a HTML Select
and option... This is ordered by the navigator base on the spelling of the
element... So when you edit your form if you want to maintain the
preexisting order (the one that were there when you select items and order
them with bsm) you need to set them in order in the select yourself...
Bsmselect use OL that is Ordered List instead of UL... But it consume a
standard select... So, as long as he get a select with the proper ordered
options he can recreate the prexisting order... That is what the js I show
you does...

ordered_values content the list:reference or the reference value that are a
simple python list... List are items of list are ordered not like python
dict that not preserve order... So I just get the value of the field that
is a list object and pass it to the javascript as a list object... then I
create option from that list in javascript like you could do in web2py with
helpers for instance or by generating html yourself...

Hope it helps.

Richard


On Fri, Dec 13, 2013 at 7:27 AM, Kevin Bethke kevin.bet...@gmail.comwrote:

 thanks but to be honest now I'm even more confused.
 why do you need a piece of jquery code in a javascript variable. I sopose
 you included the entire jquery library.
 Why do you do the ordering with javascript and not with python is there a
 special reason for this? I think I just explained the last question  by
 looking at the code again. The document ready function is executed every
 time you add or remove an element from the list?
 the javascript variable ordered_values=%s is filled from the represent
 python variable?
 And my last question do you implement the multiple select into a form?
 Sry for all those questions but I'm still learning and the need for this
 to work really pushes my skills and knowledge beyond its limits.


 On Thu, Dec 12, 2013 at 3:49 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 It's a bit hacky but it works...

 :)

 Richard


 On Thu, Dec 12, 2013 at 9:48 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Don't bother with the php thing...

 Just look the data structure of the select...

 Here what I do to restore proper order on update form :

 controller_view_js += 
 var ordered_values = ''%s'';
 $(document).ready(function() {
 if(ordered_values != None) {
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]).append(option
 value=\'+ordered_values[i]+\'+
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).text()+/option);
 });
 $(select[name=field_name] option:selected).remove();
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).attr(selected, selected);
 });
 };
 }); % [int(ID) for ID in ordered_values_query]

 controller_view_js is a variable containing a piece of jquery that I
 pass to the view from the controller... What it does put the options into
 the proper order or how they were ordered at the input... All this is
 because web2py don't use ol list out of the box... So I manage thing to
 not require ol.

 The ordered_values_query contain the value of the field field_name for
 the given record...

 I had to set a representation like this too :

 represent=lambda values, row: ', '.join(map(lambda id:
 db.ref_referenced_table(id).represent_field, values)) if values != [] or
 None else T('N/A')

 Hope it helps.

 Richard


 On Thu, Dec 12, 2013 at 4:07 AM, BlueShadow kevin.bet...@gmail.comwrote:

 thanks for your offer I'm working my way through the example code but
 my biggest problem is that php site. I don't know php. But from what I get
 from the php code is that all the sample cities need to be in an unordered
 list environment ulli/li.../ul
 but this form part of the bsmselect example really confuses me.

 h1Example 1: Typical Usage/h1


 form action=./example_results.php method=post



 label for=cities1What are your favorite cities?/label


 select id=cities1 multiple=multiple name=cities[] title=Click 
 to Select a City class=sminit


   optionAmsterdam/option


 /select
 pinput type=submit name=submit value=submit //p


   /form


 especially the php file in form action=
 ?php

 if(!empty($_POST['submit'])) {

   echo html\nbody style='width: 400px; margin: 2em auto;
 font-family: Arial;';

   if(!empty($_POST['cities'])) {

 echo \npstrongYou selected the following
 cities:/strong/p\nul;

 foreach($_POST['cities'] as $city) {

   // exclude any items with chars we don't want, just in case
 someone is playing
   if(!preg_match('/^[-A-Z0-9\., ]+$/iD', $city)) continue;

   // print the city
   echo \n\tli . htmlspecialchars($city) . /li;
 }

 echo \n/ul;

   } else {
 echo \npNo items selected/p;
   }

   echo \npa href='index.html'Try Again?/a/p;

   echo \n/body\n/html;

 } else {
   

Re: [web2py] Re: list:reference painfull to fill

2013-12-13 Thread Kevin Bethke
Thanks it explains a lot. I will try to work on it as soon as I got the
time. Unfortunatly we got a deadline at work which is Christmas. So I will
probably not work on it till than.


On Fri, Dec 13, 2013 at 3:53 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 I am sorry about that...

 Web2py default behavior for list:reference or reference is a HTML Select
 and option... This is ordered by the navigator base on the spelling of the
 element... So when you edit your form if you want to maintain the
 preexisting order (the one that were there when you select items and order
 them with bsm) you need to set them in order in the select yourself...
 Bsmselect use OL that is Ordered List instead of UL... But it consume a
 standard select... So, as long as he get a select with the proper ordered
 options he can recreate the prexisting order... That is what the js I show
 you does...

 ordered_values content the list:reference or the reference value that are
 a simple python list... List are items of list are ordered not like python
 dict that not preserve order... So I just get the value of the field that
 is a list object and pass it to the javascript as a list object... then I
 create option from that list in javascript like you could do in web2py with
 helpers for instance or by generating html yourself...

 Hope it helps.

 Richard


 On Fri, Dec 13, 2013 at 7:27 AM, Kevin Bethke kevin.bet...@gmail.comwrote:

 thanks but to be honest now I'm even more confused.
 why do you need a piece of jquery code in a javascript variable. I sopose
 you included the entire jquery library.
  Why do you do the ordering with javascript and not with python is there
 a special reason for this? I think I just explained the last question  by
 looking at the code again. The document ready function is executed every
 time you add or remove an element from the list?
 the javascript variable ordered_values=%s is filled from the represent
 python variable?
 And my last question do you implement the multiple select into a form?
 Sry for all those questions but I'm still learning and the need for this
 to work really pushes my skills and knowledge beyond its limits.


 On Thu, Dec 12, 2013 at 3:49 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 It's a bit hacky but it works...

 :)

 Richard


 On Thu, Dec 12, 2013 at 9:48 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Don't bother with the php thing...

 Just look the data structure of the select...

 Here what I do to restore proper order on update form :

 controller_view_js += 
 var ordered_values = ''%s'';
 $(document).ready(function() {
 if(ordered_values != None) {
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]).append(option
 value=\'+ordered_values[i]+\'+
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).text()+/option);
 });
 $(select[name=field_name] option:selected).remove();
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).attr(selected, selected);
 });
 };
 }); % [int(ID) for ID in ordered_values_query]

 controller_view_js is a variable containing a piece of jquery that I
 pass to the view from the controller... What it does put the options into
 the proper order or how they were ordered at the input... All this is
 because web2py don't use ol list out of the box... So I manage thing to
 not require ol.

 The ordered_values_query contain the value of the field field_name for
 the given record...

 I had to set a representation like this too :

 represent=lambda values, row: ', '.join(map(lambda id:
 db.ref_referenced_table(id).represent_field, values)) if values != [] or
 None else T('N/A')

 Hope it helps.

 Richard


 On Thu, Dec 12, 2013 at 4:07 AM, BlueShadow kevin.bet...@gmail.comwrote:

 thanks for your offer I'm working my way through the example code but
 my biggest problem is that php site. I don't know php. But from what I get
 from the php code is that all the sample cities need to be in an unordered
 list environment ulli/li.../ul
 but this form part of the bsmselect example really confuses me.

 h1Example 1: Typical Usage/h1



 form action=./example_results.php method=post




 label for=cities1What are your favorite cities?/label



 select id=cities1 multiple=multiple name=cities[] title=Click 
 to Select a City class=sminit



   optionAmsterdam/option



 /select
 pinput type=submit name=submit value=submit //p



   /form


 especially the php file in form action=
 ?php

 if(!empty($_POST['submit'])) {

   echo html\nbody style='width: 400px; margin: 2em auto;
 font-family: Arial;';

   if(!empty($_POST['cities'])) {

 echo \npstrongYou selected the following
 cities:/strong/p\nul;

 foreach($_POST['cities'] as $city) {

   // exclude any items with chars we don't want, just in case
 someone is playing
   

Re: [web2py] Re: list:reference painfull to fill

2013-12-13 Thread Kevin Bethke
Well actually I got one more question: How do you change the standard form
from web2py, to use the bsmselect form?


On Fri, Dec 13, 2013 at 4:18 PM, Kevin Bethke kevin.bet...@gmail.comwrote:

 Thanks it explains a lot. I will try to work on it as soon as I got the
 time. Unfortunatly we got a deadline at work which is Christmas. So I will
 probably not work on it till than.


 On Fri, Dec 13, 2013 at 3:53 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 I am sorry about that...

 Web2py default behavior for list:reference or reference is a HTML Select
 and option... This is ordered by the navigator base on the spelling of the
 element... So when you edit your form if you want to maintain the
 preexisting order (the one that were there when you select items and order
 them with bsm) you need to set them in order in the select yourself...
 Bsmselect use OL that is Ordered List instead of UL... But it consume a
 standard select... So, as long as he get a select with the proper ordered
 options he can recreate the prexisting order... That is what the js I show
 you does...

 ordered_values content the list:reference or the reference value that are
 a simple python list... List are items of list are ordered not like python
 dict that not preserve order... So I just get the value of the field that
 is a list object and pass it to the javascript as a list object... then I
 create option from that list in javascript like you could do in web2py with
 helpers for instance or by generating html yourself...

 Hope it helps.

 Richard


 On Fri, Dec 13, 2013 at 7:27 AM, Kevin Bethke kevin.bet...@gmail.comwrote:

 thanks but to be honest now I'm even more confused.
 why do you need a piece of jquery code in a javascript variable. I
 sopose you included the entire jquery library.
  Why do you do the ordering with javascript and not with python is there
 a special reason for this? I think I just explained the last question  by
 looking at the code again. The document ready function is executed every
 time you add or remove an element from the list?
 the javascript variable ordered_values=%s is filled from the represent
 python variable?
 And my last question do you implement the multiple select into a form?
 Sry for all those questions but I'm still learning and the need for this
 to work really pushes my skills and knowledge beyond its limits.


 On Thu, Dec 12, 2013 at 3:49 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 It's a bit hacky but it works...

 :)

 Richard


 On Thu, Dec 12, 2013 at 9:48 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Don't bother with the php thing...

 Just look the data structure of the select...

 Here what I do to restore proper order on update form :

 controller_view_js += 
 var ordered_values = ''%s'';
 $(document).ready(function() {
 if(ordered_values != None) {
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]).append(option
 value=\'+ordered_values[i]+\'+
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).text()+/option);
 });
 $(select[name=field_name] option:selected).remove();
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).attr(selected, selected);
 });
 };
 }); % [int(ID) for ID in ordered_values_query]

 controller_view_js is a variable containing a piece of jquery that I
 pass to the view from the controller... What it does put the options into
 the proper order or how they were ordered at the input... All this is
 because web2py don't use ol list out of the box... So I manage thing to
 not require ol.

 The ordered_values_query contain the value of the field field_name for
 the given record...

 I had to set a representation like this too :

 represent=lambda values, row: ', '.join(map(lambda id:
 db.ref_referenced_table(id).represent_field, values)) if values != [] or
 None else T('N/A')

 Hope it helps.

 Richard


 On Thu, Dec 12, 2013 at 4:07 AM, BlueShadow kevin.bet...@gmail.comwrote:

 thanks for your offer I'm working my way through the example code but
 my biggest problem is that php site. I don't know php. But from what I 
 get
 from the php code is that all the sample cities need to be in an 
 unordered
 list environment ulli/li.../ul
 but this form part of the bsmselect example really confuses me.

 h1Example 1: Typical Usage/h1




 form action=./example_results.php method=post





 label for=cities1What are your favorite cities?/label




 select id=cities1 multiple=multiple name=cities[] 
 title=Click to Select a City class=sminit




   optionAmsterdam/option




 /select
 pinput type=submit name=submit value=submit //p




   /form


 especially the php file in form action=
 ?php

 if(!empty($_POST['submit'])) {

   echo html\nbody style='width: 400px; margin: 2em auto;
 font-family: Arial;';

   if(!empty($_POST['cities'])) {


Re: [web2py] Re: list:reference painfull to fill

2013-12-13 Thread Richard Vézina
You init the js on the field!!

Richard


On Fri, Dec 13, 2013 at 10:20 AM, Kevin Bethke kevin.bet...@gmail.comwrote:

 Well actually I got one more question: How do you change the standard form
 from web2py, to use the bsmselect form?


 On Fri, Dec 13, 2013 at 4:18 PM, Kevin Bethke kevin.bet...@gmail.comwrote:

 Thanks it explains a lot. I will try to work on it as soon as I got the
 time. Unfortunatly we got a deadline at work which is Christmas. So I will
 probably not work on it till than.


 On Fri, Dec 13, 2013 at 3:53 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 I am sorry about that...

 Web2py default behavior for list:reference or reference is a HTML Select
 and option... This is ordered by the navigator base on the spelling of the
 element... So when you edit your form if you want to maintain the
 preexisting order (the one that were there when you select items and order
 them with bsm) you need to set them in order in the select yourself...
 Bsmselect use OL that is Ordered List instead of UL... But it consume a
 standard select... So, as long as he get a select with the proper ordered
 options he can recreate the prexisting order... That is what the js I show
 you does...

 ordered_values content the list:reference or the reference value that
 are a simple python list... List are items of list are ordered not like
 python dict that not preserve order... So I just get the value of the field
 that is a list object and pass it to the javascript as a list object...
 then I create option from that list in javascript like you could do in
 web2py with helpers for instance or by generating html yourself...

 Hope it helps.

 Richard


 On Fri, Dec 13, 2013 at 7:27 AM, Kevin Bethke kevin.bet...@gmail.comwrote:

 thanks but to be honest now I'm even more confused.
 why do you need a piece of jquery code in a javascript variable. I
 sopose you included the entire jquery library.
  Why do you do the ordering with javascript and not with python is
 there a special reason for this? I think I just explained the last
 question  by looking at the code again. The document ready function is
 executed every time you add or remove an element from the list?
 the javascript variable ordered_values=%s is filled from the
 represent python variable?
 And my last question do you implement the multiple select into a form?
 Sry for all those questions but I'm still learning and the need for
 this to work really pushes my skills and knowledge beyond its limits.


 On Thu, Dec 12, 2013 at 3:49 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 It's a bit hacky but it works...

 :)

 Richard


 On Thu, Dec 12, 2013 at 9:48 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Don't bother with the php thing...

 Just look the data structure of the select...

 Here what I do to restore proper order on update form :

 controller_view_js += 
 var ordered_values = ''%s'';
 $(document).ready(function() {
 if(ordered_values != None) {
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]).append(option
 value=\'+ordered_values[i]+\'+
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).text()+/option);
 });
 $(select[name=field_name] option:selected).remove();
 $.each(ordered_values, function(i, val) {
 $(select[name=field_name]
 option[value=+ordered_values[i]+]).attr(selected, selected);
 });
 };
 }); % [int(ID) for ID in ordered_values_query]

 controller_view_js is a variable containing a piece of jquery that I
 pass to the view from the controller... What it does put the options into
 the proper order or how they were ordered at the input... All this is
 because web2py don't use ol list out of the box... So I manage thing to
 not require ol.

 The ordered_values_query contain the value of the field field_name
 for the given record...

 I had to set a representation like this too :

 represent=lambda values, row: ', '.join(map(lambda id:
 db.ref_referenced_table(id).represent_field, values)) if values != [] or
 None else T('N/A')

 Hope it helps.

 Richard


 On Thu, Dec 12, 2013 at 4:07 AM, BlueShadow 
 kevin.bet...@gmail.comwrote:

 thanks for your offer I'm working my way through the example code
 but my biggest problem is that php site. I don't know php. But from 
 what I
 get from the php code is that all the sample cities need to be in an
 unordered list environment ulli/li.../ul
 but this form part of the bsmselect example really confuses me.

 h1Example 1: Typical Usage/h1





 form action=./example_results.php method=post






 label for=cities1What are your favorite cities?/label





 select id=cities1 multiple=multiple name=cities[] 
 title=Click to Select a City class=sminit





   optionAmsterdam/option





 /select
 pinput type=submit name=submit value=submit //p





   /form


 especially the php file in form action=
 ?php

 

[web2py] Re: help-block in Bootstrap forms

2013-12-13 Thread Niphlod
is the endgame really let response.menu generate a structure than is 
converted every time server-side ?
Shouldn't we avoid server-side dom at all costs ?

On Friday, December 13, 2013 3:21:28 PM UTC+1, Paolo Caruccio wrote:

 Thank you LightDot.
 In the next few days I'll send to your private email the files for 
 bootstrap3 and foundation5 so you will able to check my code and yours.
 My bootstrap 3 code supports multilevel (2, 3 and so on) menu also. Both 
 bs3 and f5 manage the errors in form (see attached image) and the auth 
 navbar is easily customizable by the user. There are other small features 
 too. Of course they are responsive and should work also in mobile machines. 
 But more important thing is that by making small changes to it,  the code 
 can be applied also to other framework and therefore we will isolate this 
 matters from web2py core. The package for each framework  is constitued by 
 a python module, custom css file and a custom js file  in addition to the 
 framework files obviously.
 I hope this will be the first step to the web2py theming.


 Il giorno venerdì 13 dicembre 2013 11:54:21 UTC+1, LightDot ha scritto:

 That's excellent! I just started converting the welcome app to bs3 
 yesterday and got as far as converting and tweaking the html and adding 2nd 
 level submenu support. Foundation 5 was the next on my list.

 It seems that you've gotten further along so I'll wait for your code and 
 help out once it's published. Drop me a note directly if you could use any 
 help before that.

 Regards


 On Thursday, December 12, 2013 11:25:34 PM UTC+1, Paolo Caruccio wrote:

 In this days I'm finishing an external module (based on DOM server-side 
 manipulation) that converts web2py elements (at the moment: the auth 
 navbar, the menu and SQLform) to bootstrap3. It is my intention make this 
 module easy to extend to other frameworks also. Bootstrap3 and Foundation5 
 are almost ready and I'm working on ink sapo framework just to try if 
 it's possible the porting to something different. 
 I'm posting the code and examples on this group before xmas for testing 
 and feedback purposes. Some screenshots here attached.


 Il giorno giovedì 12 dicembre 2013 22:32:32 UTC+1, Massimo Di Pierro ha 
 scritto:

 Can you please open a ticket about this so it does not get lost? We 
 need to port welcome to bootstrap 3 asap.

 On Thursday, 12 December 2013 12:08:15 UTC-6, Annet wrote:

 Some field definitions in my models have comments, which in a 
 Bootstrap form are
 being displayed in a help-block.

 The problem is that this help-block

 span class=help-blockmy comment/span

 is added to every form field, resulting in 20 px of extra padding 
 between form fields, margin-bottom: 10px
 and margin-bottom: 5px. Is there a way to make adding a help-block 
 conditional?

 So far I made the following adjustments to a custom formstyle function:

 def bootstrap3(form, fields):
 form.add_class('form-horizontal')
 parent = FIELDSET()
 for id, label, controls, help in fields:
 # wrappers
 _help = SPAN(help, _class='help-block')
 # embed _help into _controls
 _controls = DIV(controls, _help, _class='controls col-sm-8')
 # submit unflag by default
 _submit = False

 if isinstance(controls, INPUT):
 controls.add_class('form-control')
 if controls['_type'] == 'submit':
 # flag submit button
 _submit = True
 controls['_class'] = 'btn btn-primary'
 if controls['_type'] == 'file':
 controls['_class'] = 'input-file'

 # For password fields, which are wrapped in a CAT object.
 if isinstance(controls, CAT) and isinstance(controls[0], 
 INPUT):
 controls[0].add_class('form-control')

 if isinstance(controls, SELECT):
 controls.add_class('form-control')

 if isinstance(controls, TEXTAREA):
 controls.add_class('form-control')

 if isinstance(label, LABEL):
 label['_class'] = 'col-sm-4 control-label'

 if _submit:
 # submit button has unwrapped label and controls, 
 different class
 parent.append(DIV(label, controls, _class='col-sm-offset-4 
 col-sm-8 form-actions', _id=id))
 # unflag submit (possible side effect)
 _submit = False
 else:
 # unwrapped label
 parent.append(DIV(label, _controls, _class='form-group', 
 _id=id))
 return parent



 Kind regards,

 Annet



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more 

[web2py] SQLForm Grid

2013-12-13 Thread LaDarrius Stewart
Is there to only give the add(create) functionality of the sqlform.grid 
Example:
db.define_table('Participant',
Field('FirstName' , 'text'),
Field('LastName' , 'text')

fields = [ db.Participant.FirstName ]
headers = {'Participant.FirstName': 'FirstName'}
form2=SQLFORM.grid(db.Participant, fields=fields, searchable=False)

On the grid displayed on a page it currently shows all Participant records. 
I dont really even want the grid I just want the Add(create) functionality. 
I dont even need the grid to bring back like somehow make the query not 
auto execute so it doesnt bring back all the Participants. My explanation 
might not be that clear if anyone needs further clarification let me know 
any help is appreciated.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: help-block in Bootstrap forms

2013-12-13 Thread Paolo Caruccio
Well we could convert the menu on client side but I found several ugly 
rendering issues.
And why we should avoid server-side dom? I think that it is an interesting 
web2py feature. 

However since your opinion is important for me, do you think the following 
function might have a bad impact server-side?

def menu():
# get the current menu
current_menu = current.response.menu
# set the new menu
menu = MENU(current_menu,
   _class='nav navbar-nav',
   li_class='dropdown',
   ul_class='dropdown-menu')
# add here any menu customization
menu = menu.serialize(menu.data)
dropdowns = menu.elements('ul.dropdown-menu')
for dropdown in dropdowns:
toggle = dropdown.parent
if toggle.parent['_class'] == 'nav navbar-nav':
toggle['_data-w2pmenulevel'] = l0
toggle.element('a',
   replace=lambda t: A(t[0], ' ',
   SPAN('', _class=caret),
   _href=t['_href'],
   _class='dropdown-toggle',
   **{'_data-toggle': 'dropdown'
}))
else:
toggle['_class'] = toggle['_class'].replace('dropdown',
'dropdown-submenu')


return menu

And in the layout.html:

{{if response.menu:}}
{{=bs3.menu()}}
{{pass}}

Thank you in advance for your feedback.




Il giorno venerdì 13 dicembre 2013 17:22:35 UTC+1, Niphlod ha scritto:

 is the endgame really let response.menu generate a structure than is 
 converted every time server-side ?
 Shouldn't we avoid server-side dom at all costs ?

 On Friday, December 13, 2013 3:21:28 PM UTC+1, Paolo Caruccio wrote:

 Thank you LightDot.
 In the next few days I'll send to your private email the files for 
 bootstrap3 and foundation5 so you will able to check my code and yours.
 My bootstrap 3 code supports multilevel (2, 3 and so on) menu also. Both 
 bs3 and f5 manage the errors in form (see attached image) and the auth 
 navbar is easily customizable by the user. There are other small features 
 too. Of course they are responsive and should work also in mobile machines. 
 But more important thing is that by making small changes to it,  the code 
 can be applied also to other framework and therefore we will isolate this 
 matters from web2py core. The package for each framework  is constitued by 
 a python module, custom css file and a custom js file  in addition to the 
 framework files obviously.
 I hope this will be the first step to the web2py theming.


 Il giorno venerdì 13 dicembre 2013 11:54:21 UTC+1, LightDot ha scritto:

 That's excellent! I just started converting the welcome app to bs3 
 yesterday and got as far as converting and tweaking the html and adding 2nd 
 level submenu support. Foundation 5 was the next on my list.

 It seems that you've gotten further along so I'll wait for your code and 
 help out once it's published. Drop me a note directly if you could use any 
 help before that.

 Regards


 On Thursday, December 12, 2013 11:25:34 PM UTC+1, Paolo Caruccio wrote:

 In this days I'm finishing an external module (based on DOM server-side 
 manipulation) that converts web2py elements (at the moment: the auth 
 navbar, the menu and SQLform) to bootstrap3. It is my intention make this 
 module easy to extend to other frameworks also. Bootstrap3 and Foundation5 
 are almost ready and I'm working on ink sapo framework just to try if 
 it's possible the porting to something different. 
 I'm posting the code and examples on this group before xmas for testing 
 and feedback purposes. Some screenshots here attached.


 Il giorno giovedì 12 dicembre 2013 22:32:32 UTC+1, Massimo Di Pierro ha 
 scritto:

 Can you please open a ticket about this so it does not get lost? We 
 need to port welcome to bootstrap 3 asap.

 On Thursday, 12 December 2013 12:08:15 UTC-6, Annet wrote:

 Some field definitions in my models have comments, which in a 
 Bootstrap form are
 being displayed in a help-block.

 The problem is that this help-block

 span class=help-blockmy comment/span

 is added to every form field, resulting in 20 px of extra padding 
 between form fields, margin-bottom: 10px
 and margin-bottom: 5px. Is there a way to make adding a help-block 
 conditional?

 So far I made the following adjustments to a custom formstyle 
 function:

 def bootstrap3(form, fields):
 form.add_class('form-horizontal')
 parent = FIELDSET()
 for id, label, controls, help in fields:
 # wrappers
 _help = SPAN(help, _class='help-block')
 # embed _help into _controls
 _controls = DIV(controls, _help, _class='controls col-sm-8')
 # submit unflag by default
 _submit = False

 if isinstance(controls, INPUT):
 

[web2py] Re: count amount of times a field is present in selection and fetch a record for each

2013-12-13 Thread Leonel Câmara
You need to be more clear with what you're trying to do, I also don't know 
what the hell is in db.parking table or in db.person. This makes it very 
difficult to help you.

BTW you could just do this to get a list of persons:

persons = db(db.person.id.belongs(session.people.keys())).select()



Sexta-feira, 13 de Dezembro de 2013 12:04:43 UTC, Ivo escreveu:

 I have a list containing record id's and need to select those records from 
 a table. then I need to count how many different values are contained in 
 the fields and for each select the first record of an other table.

 ids = session.people.keys()
 persons = {}

 for id in ids: persons[id]=db(db.people.id==id).select()[0]
 person_list[]
 for id,person in persons.items():
 person=people.user_name
 person_list.append(person)


 now I want retrieve the first record, with a bool set to False, from 
 db.parking for each. 
 db.parking records contain a bool which I want to toggle to true


 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: SQLForm Grid

2013-12-13 Thread LaDarrius Stewart
Also in my model I have db.Participant.Member_Local.widget = 
SQLFORM.widgets.autocomplete(request, db.Locals.LocalName, 
id_field=db.Locals.Id)
Is there a way to pass a given list of ids instead of the available Ids in 
the entire db. i.e.

allowed=(1,2,3)
db.Participant.Member_Local.widget = SQLFORM.widgets.autocomplete(request, 
db.Locals.LocalName, id_field=allowed)


On Friday, December 13, 2013 10:38:03 AM UTC-6, LaDarrius Stewart wrote:

 Is there to only give the add(create) functionality of the sqlform.grid 
 Example:
 db.define_table('Participant',
 Field('FirstName' , 'text'),
 Field('LastName' , 'text')

 fields = [ db.Participant.FirstName ]
 headers = {'Participant.FirstName': 'FirstName'}
 form2=SQLFORM.grid(db.Participant, fields=fields, searchable=False)

 On the grid displayed on a page it currently shows all Participant 
 records. I dont really even want the grid I just want the Add(create) 
 functionality. I dont even need the grid to bring back like somehow make 
 the query not auto execute so it doesnt bring back all the Participants. My 
 explanation might not be that clear if anyone needs further clarification 
 let me know any help is appreciated.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Import error for requests

2013-12-13 Thread John Zumsteg
I can answer my own question here, kind of.

I was able to make this work by copying the requests folder from
/Library/Python/2.7/site-packages/*requests-2.1.0-py2.7.egg* to the 
application's modules folder. This makes it work for this application, but 
it seems to me that having it in the site-packages folder should make it 
universally available to any web2py application. I guess I need more 
knowledge about how all this works, but for now, I can go forward.

John


On Thursday, December 12, 2013 8:26:49 AM UTC-8, John Zumsteg wrote:

 I have a controller that does an *import requests. *I get the message 
 Cannot import module 'requests' when trying to run it. I installed 
 Requests using pip install, and  

 /Library/Python/2.7/site-packages/ contains *requests-2.1.0-py2.7.egg*. I 
 can import requests from the Python2.7 interpreter, but not from web2py. 
 Running on OS X Mavericks.

 Any ideas why the import requests fails, and how to correct it?




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: The procedure entry point wcspy_s could not be located in the dynamic link library msvcrt.dll

2013-12-13 Thread mikech
I am also getting the the procedure entry point wcspy_s could not be 
located in the dynamic link library msvcrt.dll on WinXP and this is a clean 
install with no pre-existing projects of databases.

On Thursday, December 5, 2013 1:12:53 PM UTC-8, Niphlod wrote:

 recent web2py version enforce FK integrity on SQLite (as any other 
 relational backend does by default) to prevent users from working on the 
 development with SQLite without realizing that there is some really faulty 
 data in the database. Too many incurred in the problem too late to know... 
 check your data and fix it before it's too late ^_^

 On Monday, December 2, 2013 12:49:40 AM UTC+1, Alex Glaros wrote:

 When upgrading to 2.8.2  today on Windows Home XP, I get this error when 
 trying to boot W2P:

 The procedure entry point wcspy_s could not be located in the dynamiclink 
 library msvcrt
 .dll

 I restore to earlier Windows version to remove the DLL error and get W2P 
 working, but then get the following error when adding a record via a form:

 class 'sqlite3.IntegrityError' foreign key constraint failed

 Same controller works for 7.2.4.  No DLL and no foreign key error.

 On another Windows 7 machine I don't get DLL error but get foreign key 
 constraint error on same app that works with W2P 7.2.4

 Alex Glaros



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: help-block in Bootstrap forms

2013-12-13 Thread Niphlod
IMHO there's no point on having web2py serializing by default a structure 
(response.menu) to a string (the html markup) and then reparse it back to a 
structure (elements) to move a few pieces back and forth and then 
reserializing those pieces back to html markup. It's just a waste of cpu.

The way to go NEEDS to be modules with overrides, not server-side DOM 
manipulations...
I agree that right now you can only act on the MENU() function, but a way 
must be figured out to avoid serverside DOM parsing or we'll soon face an 
untouchable MENU() that can't accomodate for new features 'cause there are 
lots of code expecting a fixed html markup.
Same goes for forms and widgets: fortunately we have already a formstyle 
that takes a callback, but I don't see why noone is coming up with a new 
set of widgets that override the default one composing the html elements 
the way they are supposed to be in the first place

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: The procedure entry point wcspy_s could not be located in the dynamic link library msvcrt.dll

2013-12-13 Thread Niphlod
jump on the bandwagon yourself! 
http://code.google.com/p/web2py/issues/detail?id=1809

On Friday, December 13, 2013 8:30:29 PM UTC+1, mikech wrote:

 I am also getting the the procedure entry point wcspy_s could not be 
 located in the dynamic link library msvcrt.dll on WinXP and this is a 
 clean install with no pre-existing projects of databases.

 On Thursday, December 5, 2013 1:12:53 PM UTC-8, Niphlod wrote:

 recent web2py version enforce FK integrity on SQLite (as any other 
 relational backend does by default) to prevent users from working on the 
 development with SQLite without realizing that there is some really faulty 
 data in the database. Too many incurred in the problem too late to know... 
 check your data and fix it before it's too late ^_^

 On Monday, December 2, 2013 12:49:40 AM UTC+1, Alex Glaros wrote:

 When upgrading to 2.8.2  today on Windows Home XP, I get this error when 
 trying to boot W2P:

 The procedure entry point wcspy_s could not be located in the dynamiclink 
 library msvcrt
 .dll

 I restore to earlier Windows version to remove the DLL error and get W2P 
 working, but then get the following error when adding a record via a form:

 class 'sqlite3.IntegrityError' foreign key constraint failed

 Same controller works for 7.2.4.  No DLL and no foreign key error.

 On another Windows 7 machine I don't get DLL error but get foreign key 
 constraint error on same app that works with W2P 7.2.4

 Alex Glaros



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Error with session when user tries to login

2013-12-13 Thread Marin Pranjić
This happens when customer tries to login. I have no idea why it happens 
and it works when I try it on localhost.


web2py™Version 2.8.2-stable+timestamp.2013.11.28.07.51.37PythonPython 2.7.3: 
/usr/bin/python (prefix: /usr)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

Traceback (most recent call last):
  File /home/www-data/web2py/gluon/main.py, line 479, in wsgibase
session._try_store_in_cookie_or_file(request, response)
  File /home/www-data/web2py/gluon/globals.py, line 1089, in 
_try_store_in_cookie_or_file
return self._try_store_in_file(request, response)
  File /home/www-data/web2py/gluon/globals.py, line 1096, in 
_try_store_in_file
or self._unchanged(response)):
  File /home/www-data/web2py/gluon/globals.py, line 1041, in _unchanged
session_pickled = cPickle.dumps(self)
  File /usr/lib/python2.7/copy_reg.py, line 84, in _reduce_ex
dict = getstate()
TypeError: 'NoneType' object is not callable


Any ideas? It's urgent so any suggestion is welcome.

Marin

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] routes.py URL rewriting

2013-12-13 Thread Gael Princivalle
Hello all.

I've read a lot of literature about routes.py, it's amazing how it can be 
powerful and complex.
However for my simple needs I don't reach to find the solution.

In my web2py root folder I have this routes.py, using the parameter-based 
system:
routers = dict(
BASE = dict(
domains = {
mydomain1.com : myapp1,
mydomain1.com : myapp1,
}
),
)

It works as I expect, when a user wants to go on mydomain1.com in the URL 
address it have mydomain1.com, and web2py display index from myapp1.

Now I need to add this:
When the user ask for mydomain1.com/pdf/file1.pdf, web2py search for this 
file in myapp1/static/pdf, and the URL address web2py display 
mydomain1.com/pdf/file1.pdf.

Is it possible to do it with the parameter-based system, and how ?
Do I have to add routes in the routes.py from the web2py root or from 
myapp1 ?

Thanks.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Error with session when user tries to login

2013-12-13 Thread Leonel Câmara
Yes, Lucas and I are having the same problem.
https://groups.google.com/forum/#!topic/web2py/CSuT_CknD20

Restarting the webserver temporarily solves the problem for me. Saving 
sessions in db also seems to make the problem take longer to appear.

For me, it's happening with apache in windows, I've never seen it happen 
with the included rocket server.

Either way, it's definitely a bug introduced between 2.7 and 2.8, I just 
didn't have the time to look into it properly yet, hopefully one of the 
devs will have time to do it soon.

What seems to be happening here is that somewhere along the way, an object 
that is not copyable is being saved in the session.

A potential way to find the bug that I didn't have time to try yet, is to 
define Session __setitem__ and try to cPickle.dumps everything that is put 
there as that should crash instantly and find what's going wrong.


Sexta-feira, 13 de Dezembro de 2013 19:40:18 UTC, Marin Pranjić escreveu:

 This happens when customer tries to login. I have no idea why it happens 
 and it works when I try it on localhost.


 web2py™Version 2.8.2-stable+timestamp.2013.11.28.07.51.37PythonPython 2.7.
 3: /usr/bin/python (prefix: /usr)

 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.

 Traceback (most recent call last):
   File /home/www-data/web2py/gluon/main.py, line 479, in wsgibase
 session._try_store_in_cookie_or_file(request, response)
   File /home/www-data/web2py/gluon/globals.py, line 1089, in 
 _try_store_in_cookie_or_file
 return self._try_store_in_file(request, response)
   File /home/www-data/web2py/gluon/globals.py, line 1096, in 
 _try_store_in_file
 or self._unchanged(response)):
   File /home/www-data/web2py/gluon/globals.py, line 1041, in _unchanged
 session_pickled = cPickle.dumps(self)
   File /usr/lib/python2.7/copy_reg.py, line 84, in _reduce_ex
 dict = getstate()
 TypeError: 'NoneType' object is not callable


 Any ideas? It's urgent so any suggestion is welcome.

 Marin


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: count amount of times a field is present in selection and fetch a record for each

2013-12-13 Thread Ivo
sorry for being unclear.
I want to assign a parkingspot_code for each user_name in either a form or 
a grid and populate it with some other data from the people db

The db.parking table contains:
db.define_table('parking',
Field('parkingspot_code', 'string', unique=True),
Field('used', 'boolean', default=False))

I think I either need to togle the boolean to true if a code is used or I 
need to select the first record in the db, copy the code value and delete 
the record. The parkingspot_code's are pre generated and 1 time use only. 
The resulting form or grid is stored in an other table

I hope this clarifies it a bit.

On Friday, December 13, 2013 6:16:44 PM UTC+1, Leonel Câmara wrote:

 You need to be more clear with what you're trying to do, I also don't know 
 what the hell is in db.parking table or in db.people. This makes it very 
 difficult to help you.

 BTW you could just do this to get a list of persons:

 persons = db(db.people.id.belongs(session.people.keys())).select()



 Sexta-feira, 13 de Dezembro de 2013 12:04:43 UTC, Ivo escreveu:

 I have a list containing record id's and need to select those records 
 from a table. then I need to count how many different values are contained 
 in the fields and for each select the first record of an other table.

 ids = session.people.keys()
 persons = {}

 for id in ids: persons[id]=db(db.people.id==id).select()[0]
 person_list[]
 for id,person in persons.items():
 person=people.user_name
 person_list.append(person)


 now I want retrieve the first record, with a bool set to False, from 
 db.parking for each. 
 db.parking records contain a bool which I want to toggle to true


 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Show / Hide buttons

2013-12-13 Thread Michel Hayek
Thanks Steve awesome.

On Thursday, December 12, 2013 12:24:21 PM UTC-6, Michel Hayek wrote:

 Hey guys,

 *I have this in the db.py*

 *db.define_table('t_usertypes',*
 *Field('f_usertype',label='User Type :', required=True, 
 notnull=True),*
 *format='%(f_usertype)s')*

 *I have this in default.py*

 *def usertypes():*
 *   form=SQLFORM(db.t_usertypes)*
 *   if form.accepts(request.vars,session):*
 *session.flash=The new user type has been successfully added!*
 *redirect(URL(r=request))*
 *grid=SQLFORM.grid(db.t_usertypes)*
 *   return dict (grid=grid)*

 *The html file contains this *

 *div id=mydiv class=mydiv*
 *User Types*
 *{{=BEAUTIFY(response._vars)}}*

 *{{db.t_usertypes}}*
 */div*

 How i can enable/disable users from insert, delete, update.

 is the best choice to show / hide the ADD, DELETE, UPDATE links?
 if so how can this be done?

 Thanks

 *This e-mail is confidential and may also be privileged. If you are not 
 the intended **recipient, please notify the sender immediately, delete it 
 from your system and do **not copy, disseminate, distribute or disclose 
 any information contained therein.*


-- 
 

*This e-mail is confidential and may also be privileged. If you are not the 
intended **recipient, please notify the sender immediately, delete it from 
your system and do **not copy, disseminate, distribute or disclose any 
information contained therein.*

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Drop down not showing

2013-12-13 Thread Michel Hayek
Hi guys,

I have 2 tables defined Auth_User(PK=id) and Companies(PK=ID)
I also defined User_Has_Companies which has 2 columns USER_ID and COMP_ID 
together should form a PK.
*db.py:*
*db.define_table('t_user_has_companies',*
*Field('first_name', 'reference auth_user', label='User', 
writable=True, readable=True, notnull=True, required=True,  ondelete='NO 
ACTION', requires=IS_IN_DB(db, db.auth_user, '%(id)s %(first_name)s 
%(last_name)s')),*
*Field('f_coname', 'reference t_companies', 
label='Company', writable=True, readable=True, notnull=True, required=True, 
ondelete='NO ACTION', requires=IS_IN_DB(db, db.t_companies, '%(id)s 
%(f_coname)s'))*
*   )*
*db.t_user_has_companies.first_name.requires=IS_NOT_IN_DB(db(db.t_user_has_companies.f_coname==request.vars.f_coname),db.t_user_has_companies.first_name)*

*In default.py:*
*@auth.requires_login()*
*def usercompanies():*
*grid=SQLFORM.grid(db.t_user_has_companies)*
*return locals()*

it works fine but the problem is i only get one drop down for the 
companies, as for the User it appears a text box. How this one also be set 
to drop down box?

Thanks

-- 
 

*This e-mail is confidential and may also be privileged. If you are not the 
intended **recipient, please notify the sender immediately, delete it from 
your system and do **not copy, disseminate, distribute or disclose any 
information contained therein.*

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] cannot figure out class 'cPickle.UnpicklingError' invalid load key, ''.

2013-12-13 Thread Evan Caldwell
I got this error today after doing a git pull from my repo (there is one 
other person working on this code as well). I'm sure I'm missing something 
small but I don't know what. I also cannot get into database administration 
due to the same error. Thanks in advance for the help.

class 'cPickle.UnpicklingError' invalid load key, ''. Version  web2py™ 
Version 
2.7.4-stable+timestamp.2013.11.14.13.28.53  Python Python 2.7: 
C:\web2py\web2py_no_console.exe (prefix: C:\web2py)  Traceback 

1.
2.
3.
4.
5.
6.
7.
8.

Traceback (most recent call last):
  File C:\web2py\gluon\restricted.py, line 217, in restricted
  File C:/web2py/applications/siriadmin/models/db.py 
http://127.0.0.1:8000/admin/default/edit/siriadmin/models/db.py, line 136, in 
module
  File C:\web2py\gluon\dal.py, line 8129, in define_table
  File C:\web2py\gluon\dal.py, line 8166, in lazy_define_table
  File C:\web2py\gluon\dal.py, line 1079, in create_table
UnpicklingError: invalid load key, ''.

Error snapshot [image: help] 
http://127.0.0.1:8000/admin/default/ticket/siriadmin/127.0.0.1.2013-12-13.14-00-38.09e21ced-5687-4f9f-8040-7ebeeb3dd80d#
 

class 'cPickle.UnpicklingError'(invalid load key, ''.) 

inspect attributes 
 Frames 
   
   -  
   
   *File C:\web2py\gluon\restricted.py in restricted at line 217* code 
   arguments variables 
-  
   
   *File C:\web2py\applications\siriadmin\models\db.py in module at line 
   136* code arguments variables 
-  
   
   *File C:\web2py\gluon\dal.py in define_table at line 8129* code arguments 
   variables 
-  
   
   *File C:\web2py\gluon\dal.py in lazy_define_table at line 8166* code 
   arguments variables 
-  
   
   *File C:\web2py\gluon\dal.py in create_table at line 1079* code arguments 
   variables 
Function argument list 
   
   (self=gluon.dal.SQLiteAdapter object, table=Table siri_projects 
   
(id,name,description,coordi..._loc,num_students,reviewed,contracted,is_active),
 
   migrate=True, fake_migrate=False, polymodel=None)
Code listing 
   
   1074.
   1075.
   1076.
   1077.
   1078.
   1079.
   
   1080.
   1081.
   1082.
   1083.
   
   else:
   self.log('success!\n', table)
   else:
   tfile = self.file_open(table._dbt, 'r')
   try:
   sql_fields_old = pickle.load(tfile)
   
   except EOFError:
   self.file_close(tfile)
   raise RuntimeError('File %s appears corrupted' % table._dbt)
   self.file_close(tfile)
   
Variables   

 Context 

locals request session response 
 In file: C:\web2py\applications\siriadmin\models\db.py 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.

# -*- coding: utf-8 -*-

#
## This scaffolding model makes your app work on Google App Engine too
## File is released under public domain and you can use without limitations
#

## if SSL/HTTPS is properly configured and you want all HTTP requests to
## be redirected to HTTPS, uncomment the line below:
# request.requires_https()

if not request 
http://127.0.0.1:8000/examples/global/vars/request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
db = DAL 
http://127.0.0.1:8000/examples/global/vars/DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
else:
## connect to Google BigTable (optional 'google:datastore://namespace')
db = DAL 
http://127.0.0.1:8000/examples/global/vars/DAL('google:datastore')
## store sessions and tickets there
session 
http://127.0.0.1:8000/examples/global/vars/session.connect(request 
http://127.0.0.1:8000/examples/global/vars/request, response 
http://127.0.0.1:8000/examples/global/vars/response, db=db)
## or store session in Memcache, Redis, etc.
## from gluon.contrib.memdb import MEMDB
## from google.appengine.api.memcache import Client
## session.connect(request, response, db = MEMDB(Client()))

## by default give a view/generic.extension to all actions from localhost
## none otherwise. a pattern can be 'controller/function.extension'
response http://127.0.0.1:8000/examples/global/vars/response.generic_patterns 
= ['*'] if request 
http://127.0.0.1:8000/examples/global/vars/request.is_local else []
## (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 

Re: [web2py] Re: Error with session when user tries to login

2013-12-13 Thread Marin Pranjić
Ok, let's continue discussion there.

Marin



On Fri, Dec 13, 2013 at 9:16 PM, Leonel Câmara leonelcam...@gmail.comwrote:

 Yes, Lucas and I are having the same problem.
 https://groups.google.com/forum/#!topic/web2py/CSuT_CknD20

 Restarting the webserver temporarily solves the problem for me. Saving
 sessions in db also seems to make the problem take longer to appear.

 For me, it's happening with apache in windows, I've never seen it happen
 with the included rocket server.

 Either way, it's definitely a bug introduced between 2.7 and 2.8, I just
 didn't have the time to look into it properly yet, hopefully one of the
 devs will have time to do it soon.

 What seems to be happening here is that somewhere along the way, an object
 that is not copyable is being saved in the session.

 A potential way to find the bug that I didn't have time to try yet, is to
 define Session __setitem__ and try to cPickle.dumps everything that is put
 there as that should crash instantly and find what's going wrong.


 Sexta-feira, 13 de Dezembro de 2013 19:40:18 UTC, Marin Pranjić escreveu:

 This happens when customer tries to login. I have no idea why it happens
 and it works when I try it on localhost.


 web2py™Version 2.8.2-stable+timestamp.2013.11.28.07.51.37 PythonPython
 2.7.3: /usr/bin/python (prefix: /usr)

 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.


 9.
 10.
 11.
 12.
 13.

 Traceback (most recent call last):


   File /home/www-data/web2py/gluon/main.py, line 479, in wsgibase


 session._try_store_in_cookie_or_file(request, response)


   File /home/www-data/web2py/gluon/globals.py, line 1089, in 
 _try_store_in_cookie_or_file


 return self._try_store_in_file(request, response)


   File /home/www-data/web2py/gluon/globals.py, line 1096, in 
 _try_store_in_file


 or self._unchanged(response)):


   File /home/www-data/web2py/gluon/globals.py, line 1041, in _unchanged


 session_pickled = cPickle.dumps(self)


   File /usr/lib/python2.7/copy_reg.py, line 84, in _reduce_ex


 dict = getstate()
 TypeError: 'NoneType' object is not callable


 Any ideas? It's urgent so any suggestion is welcome.

 Marin

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] routes.py URL rewriting

2013-12-13 Thread Jonathan Lundell
On 13 Dec 2013, at 12:01 PM, Gael Princivalle gaelprinciva...@gmail.com wrote:
 I've read a lot of literature about routes.py, it's amazing how it can be 
 powerful and complex.
 However for my simple needs I don't reach to find the solution.
 
 In my web2py root folder I have this routes.py, using the parameter-based 
 system:
 routers = dict(
 BASE = dict(
 domains = {
 mydomain1.com : myapp1,
 mydomain1.com : myapp1,
 }
 ),
 )
 
 It works as I expect, when a user wants to go on mydomain1.com in the URL 
 address it have mydomain1.com, and web2py display index from myapp1.
 
 Now I need to add this:
 When the user ask for mydomain1.com/pdf/file1.pdf, web2py search for this 
 file in myapp1/static/pdf, and the URL address web2py display 
 mydomain1.com/pdf/file1.pdf.
 
 Is it possible to do it with the parameter-based system, and how ?
 Do I have to add routes in the routes.py from the web2py root or from myapp1 ?

One way, not using the router: make a pdf controller, and in its default 
function, open the file you want to return and:

return response.stream(file, chunk_size=4096, attachment=True, 
filename='file1.pdf')

You may need to fiddle with content-type or something to control whether the 
pdf gets displayed by the browser.

A more efficient way is to handle the incoming URL directly in Apache (or 
whatever you're using for the front end), and bypass web2py altogether. That's 
generally a good thing to do with static files in general; you just need to 
rewrite the path first.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: login crash under 2.8.2

2013-12-13 Thread Marin Pranjić
I just found this:

https://groups.google.com/forum/#!searchin/web2py/weird$20auth$20error/web2py/jkqyPM5_zaE/Ve5gy7greuoJ
This is version 2.4.5 so it is NOT something introduced in recent version.

I am also privileged to feel the pain that this issue causes in production.

Marin

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: SQLForm Grid

2013-12-13 Thread 黄祥
i think you can achieve it with :
not tested
create = True
editable = False
deletable = False
searchable = False
details = False
csv = False
sortable = False
links_in_grid = False
showbuttontext = False

def participant():
grid=SQLFORM.grid(*db.*Participant, create = create, editable = 
editable, deletable = deletable, searchable = searchable, details = 
details, csv = csv, sortable = sortable, links_in_grid = links_in_grid, 
showbuttontext = showbuttontext)
return locals()

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: The procedure entry point wcspy_s could not be located in the dynamic link library msvcrt.dll

2013-12-13 Thread mikech
Done :)

On Friday, December 13, 2013 11:34:33 AM UTC-8, Niphlod wrote:

 jump on the bandwagon yourself! 
 http://code.google.com/p/web2py/issues/detail?id=1809

 On Friday, December 13, 2013 8:30:29 PM UTC+1, mikech wrote:

 I am also getting the the procedure entry point wcspy_s could not be 
 located in the dynamic link library msvcrt.dll on WinXP and this is a 
 clean install with no pre-existing projects of databases.

 On Thursday, December 5, 2013 1:12:53 PM UTC-8, Niphlod wrote:

 recent web2py version enforce FK integrity on SQLite (as any other 
 relational backend does by default) to prevent users from working on the 
 development with SQLite without realizing that there is some really faulty 
 data in the database. Too many incurred in the problem too late to know... 
 check your data and fix it before it's too late ^_^

 On Monday, December 2, 2013 12:49:40 AM UTC+1, Alex Glaros wrote:

 When upgrading to 2.8.2  today on Windows Home XP, I get this error 
 when trying to boot W2P:

 The procedure entry point wcspy_s could not be located in the dynamiclink 
 library msvcrt
 .dll

 I restore to earlier Windows version to remove the DLL error and get 
 W2P working, but then get the following error when adding a record via a 
 form:

 class 'sqlite3.IntegrityError' foreign key constraint failed

 Same controller works for 7.2.4.  No DLL and no foreign key error.

 On another Windows 7 machine I don't get DLL error but get foreign key 
 constraint error on same app that works with W2P 7.2.4

 Alex Glaros



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Drop down not showing

2013-12-13 Thread 黄祥


 *db.define_table('t_user_has_companies',*
 *Field('first_name', 'reference auth_user', label='User', 
 writable=True, readable=True, notnull=True, required=True,  ondelete='NO 
 ACTION', requires=IS_IN_DB(db, db.auth_user, '%(id)s %(first_name)s 
 %(last_name)s')),*
 *Field('f_coname', 'reference t_companies', 
 label='Company', writable=True, readable=True, notnull=True, required=True, 
 ondelete='NO ACTION', requires=IS_IN_DB(db, db.t_companies, '%(id)s 
 %(f_coname)s'))*
 *   )*

 *db.t_user_has_companies.first_name.requires=IS_NOT_IN_DB(db(db.t_user_has_companies.f_coname==request.vars.f_coname),db.t_user_has_companies.first_name)*

  
hm, i think the problem is on your requires for first_name field in 
user_has_companies table. could you test to make the first_name field in 
user_has_companies table more simple first, after that add the DAL field 
constructor one by one.
e.g.
*db.define_table('t_user_has_companies',*
*Field('first_name', 'reference auth_user'),*
*Field('f_coname', 'reference t_companies', 
label='Company', writable=True, readable=True, notnull=True, required=True, 
ondelete='NO ACTION', requires=IS_IN_DB(db, db.t_companies, '%(id)s 
%(f_coname)s'))*
*   )*
 
p.s.
for combine requires field constructor i think you can use the list [] for 
that.
e.g.
table.email.requires = [IS_LOWER(), IS_EMAIL(), IS_NOT_IN_DB(db, 
table.email) ]

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Scheduler - observation

2013-12-13 Thread Marin Pranjić
So I have a task queued at 00:02:07.
I have a worker for that group with last_heartbeat 00:07:55.
Task is still QUEUED.
Worker is ACTIVE.
I have TWO is_ticker workers (usually it's one).

Scheduler is up for days, it usually works.


Two days ago I was resetting databases so I dropped most of the tables, 
including scheduler tables.
They got recreated after one minute (when I deleted *.table files, I use 
migrations) so probably in the meantime scheduler tried to read/write table 
that doesn't exist.
I didn't restart scheduler after that. And now it's just hanging around 
minding its own business, not caring about my queued tasks.


Everything works after restart. I am aware that my actions might have 
caused weird scheduler behavior.
I wrote this email because it might help, nothing else. I would be less 
surprised if scheduler just stopped.
But I guess it tried to recover from all the issues as it usually does, but 
somehow failed even if it acts completely ok (has heartbeat, schedules 
tasks).

Scheduler still rocks.

Marin

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Drop down not showing

2013-12-13 Thread Cliff Kachinske
What is this line all about?

db.t_user_has_companies.first_name.requires=IS_NOT_IN_DB(db(db.t_user_has_companies.f_coname==request.vars.f_coname),db.t_user_has_companies.first_name)

Also, these lines in your t_user_has_companies table def don't match what 
you say about them.
  Field('first_name', 'reference auth_user', label='User', 
writable=True, readable=True, notnull=True, required=True,  ondelete='NO 
ACTION', requires=IS_IN_DB(db, db.auth_user, '%(id)s %(first_name)s 
%(last_name)s')),
  Field('f_coname', 'reference t_companies', label='Company', 
writable=True, readable=True, notnull=True, required=True, ondelete='NO 
ACTION', requires=IS_IN_DB(db, db.t_companies, '%(id)s %(f_coname)s'))

I also defined User_Has_Companies which has 2 columns USER_ID and 
COMP_ID together should form a PK.

You don't need the required attributes as they are covered by IS_IN_DB. 
Why do you have the ondelete in there?

DAL doesn't support multi-column primary keys. 

This is awfully ambitious. Why don't you cut out a lot of the code and see 
if you can get it working something like the example in the on-line manual?


On Friday, December 13, 2013 3:48:14 PM UTC-5, Michel Hayek wrote:

 Hi guys,

 I have 2 tables defined Auth_User(PK=id) and Companies(PK=ID)
 I also defined User_Has_Companies which has 2 columns USER_ID and COMP_ID 
 together should form a PK.

 *db.py:*



 *#db.define_table('t_companies',  
   Field('f_coname',label='Company Name', required=True,ondelete='NO 
 ACTION',notnull=True),Field('f_comanager',label='Company 
 Manager', required=False,ondelete='NO ACTION',notnull=False),  
   Field('f_coemail',label='Company Email', required=False,ondelete='NO 
 ACTION',notnull=False))db.t_companies.f_coemail.requires = 
 IS_EMAIL(error_message='invalid 
 email!')*
 *db.define_table('t_user_has_companies',*
 *Field('first_name', 'reference auth_user', label='User', 
 writable=True, readable=True, notnull=True, required=True,  ondelete='NO 
 ACTION', requires=IS_IN_DB(db, db.auth_user, '%(id)s %(first_name)s 
 %(last_name)s')),*
 *Field('f_coname', 'reference t_companies', 
 label='Company', writable=True, readable=True, notnull=True, required=True, 
 ondelete='NO ACTION', requires=IS_IN_DB(db, db.t_companies, '%(id)s 
 %(f_coname)s'))*
 *   )*

 *db.t_user_has_companies.first_name.requires=IS_NOT_IN_DB(db(db.t_user_has_companies.f_coname==request.vars.f_coname),db.t_user_has_companies.first_name)*

 *In default.py:*
 *@auth.requires_login()*
 *def usercompanies():*
 *grid=SQLFORM.grid(db.t_user_has_companies)*
 *return locals()*

 it works fine but the problem is i only get one drop down for the 
 companies, as for the User it appears a text box. How this one also be set 
 to drop down box?

 Thanks


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Error with session when user tries to login

2013-12-13 Thread Massimo Di Pierro
have you deleted all sessions or are you using sessions created with a 
previous version?

On Friday, 13 December 2013 13:40:18 UTC-6, Marin Pranjić wrote:

 This happens when customer tries to login. I have no idea why it happens 
 and it works when I try it on localhost.


 web2py™Version 2.8.2-stable+timestamp.2013.11.28.07.51.37PythonPython 2.7.
 3: /usr/bin/python (prefix: /usr)

 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.

 Traceback (most recent call last):
   File /home/www-data/web2py/gluon/main.py, line 479, in wsgibase
 session._try_store_in_cookie_or_file(request, response)
   File /home/www-data/web2py/gluon/globals.py, line 1089, in 
 _try_store_in_cookie_or_file
 return self._try_store_in_file(request, response)
   File /home/www-data/web2py/gluon/globals.py, line 1096, in 
 _try_store_in_file
 or self._unchanged(response)):
   File /home/www-data/web2py/gluon/globals.py, line 1041, in _unchanged
 session_pickled = cPickle.dumps(self)
   File /usr/lib/python2.7/copy_reg.py, line 84, in _reduce_ex
 dict = getstate()
 TypeError: 'NoneType' object is not callable


 Any ideas? It's urgent so any suggestion is welcome.

 Marin


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: list:reference painfull to fill

2013-12-13 Thread Jesse Ferguson
sorry to hop in and ask a silly question but, when you say init the js on 
the field how is that supposed to be done in web2py? Is it done in the 
view? would it be ideal to put the js in the template and then pass params? 

 any named optional attribute is passed to the form tag

 for example _class, _id, _style, _action, _method, etc.


sorry if this doesn't make much sense I'm sure I am just missing the java 
knowledge I'm pretty new to programming and am learning through trial and 
error...

 

On Friday, December 13, 2013 7:54:48 AM UTC-8, Richard wrote:

 You init the js on the field!!

 Richard


 On Fri, Dec 13, 2013 at 10:20 AM, Kevin Bethke 
 kevin@gmail.comjavascript:
  wrote:

 Well actually I got one more question: How do you change the standard 
 form from web2py, to use the bsmselect form? 


 On Fri, Dec 13, 2013 at 4:18 PM, Kevin Bethke 
 kevin@gmail.comjavascript:
  wrote:

 Thanks it explains a lot. I will try to work on it as soon as I got the 
 time. Unfortunatly we got a deadline at work which is Christmas. So I will 
 probably not work on it till than.
  

 On Fri, Dec 13, 2013 at 3:53 PM, Richard Vézina 
 ml.richa...@gmail.comjavascript:
  wrote:

 I am sorry about that...

 Web2py default behavior for list:reference or reference is a HTML 
 Select and option... This is ordered by the navigator base on the spelling 
 of the element... So when you edit your form if you want to maintain the 
 preexisting order (the one that were there when you select items and order 
 them with bsm) you need to set them in order in the select yourself... 
 Bsmselect use OL that is Ordered List instead of UL... But it consume a 
 standard select... So, as long as he get a select with the proper ordered 
 options he can recreate the prexisting order... That is what the js I show 
 you does...

 ordered_values content the list:reference or the reference value that 
 are a simple python list... List are items of list are ordered not like 
 python dict that not preserve order... So I just get the value of the 
 field 
 that is a list object and pass it to the javascript as a list object... 
 then I create option from that list in javascript like you could do in 
 web2py with helpers for instance or by generating html yourself...

 Hope it helps.

 Richard


 On Fri, Dec 13, 2013 at 7:27 AM, Kevin Bethke 
 kevin@gmail.comjavascript:
  wrote:

 thanks but to be honest now I'm even more confused.
 why do you need a piece of jquery code in a javascript variable. I 
 sopose you included the entire jquery library.
  Why do you do the ordering with javascript and not with python is 
 there a special reason for this? I think I just explained the last 
 question  by looking at the code again. The document ready function is 
 executed every time you add or remove an element from the list?
 the javascript variable ordered_values=%s is filled from the 
 represent python variable?
 And my last question do you implement the multiple select into a form?
 Sry for all those questions but I'm still learning and the need for 
 this to work really pushes my skills and knowledge beyond its limits.


 On Thu, Dec 12, 2013 at 3:49 PM, Richard Vézina 
 ml.richa...@gmail.comjavascript:
  wrote:

 It's a bit hacky but it works...

 :)

 Richard


 On Thu, Dec 12, 2013 at 9:48 AM, Richard Vézina 
 ml.richa...@gmail.com javascript: wrote:

 Don't bother with the php thing...

 Just look the data structure of the select... 

 Here what I do to restore proper order on update form :

 controller_view_js += 
 var ordered_values = ''%s''; 
 $(document).ready(function() { 
 if(ordered_values != None) { 
 $.each(ordered_values, function(i, val) { 
 $(select[name=field_name]).append(option 
 value=\'+ordered_values[i]+\'+
 $(select[name=field_name] 
 option[value=+ordered_values[i]+]).text()+/option); 
 }); 
 $(select[name=field_name] option:selected).remove(); 
 $.each(ordered_values, function(i, val) { 
 $(select[name=field_name] 
 option[value=+ordered_values[i]+]).attr(selected, selected); 
 }); 
 }; 
 }); % [int(ID) for ID in ordered_values_query]

 controller_view_js is a variable containing a piece of jquery that I 
 pass to the view from the controller... What it does put the options 
 into 
 the proper order or how they were ordered at the input... All this is 
 because web2py don't use ol list out of the box... So I manage thing 
 to 
 not require ol.

 The ordered_values_query contain the value of the field field_name 
 for the given record...

 I had to set a representation like this too :

 represent=lambda values, row: ', '.join(map(lambda id: 
 db.ref_referenced_table(id).represent_field, values)) if values != [] 
 or 
 None else T('N/A')

 Hope it helps.

 Richard


 On Thu, Dec 12, 2013 at 4:07 AM, BlueShadow 
 kevin@gmail.comjavascript:
  wrote:

 thanks for your offer I'm working my way through the example 

[web2py] Re: help-block in Bootstrap forms

2013-12-13 Thread Paolo Caruccio
Thank you Niphlod. I see what you mean. I'll try to convert my code in 
order to build a custom formstyle. However, I'll share my code with the 
web2py users group: maybe it could be useful to someone. 
About the menu, I have in my mind a simple change to the MENU helper that 
should semplify its customization client side (jquery and css) but I have 
to investigate more on this.
Anyway, the menu complexity is due to lack of support for multilevel 
submenus. If we need a single level menu there's no need to modify the 
web2py code. 
For the sake of completeness, Foundation framework supports the multilevel 
menu, but its css breaks the web2py calendar css. 
It seems that every css framework has its own Achilles' Heel.  


Il giorno venerdì 13 dicembre 2013 20:33:40 UTC+1, Niphlod ha scritto:

 IMHO there's no point on having web2py serializing by default a structure 
 (response.menu) to a string (the html markup) and then reparse it back to a 
 structure (elements) to move a few pieces back and forth and then 
 reserializing those pieces back to html markup. It's just a waste of cpu.

 The way to go NEEDS to be modules with overrides, not server-side DOM 
 manipulations...
 I agree that right now you can only act on the MENU() function, but a way 
 must be figured out to avoid serverside DOM parsing or we'll soon face an 
 untouchable MENU() that can't accomodate for new features 'cause there are 
 lots of code expecting a fixed html markup.
 Same goes for forms and widgets: fortunately we have already a formstyle 
 that takes a callback, but I don't see why noone is coming up with a new 
 set of widgets that override the default one composing the html elements 
 the way they are supposed to be in the first place



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Drop down not showing

2013-12-13 Thread Michel Hayek
Ok here is the new table def.

db.define_table('t_user_has_companies1',
 Field('USER_ID', 'reference auth_user', label='User', 
 writable=True, readable=True, notnull=True, requires=IS_IN_DB(db, 
db.auth_user, '%(id)s %(first_name)s %(last_name)s')),
 Field('COMP_ID', 'reference t_companies', label='Company', 
writable=True, readable=True, notnull=True, requires=IS_IN_DB(db, 
db.t_companies, '%(id)s %(f_coname)s')))
#db.t_user_has_companies1.USER_ID.requires=IS_NOT_IN_DB(db(db.t_user_has_companies1.COMP_ID==request.vars.COMP_ID),db.t_user_has_companies1.USER_ID)

without the commented line (IS_NOT_IN_DB..) i won't be able to have a 
dropdown for the companies but also this line is removing the dropdown for 
the users.

If i comment the line, its not performing as a PK.

-- 
 

*This e-mail is confidential and may also be privileged. If you are not the 
intended **recipient, please notify the sender immediately, delete it from 
your system and do **not copy, disseminate, distribute or disclose any 
information contained therein.*

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Drop down not showing

2013-12-13 Thread 黄祥
just a suggestion, why not start your code from simple, like the python 
philosophy 'simple is better than complex, complex is better than 
complicated'?
after start your code from simple than add the DAL field constructor one by 
one.
e.g. 
*step 1 : for starting i comment the on_define (for dal field constructor), 
test is the table is work as expected or not*
# on_define_department
def on_define_department(table): 
# label
table.department.label = T('Department')
# notnull
table.department.notnull = True
# required
table.department.required = True
# requires
table.department.requires = IS_NOT_IN_DB(db, table.department)
# unique
table.department.unique = True

# create table : department
db.define_table('department', 
Field('department'), 
# on_define = on_define_department, 
format = '%(department)s')

*step 2 : test the dal field constructor label, after it works, release the 
commented dal field constructor one by one*
# on_define_department
def on_define_department(table): 
# label
table.department.label = T('Department')
# notnull
# table.department.notnull = True
# required
# table.department.required = True
# requires
# table.department.requires = IS_NOT_IN_DB(db, table.department)
# unique
# table.department.unique = True

# create table : department
db.define_table('department', 
Field('department'), 
on_define = on_define_department, 
format = '%(department)s')

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] dal store data in more than 1 database

2013-12-13 Thread 黄祥
hi,

is it possible for dal store data in more than 1 database? 

let say i use database 'production1' with mysql backend, while during the 
daily usage i want to make a copy of that database also in sqlite backend 
or maybe another database name 'testing1' with mysql backend. 

i know i can do it manually or using scheduler for backup sqldump and then 
restore it to another database as needed, but it is in infrastructure side, 
i want to know how to achieve it in web2py way?

is there any significant impact in performance terms?

thanks and best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Multiple submit buttons using selectable in SQLFORM.grid

2013-12-13 Thread Tim Richardson
multiple action buttons via passing a list to selectable is now documented in 
the book (github) 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Field (..update=auth.id..) does not seem to work for me.

2013-12-13 Thread TSmith
There exists a table.  I added the modified_by field as shown below.  I 
also tried the second version which is what I really want.

db.define_table('DOCUMENTATION',
Field('documentation_type','string'),
Field('modified_by', 'reference auth_user',
  default=auth.user_id, update=auth.user_id, writable=False))

db.define_table('DOCUMENTATION',
Field('documentation_type','string'),
Field('modified_by', 'string',
  default=auth.user, update=auth.user, writable=False))

I then modify (via SQLForm) a row in the table.  checking the database with 
SQL I can see that the modified_by column is added to the table.  But the 
row that I modified is null.

Why:  I know auth has record versioning, but I have multiple application 
that use the database.  I use triggers to audit changes to key reference 
tables.  In these triggers I see web2py in the application field (nice 
for setting that).  I'd like to have the modified_by field update with each 
change to make it easier to see who did what.

-- end of question
New to the software.  Liking it very much. thanks to all those who 
contribute.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Reddit Clone Week 3 video jQuery error

2013-12-13 Thread Doug Hauenstein
I am following the week 3 video and trying to learn by doing so I am trying 
to duplicate the application as presented in the video.

Do I have to initialize jQuery or do I have a syntax error???
firebug ooutput: ===

ReferenceError: JQuery is not defined
http://127.0.0.1:8000/reddit_clone/default/list_posts_by_votes/programming
Line 285
=
RE:  list_posts_by_votes.html
adding syntax so the buttons button data-direction= up-/button etc

The button action does not work and I get the following error in firebug:

script
function do_ajax_vote(t,direction)  {- Line 285  ---
   alert('clicked');
}

JQuery(function()  {
  jQuery('[data-direction=up').click(function(){do_ajax_vote(this,'up');});
  jQuery('[data-direction=dw').click(function(){do_ajax_vote(this,'dw');});
});
/script

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: help-block in Bootstrap forms

2013-12-13 Thread LightDot
Most of the work already done on bootstrap 3, foundation 5, etc. can be 
reused. The DOM manipulating parts are also bound to be useful - as an 
example of what can be done, if nothing else.

I'm using the plugin_layout_cssfw functionality to keep bootstrap 2  3, 
bootswatch 2  3 and foundation 5 playing along within a single app. I'm 
aiming for slightly different bs2, bs3, foundation5, etc. welcome apps, 
that can be packed as plugin_layout_cssfw and updated as someone needs 
them.

About the other part of the equation - the support for different CSS 
frameworks from within gluon or contrib - there was a discussion about how 
to implement all this a while ago and I think we really ought to finish 
it...

My thoughts as far as functionality goes:
- user would set a global variable (ie. styleserializer=bootstrap3 ..or 
bootstrap2, foundation5 or some other predefined style) and thus define the 
serialization of menus, forms, tables, grid, flash messages, etc. all in 
one place
- existing menu, formstyle, etc. functionality stays, this is needed for 
backward compatibility and is also useful. User could ie. use the global 
variable to set everything to bootstrap3, then override the formstyle 
setting for one specific form to, let's say, bootstrap3-inline.

All that is left for a user is to drop in a correct welcome app and voila, 
foundation 5 or bootstrap 3 based web2py.

The implementation is something I'm not clear about. Should everything be 
kept in gluon, as it is now..? Should old formstyles (table3cols, etc.) 
stay within gluon, while bootstrap, bootstrap3 (it's already done, since 
recently) and future ones get moved to contrib?  Should MENU() be 
deprecated, keeping it as is, or should it be extended to accomodate more 
CSS frameworks? Perhaps a new menu function altogether, in contrib?

What else am I not thinking of..?


On Saturday, December 14, 2013 12:50:04 AM UTC+1, Paolo Caruccio wrote:

 Thank you Niphlod. I see what you mean. I'll try to convert my code in 
 order to build a custom formstyle. However, I'll share my code with the 
 web2py users group: maybe it could be useful to someone. 
 About the menu, I have in my mind a simple change to the MENU helper that 
 should semplify its customization client side (jquery and css) but I have 
 to investigate more on this.
 Anyway, the menu complexity is due to lack of support for multilevel 
 submenus. If we need a single level menu there's no need to modify the 
 web2py code. 
 For the sake of completeness, Foundation framework supports the multilevel 
 menu, but its css breaks the web2py calendar css. 
 It seems that every css framework has its own Achilles' Heel.  


 Il giorno venerdì 13 dicembre 2013 20:33:40 UTC+1, Niphlod ha scritto:

 IMHO there's no point on having web2py serializing by default a structure 
 (response.menu) to a string (the html markup) and then reparse it back to a 
 structure (elements) to move a few pieces back and forth and then 
 reserializing those pieces back to html markup. It's just a waste of cpu.

 The way to go NEEDS to be modules with overrides, not server-side DOM 
 manipulations...
 I agree that right now you can only act on the MENU() function, but a way 
 must be figured out to avoid serverside DOM parsing or we'll soon face an 
 untouchable MENU() that can't accomodate for new features 'cause there are 
 lots of code expecting a fixed html markup.
 Same goes for forms and widgets: fortunately we have already a formstyle 
 that takes a callback, but I don't see why noone is coming up with a new 
 set of widgets that override the default one composing the html elements 
 the way they are supposed to be in the first place



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Field (..update=auth.id..) does not seem to work for me.

2013-12-13 Thread Massimo Di Pierro
Should not be default=auth.user but default=auth.user_id (same for 
update=...) Anyway you will get Null when user_id is None.

On Friday, 13 December 2013 12:23:49 UTC-6, TSmith wrote:

 There exists a table.  I added the modified_by field as shown below.  I 
 also tried the second version which is what I really want.

 db.define_table('DOCUMENTATION',
 Field('documentation_type','string'),
 Field('modified_by', 'reference auth_user',
   default=auth.user_id, update=auth.user_id, writable=False))

 db.define_table('DOCUMENTATION',
 Field('documentation_type','string'),
 Field('modified_by', 'string',
   default=auth.user, update=auth.user, writable=False))

 I then modify (via SQLForm) a row in the table.  checking the database 
 with SQL I can see that the modified_by column is added to the table.  But 
 the row that I modified is null.

 Why:  I know auth has record versioning, but I have multiple application 
 that use the database.  I use triggers to audit changes to key reference 
 tables.  In these triggers I see web2py in the application field (nice 
 for setting that).  I'd like to have the modified_by field update with each 
 change to make it easier to see who did what.

 -- end of question
 New to the software.  Liking it very much. thanks to all those who 
 contribute.





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Reddit Clone Week 3 video jQuery error

2013-12-13 Thread Massimo Di Pierro
JQuery should be jQuery

On Friday, 13 December 2013 15:30:06 UTC-6, Doug Hauenstein wrote:

 I am following the week 3 video and trying to learn by doing so I am 
 trying to duplicate the application as presented in the video.

 Do I have to initialize jQuery or do I have a syntax error???
 firebug ooutput: ===

 ReferenceError: JQuery is not defined
 http://127.0.0.1:8000/reddit_clone/default/list_posts_by_votes/programming
 Line 285
 =
 RE:  list_posts_by_votes.html
 adding syntax so the buttons button data-direction= up-/button 
 etc

 The button action does not work and I get the following error in firebug:

 script
 function do_ajax_vote(t,direction)  {- Line 285  ---
alert('clicked');
 }

 JQuery(function()  {
   jQuery('[data-direction=up').click(function(){do_ajax_vote(this,'up');});
   jQuery('[data-direction=dw').click(function(){do_ajax_vote(this,'dw');});
 });
 /script


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Reddit Clone Week 3 video jQuery error

2013-12-13 Thread Doug Hauenstein
Syntax! Thank you!

On Friday, December 13, 2013 8:38:24 PM UTC-5, Massimo Di Pierro wrote:

 JQuery should be jQuery

 On Friday, 13 December 2013 15:30:06 UTC-6, Doug Hauenstein wrote:

 I am following the week 3 video and trying to learn by doing so I am 
 trying to duplicate the application as presented in the video.

 Do I have to initialize jQuery or do I have a syntax error???
 firebug ooutput: ===

 ReferenceError: JQuery is not defined
 http://127.0.0.1:8000/reddit_clone/default/list_posts_by_votes/programming
 Line 285
 =
 RE:  list_posts_by_votes.html
 adding syntax so the buttons button data-direction= up-/button 
 etc

 The button action does not work and I get the following error in firebug:

 script
 function do_ajax_vote(t,direction)  {- Line 285  ---
alert('clicked');
 }

 JQuery(function()  {
   
 jQuery('[data-direction=up').click(function(){do_ajax_vote(this,'up');});
   
 jQuery('[data-direction=dw').click(function(){do_ajax_vote(this,'dw');});
 });
 /script



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.