[web2py] Re: Static form control in case of read only field

2014-01-21 Thread Annet
Hi Anthony,

This line:

 _controls = DIV(controls, _help, _class='col-sm-6 controls')

 puts the content inside the DIV in question. If you don't want that in 
 case of read-only fields, you'll need to first check whether controls is 
 a form widget (i.e., input, select, or textarea), and don't wrap it in the 
 DIV if not.



I am not sure whether I solved the issue correctly but this solution works:

 # embed _help into _controls
if not (isinstance(controls, INPUT) and isinstance(controls, SELECT) and 
isinstance(controls, TEXTAREA)):
_controls = DIV(P(controls, _help, _class='form-control-static'), 
_class='col-sm-6 controls')
else:
_controls = DIV(controls, _help, _class='col-sm-6 controls')


Why does the comment say: # embed _help into _controls
Isn't it the field value I want to be enclosed by p/p


Hi Paolo,

I downloaded web2py 2.8.2 and you're right, no more issues.
About the flash, I always put it right above the form, and never give it a 
fixed position, for
some of my forms are preceded with a headline and text, other forms only 
occupy a
small part of the page, in those cases the flash message may be overlooked 
or block
content.


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 options, visit https://groups.google.com/groups/opt_out.


[web2py] running scheduler under a user

2014-01-21 Thread Jayadevan M
I wanted to set up the scheduler and execute a few jobs. To prevent the 
python files being executed by other users, I have added a condition 
auth.has_membership('scheduler') in the functions. How can I make the 
scheduler start with a user who in in the scheduler group? Or I am going 
down the wrong path?

-- 
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] google login and scheduler/appadmin etc

2014-01-21 Thread Jayadevan M
I have enabled google login. Once that is done, when I start web2py for 
admin activities (127.0.0.1) with password, I can go to the admin interface 
and then to edit of myapp. But from Edit, if I click on database 
administration, it errors out. 

That link points to   redirects to 127.0.0;1/myapp/appadmin.index, which 
requires google login. googlelogin does not accept request from 127.0.0.1. 
So I am stuck. With some hard-coding like if   
request.controller=='appadmin', the issue was resolved. What is the 
standard/best  practice?

-- 
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 files

2014-01-21 Thread Jayadevan M
In web2py, which is the 'right' place to put the python files with 
scheduler functions? Right now I have it under controllers. 

-- 
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: New to web2py

2014-01-21 Thread Ray Allen
I too have noticed that the syntax from the design tool isn't consistent 
with the requirements of web2py and causing me lots of errors.

-- 
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: How to create a dropdown selection page?

2014-01-21 Thread 黄祥
had you already take a look at multiple forms per page in web2py book?
ref:
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Multiple-forms-per-page

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: DAL usage

2014-01-21 Thread 黄祥
brilliant, never thought of that. thank you so much. yes i agree with you 
about the advantage of using models_to_run rather than importing tables 
from modules.

thanks and best regards,
stifan

On Tuesday, January 21, 2014 1:17:57 AM UTC+7, Anthony wrote:

 appadmin is just a controller, like any other, so it only sees models 
 defined in model files (note, there is special logic that runs all model 
 files when the appadmin controller is called, even if 
 response.models_to_run would normally make some models conditional). 
 appadmin can't know what models might be imported by other controllers. In 
 a model file, you could do something like:

 if request.controller == 'appadmin':
 [code to import and define all models]

 I suppose one advantage of using models_to_run rather than importing from 
 modules is you get full appadmin functionality without a workaround like 
 the above.

 Anthony

 On Monday, January 20, 2014 10:19:12 AM UTC-5, 黄祥 wrote:

 hi anthony,

 */modules/mymodule.py:*

 from gluon import Field

 def mymodels(db):
 db.define_table('table1', Field('field1'), Field('field2'))
 db.define_table('table2', Field('field1'), Field('field2'))

 */models/db.py or /controllers/some_controller.py:*

 from mymodule import mymodels
 mymodels(db)

 in your example above, it said that the import can be on models and 
 controllers, i've test both (put in models and in controllers), if i just 
 put in controllers, the database administration (appadmin) for table1 and 
 table2 is not shown, the database administration (appadmin) for table1 and 
 table2 will shown if i import mymodels(db) in models.

 my question, is it possible to import mymodels in controllers yet still 
 got access for database adminsitration (appadmin) for table1 and table2 
 without import it in models?

 ref:
 https://groups.google.com/forum/#!topic/web2py/b65mya4wamg

 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.


[web2py] tools to edit web2py layout

2014-01-21 Thread 黄祥
hello folks,

i just want to know which tools did you use to edit web2py layout (twitter 
bootstrap)? for web2py layout i usually replace it from bootswatch, 
download pingendo, create the layout, but don't know how to adopt it with 
web2py layout. any hints, or suggestions?

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: Overriding Grid/Smartgrid's 'Edit/Delete/View'

2014-01-21 Thread horridohobbyist
Yes, I did. But I shouldn't have included arguments in the 'view' function. 
That was the error.

So how do I extract the arguments 'products' and '11' (in my example) in 
the view function? response._vars apparently does not contain them.

Thanks.

On Tuesday, 21 January 2014 01:35:52 UTC-5, Johann Spies wrote:

 Did you create a function 'view'  in the default controller?

 Regards
 Johann


 On 21 January 2014 06:44, horridohobbyist horrido...@gmail.comjavascript:
  wrote:

 I can't get this to work. I'm new to web2py. Perhaps I don't understand 
 the argument-passing mechanism...

 In SQLFORM.grid, I have:

 links=[lambda row: A('View',_href=URL('view',args=[db.products,row.id
 ]))],

 In the default controller, I have:

 def view(table,id):
 return dict()

 I get the following error:

 invalid function (default/view)

 ...with this:

 https://my_ip_addr/HorridoHobbies/default/view/products/11

 Shouldn't the arguments 'products' and '11' be passed to the view 
 function? What am I not understanding?

 Thanks.

 On Thursday, 6 October 2011 08:36:26 UTC-4, simon wrote:

 You can add your own buttons using: 

 links = [lambda row: A('Edit',_href=URL(controller,edit, 
 args=[update, tablename, a.id])) 

 and set editable, deletable, details  to False. 


 On Oct 6, 12:48 pm, Johann Spies johann.sp...@gmail.com wrote: 
  How do I override the views/controllers  triggered by the buttons 
  mentioned 
  in the subject line when using SQLFORM.grid/smartgrid? 
  
  Regards 
  Johann 
  
  -- 
   May grace and peace be yours in abundance through the full knowledge 
 of God 
  and of Jesus our Lord!  His divine power has given us everything we 
 need for 
  life and godliness through the full knowledge of the one who called us 
 by 
  his own glory and excellence. 
  2 Pet. 1:2b,3a

  -- 
 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+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




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

-- 
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: How to create a dropdown selection page?

2014-01-21 Thread Adrian Zhang
Thanks for reply.
Actually SQLFORM is exactly my confusion.I need a drop-down list instead of 
input form. And I did view several posts about this problem (such as listed 
below), none of them works for me.

http://www.web2pyslices.com/slice/show/1724/cascading-dropdowns-simplified
http://stackoverflow.com/questions/10387672/web2py-dropdown-menu
http://markmail.org/message/ybt655wfijubhh7x#query:+page:1+mid:ef5eg3alxsgqydyr+state:results
http://stackoverflow.com/questions/16787802/web2py-sqlform-dropdown-without-submit-and-form-actions

Problem is, non of them explain SQLFORM usage clearly, from drop-down point 
of view. Where can I find a simple case of drop-down? Just like the simple 
sample in the manual like photo blog, wiki, those are very useful to a 
beginner to understand how MVC works.

But for drop-down problem, what should be defended in models/db.py, 
controllers/default.py and views/default/drop-down.html? Any help is 
appreciate. 


On Tuesday, January 21, 2014 8:37:31 PM UTC+8, 黄祥 wrote:

 had you already take a look at multiple forms per page in web2py book?
 ref:

 http://web2py.com/books/default/chapter/29/07/forms-and-validators#Multiple-forms-per-page

 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: Overriding Grid/Smartgrid's 'Edit/Delete/View'

2014-01-21 Thread horridohobbyist
Ah, I think I know! The arguments are passed in request.args. Right?


On Tuesday, 21 January 2014 08:00:19 UTC-5, horridohobbyist wrote:

 Yes, I did. But I shouldn't have included arguments in the 'view' 
 function. That was the error.

 So how do I extract the arguments 'products' and '11' (in my example) in 
 the view function? response._vars apparently does not contain them.

 Thanks.

 On Tuesday, 21 January 2014 01:35:52 UTC-5, Johann Spies wrote:

 Did you create a function 'view'  in the default controller?

 Regards
 Johann


 On 21 January 2014 06:44, horridohobbyist horrido...@gmail.com wrote:

 I can't get this to work. I'm new to web2py. Perhaps I don't understand 
 the argument-passing mechanism...

 In SQLFORM.grid, I have:

 links=[lambda row: A('View',_href=URL('view',args=[db.products,row.id
 ]))],

 In the default controller, I have:

 def view(table,id):
 return dict()

 I get the following error:

 invalid function (default/view)

 ...with this:

 https://my_ip_addr/HorridoHobbies/default/view/products/11

 Shouldn't the arguments 'products' and '11' be passed to the view 
 function? What am I not understanding?

 Thanks.

 On Thursday, 6 October 2011 08:36:26 UTC-4, simon wrote:

 You can add your own buttons using: 

 links = [lambda row: A('Edit',_href=URL(controller,edit, 
 args=[update, tablename, a.id])) 

 and set editable, deletable, details  to False. 


 On Oct 6, 12:48 pm, Johann Spies johann.sp...@gmail.com wrote: 
  How do I override the views/controllers  triggered by the buttons 
  mentioned 
  in the subject line when using SQLFORM.grid/smartgrid? 
  
  Regards 
  Johann 
  
  -- 
   May grace and peace be yours in abundance through the full knowledge 
 of God 
  and of Jesus our Lord!  His divine power has given us everything we 
 need for 
  life and godliness through the full knowledge of the one who called 
 us by 
  his own glory and excellence. 
  2 Pet. 1:2b,3a

  -- 
 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




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


-- 
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: Static form control in case of read only field

2014-01-21 Thread Annet
Hi Paolo,

About the checkboxes and radio controls please note that the package works 
 since Version 2.8.2-stable+timestamp.2013.12.17.16.49.17 of web2py. In the 
 previous versions the related widget


 I downloaded web2py version 2.8..2 for normal users and for testers both 
are: Version 2.8.2-stable+timestamp.2013.11.28.13.54.07

Will replacing gluon/sqlhtml.py with gluon/sqlhtml.py from the developers 
version solve the problem, or will this
result in conflicts with other files.


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 options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: web2py --run-system-tests

2014-01-21 Thread Massimo Di Pierro
Windows has no fork. I do not think we have ever run tests on windows. Try 
with cygwin

On Monday, 20 January 2014 23:16:12 UTC-6, Kiran Subbaraman wrote:

 Hello,
 I was trying to figure out how to run tests against web2py (in the case 
 where I contribute changes to web2py).
 Ran 
 python web2py.py --help 


 This listed --run-system-tests as an option

 Ran this, and this is the output I see (I have to kill the process; unable 
 to stop it otherwise)

 testInvalidUrls (gluon.tests.test_is_url.TestIsGenericUrl) ... ok
 testPrepending (gluon.tests.test_is_url.TestIsGenericUrl) ... ok
 testValidUrls (gluon.tests.test_is_url.TestIsGenericUrl) ... ok
 testInvalidUrls (gluon.tests.test_is_url.TestIsHttpUrl) ... ok
 testPrepending (gluon.tests.test_is_url.TestIsHttpUrl) ... ok
 testValidUrls (gluon.tests.test_is_url.TestIsHttpUrl) ... ok
 testExceptionalUse (gluon.tests.test_is_url.TestIsUrl) ... ok
 testModeGeneric (gluon.tests.test_is_url.TestIsUrl) ... ok
 testModeHttp (gluon.tests.test_is_url.TestIsUrl) ... ok
 testRun (gluon.tests.test_dal.TestJoin) ... ok
 test_reads_and_writes (gluon.tests.test_languages.TestLanguagesParallel) 
 ... Traceback (most recent call last):
   File string, line 1, in module
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
 Traceback (most recent call last):
   File string, line 1, in module
 prepare(preparation_data)
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 prepare(preparation_data)
 assert main_name not in sys.modules, main_name
 Traceback (most recent call last):
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 AssertionError  File string, line 1, in module
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
 Traceback (most recent call last):
 Traceback (most recent call last):
   File string, line 1, in module
 :   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
   File string, line 1, in module
 Traceback (most recent call last):
 assert main_name not in sys.modules, main_name
 Traceback (most recent call last):
 _  File string, line 1, in module
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
 prepare(preparation_data)
   File string, line 1, in module
 prepare(preparation_data)
 AssertionErrorTraceback (most recent call last):
 _main__  File D:\programs\open\python27\lib\multiprocessing\forking.py,line 
 380, in main
 prepare(preparation_data)
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 :   File string, line 1, in module
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 Traceback (most recent call last):
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 _prepare(preparation_data)
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main


 I am running these tests on Window 8.1, from within the power-shell. I am 
 suspecting this is an OS related issue; where I need to run the tests on a 
 *nix box?



-- 
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: Static form control in case of read only field

2014-01-21 Thread Anthony


  # embed _help into _controls
 if not (isinstance(controls, INPUT) and isinstance(controls, SELECT) and 
 isinstance(controls, TEXTAREA)):
 _controls = DIV(P(controls, _help, _class='form-control-static'), 
 _class='col-sm-6 controls')
 else:
 _controls = DIV(controls, _help, _class='col-sm-6 controls')


That doesn't look like it will work -- the first branch will only execute 
if controls is an instance of all three types of widgets, which will never 
be true. I think you want:

if not isinstance(controls, (INPUT, SELECT, TEXTAREA)): 

Why does the comment say: # embed _help into _controls


Don't know. I thought that was your own custom function.

Anthony

-- 
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: Overriding Grid/Smartgrid's 'Edit/Delete/View'

2014-01-21 Thread Anthony


 links=[lambda row: A('View',_href=URL('view',args=[db.products,row.id]))],


First, note that the URL function produces a string, so putting db.products 
in args is equivalent to str(db.products), which will result in just 
products.
 

 def view(table,id):
 return dict()


As noted in the book, any function in a controller that accepts arguments 
is *not* exposed as an action accessible via URL (in other words, it is a 
private function). To access args passed via a URL (i.e., the part of the 
URL path that comes after /app/controller/function), you must use 
request.args (i.e., request.args(0) is the first argument, etc.).

Anthony

-- 
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: tools to edit web2py layout

2014-01-21 Thread Anthony
As for tools, just a text editor should do. To adapt a layout, the best 
guide is to look at the welcome app layout as well as the 
bookhttp://web2py.com/books/default/chapter/29/05/the-views#Page-layout
.

Anthony

On Tuesday, January 21, 2014 7:46:28 AM UTC-5, 黄祥 wrote:

 hello folks,

 i just want to know which tools did you use to edit web2py layout (twitter 
 bootstrap)? for web2py layout i usually replace it from bootswatch, 
 download pingendo, create the layout, but don't know how to adopt it with 
 web2py layout. any hints, or suggestions?

 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.


[web2py] Re: Routes.py not working with auth dialogs

2014-01-21 Thread Anthony
Perhaps you're using an older version of web2py. See 
https://github.com/web2py/web2py/blob/master/gluon/tools.py#L1127.

Anthony

On Tuesday, January 21, 2014 1:58:59 AM UTC-5, Joe Barnhart wrote:

 Ah... no such luck.

 def here(self):
 return current.request.env.request_uri




 On Monday, January 20, 2014 10:05:32 AM UTC-8, Anthony wrote:

 I haven't looked into this in detail, but note that self.here() does in 
 fact use the URL() function to generate the next variable.

 Anthony

 On Monday, January 20, 2014 12:25:59 PM UTC-5, Joe Barnhart wrote:

 I think I have found the underlying problem in tools.py, but I'm not 
 sure it is even fixable.

 The issue is that routes.py only works if you use the URL() function, 
 but the decorator @auth.requires_login doesn't use the URL function when it 
 presets the next field.  So everything works consistently except the 
 next after logon, which always fails because (in my case) it contains the 
 application name.  Here is the relevant part of the decorator:

 def requires(self, condition, requires_login=True, otherwise=None):
 
 decorator that prevents access to action if not logged in
 

 def decorator(action):

 def f(*a, **b):

 basic_allowed, basic_accepted, user = self.basic()
 user = user or self.user
 if requires_login:
 if not user:
 . . .
 else:
 next = self.here()
 current.session.flash = 
 current.response.flash
 return call_or_redirect(
 self.settings.on_failed_authentication,
 self.settings.login_url +
 '?_next=' + urllib.quote(next))

 if callable(condition):
 flag = condition()
 else:
 flag = condition
 if not flag:
 current.session.flash = self.messages.access_denied
 return call_or_redirect(
 self.settings.on_failed_authorization)
 return action(*a, **b)
 f.__doc__ = action.__doc__
 f.__name__ = action.__name__
 f.__dict__.update(action.__dict__)
 return f

 return decorator


 I'm not sure this is even fixable since it would require 
 reverse-engineering a string back into the format desired for URL().  In 
 the short term, I fixed it by overriding the next= variable on the 
 creation of the login dialog box.  This is from my default controller, and 
 it works as expected:

 def user():
 cmd=request.url.split('/')[-1]
 if cmd=='register':
 . . .
 
 elif cmd=='login':
 return dict(form=auth.login(next=URL('register','index')))
 return dict(form=auth())


  



-- 
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: Routes.py not working with auth dialogs

2014-01-21 Thread Anthony
The parameter based system was designed to make such common scenarios much 
easier. If all you want to do is remove the app name and the index 
function, your entire routes.py would just be:

routers = dict(
BASE = dict(
default_application = 'myapp',
default_controller = 'default',
default_function = 'index'
functions = ['list', 'of', 'functions', 'in', 'default', 
'controller']
)
)

Note, that last line (listing the functions) is optional, but needed in 
order to resolve ambiguities with URL args.

Anthony

On Tuesday, January 21, 2014 2:02:43 AM UTC-5, Joe Barnhart wrote:

 Oh man... Now you're gonna make me learn a whole new system!?!?  

 The short answer is, I've been too lazy to look at it yet.  I'm just 
 trying to get rid of the application name everywhere because it seems so... 
 redundant!  My dns name already has the name of the site, then it gets 
 repeated in the application.  For. Every. Single. Page. In. The. Site.

 I'll look into the parameter based thing.  I'm on a biz trip and looking 
 at 14 hours in the air anyway...  Plenty of time to learn a new trick...

 -- Joe


 On Monday, January 20, 2014 10:09:20 AM UTC-8, Anthony wrote:

 Seems like this would be a lot easier using the parameter-based rewrite 
 system.

 Anthony

 On Sunday, January 19, 2014 4:01:46 PM UTC-5, Joe Barnhart wrote:

 I'm trying to do the simplest routes.py possible.  I just want to get 
 rid of the application name -- EVERYWHERE.  In addition, I'd like my main 
 page (index.html) to just appear without any default controller in the 
 URL.  The problem is, the auth login dialog always includes my application 
 name in the next= field of the login form.  Nothing I do seems to affect 
 it.

 My routes.py is pretty simple...  It's the default example routes.py 
 with the following additions:


 default_application = 'my_app_name' # ordinarily set in base 
 routes.py
 default_controller = 'default'  # ordinarily set in app-specific 
 routes.py
 default_function = 'index'  # ordinarily set in app-specific 
 routes.py


 BASE = ''  # optonal prefix for incoming URLs

 routes_in = (
 # do not reroute admin unless you want to disable it
 (BASE + '/admin', '/admin/default/index'),
 (BASE + '/admin/$anything', '/admin/$anything'),
 # do not reroute appadmin unless you want to disable it
 (BASE + '/$app/appadmin', '/$app/appadmin/index'),
 (BASE + '/$app/appadmin/$anything', '/$app/appadmin/$anything'),
 #(BASE + '/appadmin', '/%s/appadmin'%default_application),
 # do not reroute static files
 (BASE + '/$app/static/$anything', '/$app/static/$anything'),
 # reroute favicon and robots, use exable for lack of better choice
 ('/favicon.ico', '/examples/static/favicon.ico'),
 ('/robots.txt', '/examples/static/robots.txt'),
 # route default app
 (BASE + '/index.html', 
 '/%s/%s/index.html'%(default_application,default_controller)),
 (BASE + '/about.html', 
 '/%s/%s/about.html'%(default_application,default_controller)),
 (BASE + '/$anything', '/%s/$anything'%default_application),
 # do other stuff
 ((r'.*http://otherdomain.com.* (?Pany.*)', r'/app/ctr\gany')),
 # remove the BASE prefix
 (BASE + '/$anything', '/$anything'),
 )


 routes_out = (
 # do not reroute admin unless you want to disable it
 ('/admin/$anything', BASE + '/admin/$anything'),
 # do not reroute appadmin unless you want to disable it
 ('/$app/appadmin/$anything', BASE + '/$app/appadmin/$anything'),
 # do not reroute static files
 ('/$app/static/$anything', BASE + '/$app/static/$anything'),
 # do other stuff
 (r'.*http://otherdomain.com.* /app/ctr(?Pany.*)', r'\gany'),
 (r'/app(?Pany.*)', r'\gany'),
 # map default application
 ('/%s/%s/index.html'%(default_application,default_controller), 
 '/index.html'),
 ('/%s/%s/about.html'%(default_application,default_controller), 
 '/about.html'),
 ('/%s/$anything'%default_application, '/$anything'),
 # restore the BASE prefix
 ('/$anything', BASE + '/$anything'),
 )


 This seems like a pretty simple application of routes.py, and I would 
 expect it to be a popular use for it.  I don't know anyone who wants their 
 root page to be festooned with the application name when it is constant 
 across every page in the site.

 Warm regards,

 Joe




-- 
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: Weird problems generating menu from database

2014-01-21 Thread americandewd
I attempted to copy/paste what you have so I can modify it for my needs.  
However it immediately errors out with:

AttributeError: 'Table' object has no attribute 'parent'

So I thought I would comment out everything for the menu except 
response.menu = [] and populate the database (have done this before and the 
site comes up just no menu as expected).

I then decided to try and populate the database fields.

However when I try to populate it I immediately get an error 
IntegrityError: FOREIGN KEY constraint failed. What I did was, put 
Animals for the title, for description I put Main Animals Category, 
then for the parent catelog I put Animals again.  Upon seeing this I'm 
confused as to how a subcategory would get identified.  So I also tried 
just putting Animals for the title, and filling in the description as 
above, but leaving the parent catelog blank, it to also failed with exactly 
the same error IntegrityError: FOREIGN KEY constraint failed.  So 
effectively I'm unable to even put anything in the fields, an issue I never 
had so I'm unsure what the problem is.

Would it be possible to use the fields I have already established to 
populate the menu?  Since you have 3 fields identified in your table albeit 
with slight differences, would it be possible to somehow incorporate that 
into what I have?  Could you also explain why you used += instead of 
append?  Maybe I could figure out something from that.

Thanks

On Tuesday, January 21, 2014 12:11:59 AM UTC-6, James Burke wrote:

 Hi,

 I managed to get one working a little while ago doing this. This has been 
 adapted for your situation, may require some tweaking:

 _tables.py - model
 db.define_table('store_catelog')


 db.define_table('store_catelog',
 Field('title', 'string'),
 Field('description', 'text'),
 Field('parent_catelog', 'reference store_catelog', default=None),
 format='%(title)s',
 redefine=True)

 menu.py - model
 response.menu = []

 categories = db(db.store_catelog.parent == None).select(orderby=db.
 store_catelog.id)

 for category in categories:
 response.menu+=[ (T(category.title), True if active_page == str(
 category.title.lower()) else False, URL('default','page/%s' % (category.
 title.lower())), [
 (T(i.title), True if active_page == str(i.id) else False, URL(
 'default','page/%s' % (i.id)), []) for i in db((db.stored_category.parent 
 == category.id)).select(db.store_category.ALL) if i.parent == category.id
 ]) ]

 The query returns any categories without a parent and adds them to the 
 menu. While doing so looks for any subcategories using the category as a 
 parent.

 Hope that helps you out.

 -James

 On Tuesday, January 21, 2014 9:33:50 AM UTC+13, americ...@gmail.com wrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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] Install Web2py on Windows with Apache and Mod WSGI (using command line, *nix flavour)

2014-01-21 Thread 黄祥


just want to share, enjoy, n please let me know if you meet any problems


Change :
- Network Domain with your Network Domain Name

- Server Name with your Server Name

- Administrator Email Address with your Administrator Email Address

- Change Path with your Own Path

   1. 
   
   Open Command Prompt (Start  Accessories  Command Prompt)
   2. 
   
   Download and Install Python Windows binary
   powershell -Command (New-Object 
   
Net.WebClient).DownloadFile('http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi',
 
   'C:\Users\sugizo\Desktop\python-2.7.6.msi')
   C:\Users\sugizo\Desktop\python-2.7.6.msi
   3. 
   
   Download Apache 2.2 with ssl support
   powershell -Command (New-Object 
   
Net.WebClient).DownloadFile('http://apache.mirrors.hoobly.com//httpd/binaries/win32/httpd-2.2.25-win32-x86-openssl-0.9.8y.msi',
 
   'C:\Users\sugizo\Desktop\httpd-2.2.25-win32-x86-openssl-0.9.8y.msi')
   C:\Users\sugizo\Desktop\httpd-2.2.25-win32-x86-openssl-0.9.8y.msi
   4. 
   
   Setting Apache during Installation
   Network Domain : domain.com
   Server Name : sugizo.domain.com
   Administrator Email Address : sug...@domain.com
   5. 
   
   Download Mod WSGI Win32/Apache 2.2/Python 2.7
   powershell -Command (New-Object 
   
Net.WebClient).DownloadFile('https://modwsgi.googlecode.com/files/mod_wsgi-win32-ap22py27-3.3.so',
 
   'C:\Users\sugizo\Desktop\mod_wsgi.so')
   6. 
   
   Download Web2py Source Code
   powershell -Command (New-Object 
   
Net.WebClient).DownloadFile('http://www.web2py.com/examples/static/web2py_src.zip',
 
   'C:\Users\sugizo\Desktop\web2py_src.zip')
   7. 
   
   Extract Downloaded Web2py Source Code to 
   C:\Users\sugizo\Desktop\web2py\web2py
   8. 
   
   Set Path Variables
   setx Path %PATH%;C:\Python27\Scripts;C:\Python27\
   9. 
   
   Backup and Edit Host File on C:\Windows\System32\drivers\etc\hosts
   copy C:\Windows\System32\drivers\etc\hosts 
   C:\Windows\System32\drivers\etc\hosts_2
   notepad C:\Windows\System32\drivers\etc\hosts
   
   127.0.0.1   localhost sugizo sugizo.domain.com
   10. 
   
   Create Certificate
   cd C:\Program Files\Apache Software Foundation\Apache2.2\bin
   openssl req -config ../conf/openssl.cnf -new -out ../conf/server.csr 
   -keyout ../conf/server.pem
   openssl rsa -in ../conf/server.pem -out ../conf/server.key
   openssl x509 -in ../conf/server.csr -out ../conf/server.crt -req 
   -signkey ../conf/server.key -days 3650
   11. 
   
   Copy Downloaded Mod WSGI Win32/Apache 2.2/Python 2.7 into Apache Modules
   copy C:\Users\sugizo\Desktop\mod_wsgi.so C:\Program Files\Apache 
   Software Foundation\Apache2.2\modules\mod_wsgi.so
   12. 
   
   Backup and Edit Apache Configuration
   copy C:\Program Files\Apache Software 
   Foundation\Apache2.2\conf\httpd.conf C:\Program Files\Apache Software 
   Foundation\Apache2.2\conf\httpd_2.conf
   notepad C:\Program Files\Apache Software 
   Foundation\Apache2.2\conf\httpd.conf
   
   Listen 80
   Listen 443
   
   LoadModule ssl_module modules/mod_ssl.so
   LoadModule wsgi_module modules/mod_wsgi.so
   
   NameVirtualHost *:80
   VirtualHost *:80
DocumentRoot C:/Users/sugizo/Desktop/web2py/web2py/applications
ServerName sugizo
   
Directory C:/Users/sugizo/Desktop/web2py/web2py
  Order allow,deny
  Deny from all
/Directory
   
Location /
  Order deny,allow
  Allow from all
/Location
   
LocationMatch ^(/[\w_]*/static/.*)
  Order Allow,Deny
  Allow from all
/LocationMatch
   
WSGIScriptAlias / C:/Users/sugizo/Desktop/web2py/web2py/wsgihandler.py
   
   /VirtualHost
   
   NameVirtualHost *:443
   VirtualHost *:443
DocumentRoot C:/Users/sugizo/Desktop/web2py/web2py/applications
ServerName sugizo
   
Directory C:/Users/sugizo/Desktop/web2py/web2py
  Order allow,deny
  Deny from all
/Directory
   
Location /
  Order deny,allow
  Allow from all
/Location
   
LocationMatch ^(/[\w_]*/static/.*)
  Order Allow,Deny
  Allow from all
/LocationMatch
   
WSGIScriptAlias / C:/Users/sugizo/Desktop/web2py/web2py/wsgihandler.py
   
SSLEngine On
SSLCertificateFile conf/server.crt
SSLCertificateKeyFile conf/server.key
   
   /VirtualHost
   13. 
   
   Copy web2py wsgihandler.py
   copy C:\Users\sugizo\Desktop\web2py\web2py\handlers\wsgihandler.py 
   C:\Users\sugizo\Desktop\web2py\web2py\
   14. 
   
   Copy web2py parameters_8000.py into parameters_80.py and 
   parameters_443.py
   copy C:\Users\sugizo\Desktop\web2py\web2py\parameters_8000.py 
   C:\Users\sugizo\Desktop\web2py\web2py\parameters_80.py
   copy C:\Users\sugizo\Desktop\web2py\web2py\parameters_8000.py 
   C:\Users\sugizo\Desktop\web2py\web2py\parameters_443.py
   15. 
   
   Restart Apache Server
   sc stop Apache2.2
   sc start Apache2.2
   16. Open your Browser and go to 
   C:\Program Files\Google\Chrome\Application\chrome.exe 
   http://localhost/welcome/default/index
   C:\Program 

[web2py] Re: tools to edit web2py layout

2014-01-21 Thread 黄祥
yes, thank you so much, anthony, i think there is a special editor to make 
the layout design easier. btw, pardon, oot, i see in the other framework 
use something like {% %} in their view templates. is it supported also in 
web2py?

thanks and best regards,
stifan

On Tuesday, January 21, 2014 9:28:22 PM UTC+7, Anthony wrote:

 As for tools, just a text editor should do. To adapt a layout, the best 
 guide is to look at the welcome app layout as well as the 
 bookhttp://web2py.com/books/default/chapter/29/05/the-views#Page-layout
 .

 Anthony

 On Tuesday, January 21, 2014 7:46:28 AM UTC-5, 黄祥 wrote:

 hello folks,

 i just want to know which tools did you use to edit web2py layout 
 (twitter bootstrap)? for web2py layout i usually replace it from 
 bootswatch, download pingendo, create the layout, but don't know how to 
 adopt it with web2py layout. any hints, or suggestions?

 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.


[web2py] multiple functions in one view

2014-01-21 Thread En Ware


Hello, 

  I am trying to figure out how to call more then function per view.
I would like to be to have users fill out a form and and then as soon as they 
submit 
show the results sort of like SQLFORM. I also want to make the grid editable 
so
that users can hide rows and columns. 

Thanks in Advance.



#controller default.py

def index():
return dict()


def tracker_form():
record = db.content(request.args(0))
show_record = request.args(0)
form = SQLFORM(db.content, record, show_record)
if form.process().accepted:
response.flash = 'Submitted Successfully!'
#response.view = 'http://127.0.0.1:8000/WnD/default/show_form'
#return dict(show_record=show_record)
elif form.errors: 
response.flash = 'Form is not correct; please correct and submit again'
else:
response.flash = 'Please fill out the damn form'
return dict(form=form)
 


def show_form():
#rows = db().select(db.content.ALL)
return dict(grid=SQLFORM.grid(db.content))





#views 

#tracker_form.html

{{extend 'layout.html'}}
h4centerTracking/center/h4
{{=form}}
{{=BEAUTIFY(request.vars)}}


#show_form.html

{{extend 'layout.html'}}
h4centerRecords processed/center/h4

{{=grid}}

a href=http://127.0.0.1:8000/WnD/default/tracker_form;Back/a


#index.html

{{extend 'layout.html'}}
titleWatch and Defend/title
h4
Current customers:
/h4
H4
   

a href=http://127.0.0.1:8000/WnD/default/tracker_formcenterTracker 
Monitoring click on the link/a/center

/H4



-- 
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: Weird problems generating menu from database

2014-01-21 Thread Massimo Di Pierro
First of all notice that if you use web2py2.8.2 you can do this:

db.define_table('store_catalog',
Field('title'),
Field('slug',requires=IS_SLUG(),compute=lambda row: 
IS_SLUG.urlify(row.title)),
Field('parent_id','reference store_catalog'))

def menu_rec(items): return 
[(x.title,None,URL('action',args=x.slug),menu_rec(x.children)) for x in 
items or []]
response.menu = menu_rec(db(db.store_catalog).select().as_tree())

And you get a recursive menu with arbitrary depth and a web interface to 
edit it with slugs.

On Tuesday, 21 January 2014 00:11:59 UTC-6, James Burke wrote:

 Hi,

 I managed to get one working a little while ago doing this. This has been 
 adapted for your situation, may require some tweaking:

 _tables.py - model
 db.define_table('store_catelog')


 db.define_table('store_catelog',
 Field('title', 'string'),
 Field('description', 'text'),
 Field('parent_catelog', 'reference store_catelog', default=None),
 format='%(title)s',
 redefine=True)

 menu.py - model
 response.menu = []

 categories = db(db.store_catelog.parent == None).select(orderby=db.
 store_catelog.id)

 for category in categories:
 response.menu+=[ (T(category.title), True if active_page == str(
 category.title.lower()) else False, URL('default','page/%s' % (category.
 title.lower())), [
 (T(i.title), True if active_page == str(i.id) else False, URL(
 'default','page/%s' % (i.id)), []) for i in db((db.stored_category.parent 
 == category.id)).select(db.store_category.ALL) if i.parent == category.id
 ]) ]

 The query returns any categories without a parent and adds them to the 
 menu. While doing so looks for any subcategories using the category as a 
 parent.

 Hope that helps you out.

 -James

 On Tuesday, January 21, 2014 9:33:50 AM UTC+13, americ...@gmail.com wrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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: tools to edit web2py layout

2014-01-21 Thread Massimo Di Pierro
You can set:

response.delimiters = (r'{%',r'%}')

But you would have to change the delimiters in all the views including 
layout.html, web2py_ajax.html and generic.*.

Massimo

On Tuesday, 21 January 2014 09:33:49 UTC-6, 黄祥 wrote:

 yes, thank you so much, anthony, i think there is a special editor to make 
 the layout design easier. btw, pardon, oot, i see in the other framework 
 use something like {% %} in their view templates. is it supported also in 
 web2py?

 thanks and best regards,
 stifan

 On Tuesday, January 21, 2014 9:28:22 PM UTC+7, Anthony wrote:

 As for tools, just a text editor should do. To adapt a layout, the best 
 guide is to look at the welcome app layout as well as the 
 bookhttp://web2py.com/books/default/chapter/29/05/the-views#Page-layout
 .

 Anthony

 On Tuesday, January 21, 2014 7:46:28 AM UTC-5, 黄祥 wrote:

 hello folks,

 i just want to know which tools did you use to edit web2py layout 
 (twitter bootstrap)? for web2py layout i usually replace it from 
 bootswatch, download pingendo, create the layout, but don't know how to 
 adopt it with web2py layout. any hints, or suggestions?

 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.


[web2py] Re: Install Web2py on Windows with Apache and Mod WSGI (using command line, *nix flavour)

2014-01-21 Thread Massimo Di Pierro
Can you post this on web2pyslices? Thanks you!

On Tuesday, 21 January 2014 09:37:46 UTC-6, 黄祥 wrote:

 just want to share, enjoy, n please let me know if you meet any problems


 Change :
 - Network Domain with your Network Domain Name

 - Server Name with your Server Name

 - Administrator Email Address with your Administrator Email Address

 - Change Path with your Own Path

1. 

Open Command Prompt (Start  Accessories  Command Prompt)
2. 

Download and Install Python Windows binary
powershell -Command (New-Object Net.WebClient).DownloadFile('
http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi', 
'C:\Users\sugizo\Desktop\python-2.7.6.msi')
C:\Users\sugizo\Desktop\python-2.7.6.msi
3. 

Download Apache 2.2 with ssl support
powershell -Command (New-Object Net.WebClient).DownloadFile('

 http://apache.mirrors.hoobly.com//httpd/binaries/win32/httpd-2.2.25-win32-x86-openssl-0.9.8y.msi',
  
'C:\Users\sugizo\Desktop\httpd-2.2.25-win32-x86-openssl-0.9.8y.msi')
C:\Users\sugizo\Desktop\httpd-2.2.25-win32-x86-openssl-0.9.8y.msi
4. 

Setting Apache during Installation
Network Domain : domain.com
Server Name : sugizo.domain.com
Administrator Email Address : sug...@domain.com javascript:
5. 

Download Mod WSGI Win32/Apache 2.2/Python 2.7
powershell -Command (New-Object Net.WebClient).DownloadFile('
https://modwsgi.googlecode.com/files/mod_wsgi-win32-ap22py27-3.3.so', 
'C:\Users\sugizo\Desktop\mod_wsgi.so')
6. 

Download Web2py Source Code
powershell -Command (New-Object Net.WebClient).DownloadFile('
http://www.web2py.com/examples/static/web2py_src.zip', 
'C:\Users\sugizo\Desktop\web2py_src.zip')
7. 

Extract Downloaded Web2py Source Code to 
C:\Users\sugizo\Desktop\web2py\web2py
8. 

Set Path Variables
setx Path %PATH%;C:\Python27\Scripts;C:\Python27\
9. 

Backup and Edit Host File on C:\Windows\System32\drivers\etc\hosts
copy C:\Windows\System32\drivers\etc\hosts 
C:\Windows\System32\drivers\etc\hosts_2
notepad C:\Windows\System32\drivers\etc\hosts

127.0.0.1   localhost sugizo sugizo.domain.com
10. 

Create Certificate
cd C:\Program Files\Apache Software Foundation\Apache2.2\bin
openssl req -config ../conf/openssl.cnf -new -out ../conf/server.csr 
-keyout ../conf/server.pem
openssl rsa -in ../conf/server.pem -out ../conf/server.key
openssl x509 -in ../conf/server.csr -out ../conf/server.crt -req 
-signkey ../conf/server.key -days 3650
11. 

Copy Downloaded Mod WSGI Win32/Apache 2.2/Python 2.7 into Apache 
Modules
copy C:\Users\sugizo\Desktop\mod_wsgi.so C:\Program Files\Apache 
Software Foundation\Apache2.2\modules\mod_wsgi.so
12. 

Backup and Edit Apache Configuration
copy C:\Program Files\Apache Software 
Foundation\Apache2.2\conf\httpd.conf C:\Program Files\Apache Software 
Foundation\Apache2.2\conf\httpd_2.conf
notepad C:\Program Files\Apache Software 
Foundation\Apache2.2\conf\httpd.conf

Listen 80
Listen 443

LoadModule ssl_module modules/mod_ssl.so
LoadModule wsgi_module modules/mod_wsgi.so

NameVirtualHost *:80
VirtualHost *:80
 DocumentRoot C:/Users/sugizo/Desktop/web2py/web2py/applications
 ServerName sugizo

 Directory C:/Users/sugizo/Desktop/web2py/web2py
   Order allow,deny
   Deny from all
 /Directory

 Location /
   Order deny,allow
   Allow from all
 /Location

 LocationMatch ^(/[\w_]*/static/.*)
   Order Allow,Deny
   Allow from all
 /LocationMatch

 WSGIScriptAlias / 
C:/Users/sugizo/Desktop/web2py/web2py/wsgihandler.py

/VirtualHost

NameVirtualHost *:443
VirtualHost *:443
 DocumentRoot C:/Users/sugizo/Desktop/web2py/web2py/applications
 ServerName sugizo

 Directory C:/Users/sugizo/Desktop/web2py/web2py
   Order allow,deny
   Deny from all
 /Directory

 Location /
   Order deny,allow
   Allow from all
 /Location

 LocationMatch ^(/[\w_]*/static/.*)
   Order Allow,Deny
   Allow from all
 /LocationMatch

 WSGIScriptAlias / 
C:/Users/sugizo/Desktop/web2py/web2py/wsgihandler.py

 SSLEngine On
 SSLCertificateFile conf/server.crt
 SSLCertificateKeyFile conf/server.key

/VirtualHost
13. 

Copy web2py wsgihandler.py
copy C:\Users\sugizo\Desktop\web2py\web2py\handlers\wsgihandler.py 
C:\Users\sugizo\Desktop\web2py\web2py\
14. 

Copy web2py parameters_8000.py into parameters_80.py and 
parameters_443.py
copy C:\Users\sugizo\Desktop\web2py\web2py\parameters_8000.py 
C:\Users\sugizo\Desktop\web2py\web2py\parameters_80.py
copy C:\Users\sugizo\Desktop\web2py\web2py\parameters_8000.py 

[web2py] Updating DAL elements with a loop

2014-01-21 Thread Mark Billion
I have a database that accepts user data and then repurposes it for use in 
a different context.  The problem is scrubbing for None; I can do it, but 
its ugly going line by line -- Id rather loop through it but I cant get it 
to work.  

Approach #1

for r in rows:
   . . . . 

   for e in [r.name . . . ]:
 if e == None:
 e = ''
 r.update_record()

#OUTPUT: r.name - unchanged . . . e = '' // Updates variable e, not the 
loop variables

Approach #2

for r in rows:
   . . . . 

   for k, v in {'name' : r.name . . . ].items():
 if v == None:
 v = ''
 r.update_record(k=v)

#OUTPUT: throws error

Thoughts?



-- 
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: How to create a dropdown selection page?

2014-01-21 Thread 黄祥
i'm sorry, my bad, i focus on your layout before 
selection.html
-
___   ___   
| select a country |  | submit |
---  -

___   ___   
| select a brand|  | submit |
---  -

*See all shops*

for learning how sqlform manage it, i think there is on the web2py gluon 
modules sqlhtml.py

for drop down form field, for start from simple, i think it created 
automatically if you set the field type as reference or list:reference 
(it's on models side). or if you want to create it in controllers side, 
please use the validators (IS_IN_DB(), IS_IN_SET())

please read the book that related with :
models : with field type reference and list:reference
and validators like : IS_IN_DB() and IS_IN_SET()

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: Install Web2py on Windows with Apache and Mod WSGI (using command line, *nix flavour)

2014-01-21 Thread 黄祥
done, i'm sorry, forgot to tell that it tested work in windows 7 ultimate 
32 bit.

ref:
http://www.web2pyslices.com/slice/show/1941/install-web2py-on-windows-with-apache-and-mod-wsgi-using-command-line-nix-flavou

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: running scheduler under a user

2014-01-21 Thread Niphlod
the wording is a little bit incorrect. 

You may prevent users queuing tasks, and that's pretty much all about what 
can you do with auth.has_membership.


python files being executed by other users

seems to point to the security of the server itself, that web2py can't 
really manage.

Can you be clearer ?

On Tuesday, January 21, 2014 10:22:04 AM UTC+1, Jayadevan M wrote:

 I wanted to set up the scheduler and execute a few jobs. To prevent the 
 python files being executed by other users, I have added a condition 
 auth.has_membership('scheduler') in the functions. How can I make the 
 scheduler start with a user who in in the scheduler group? Or I am going 
 down the wrong path?


-- 
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: web2py --run-system-tests

2014-01-21 Thread Niphlod
windows has it. but the guy who wrote those tests never give attention to 
the win world. When I run tests on windows, I delete that file.

On Tuesday, January 21, 2014 2:39:52 PM UTC+1, Massimo Di Pierro wrote:

 Windows has no fork. I do not think we have ever run tests on windows. Try 
 with cygwin

 On Monday, 20 January 2014 23:16:12 UTC-6, Kiran Subbaraman wrote:

 Hello,
 I was trying to figure out how to run tests against web2py (in the case 
 where I contribute changes to web2py).
 Ran 
 python web2py.py --help 


 This listed --run-system-tests as an option

 Ran this, and this is the output I see (I have to kill the process; 
 unable to stop it otherwise)

 testInvalidUrls (gluon.tests.test_is_url.TestIsGenericUrl) ... ok
 testPrepending (gluon.tests.test_is_url.TestIsGenericUrl) ... ok
 testValidUrls (gluon.tests.test_is_url.TestIsGenericUrl) ... ok
 testInvalidUrls (gluon.tests.test_is_url.TestIsHttpUrl) ... ok
 testPrepending (gluon.tests.test_is_url.TestIsHttpUrl) ... ok
 testValidUrls (gluon.tests.test_is_url.TestIsHttpUrl) ... ok
 testExceptionalUse (gluon.tests.test_is_url.TestIsUrl) ... ok
 testModeGeneric (gluon.tests.test_is_url.TestIsUrl) ... ok
 testModeHttp (gluon.tests.test_is_url.TestIsUrl) ... ok
 testRun (gluon.tests.test_dal.TestJoin) ... ok
 test_reads_and_writes (gluon.tests.test_languages.TestLanguagesParallel) 
 ... Traceback (most recent call last):
   File string, line 1, in module
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
 Traceback (most recent call last):
   File string, line 1, in module
 prepare(preparation_data)
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 prepare(preparation_data)
 assert main_name not in sys.modules, main_name
 Traceback (most recent call last):
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 AssertionError  File string, line 1, in module
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
 Traceback (most recent call last):
 Traceback (most recent call last):
   File string, line 1, in module
 :   File D:\programs\open\python27\lib\multiprocessing\forking.py,line 
 380, in main
   File string, line 1, in module
 Traceback (most recent call last):
 assert main_name not in sys.modules, main_name
 Traceback (most recent call last):
 _  File string, line 1, in module
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
 prepare(preparation_data)
   File string, line 1, in module
 prepare(preparation_data)
 AssertionErrorTraceback (most recent call last):
 _main__  File 
 D:\programs\open\python27\lib\multiprocessing\forking.py,line 
 380, in main
 prepare(preparation_data)
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 :   File string, line 1, in module
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 Traceback (most recent call last):
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 488, in prepare
 _prepare(preparation_data)
   File D:\programs\open\python27\lib\multiprocessing\forking.py, line 
 380, in main


 I am running these tests on Window 8.1, from within the power-shell. I am 
 suspecting this is an OS related issue; where I need to run the tests on a 
 *nix box?



-- 
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 looping update

2014-01-21 Thread Mark Billion
  I cannot seem to get this code to run, even though Im almost sure Im 
right.any thoughts would be appreciated!

for r in rows:

  . . . . . 

  for k, v in {'name': r.name, 'address': r.address . . .  }.items():
  if v is None:
db(db.client.id==r.id).update(**{k:'Not Specified'})

-- 
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: multiple functions in one view

2014-01-21 Thread Anthony
You could put both the form and the grid in ajax components. When the form 
is submitted, it could send back a JS command to load the grid:

In index.html:

{{=LOAD('default', 'tracker_form.load', ajax=True)}}
div id='content_grid'/div

Change your two existing views to a .load extension (not required, but done 
by convention for component views), and remove the {{extend 'layout.html'}} 
from each.

In tracker_form, do:

if form.process().accepted:
response.js = '$.web2py.component(%s, target=content_grid);' %URL
('default', 'show_form.load')
response.flash = 'Submitted Successfully!'

Whenever the form is submitted and accepted, it will reload the grid in the 
content_grid div.

Anthony

On Tuesday, January 21, 2014 10:37:04 AM UTC-5, En Ware wrote:

 Hello, 

   I am trying to figure out how to call more then function per view.
 I would like to be to have users fill out a form and and then as soon as they 
 submit 
 show the results sort of like SQLFORM. I also want to make the grid 
 editable so
 that users can hide rows and columns. 

 Thanks in Advance.



 #controller default.py

 def index():
 return dict()


 def tracker_form():
 record = db.content(request.args(0))
 show_record = request.args(0)
 form = SQLFORM(db.content, record, show_record)
 if form.process().accepted:
 response.flash = 'Submitted Successfully!'
 #response.view = 'http://127.0.0.1:8000/WnD/default/show_form'
 #return dict(show_record=show_record)
 elif form.errors: 
 response.flash = 'Form is not correct; please correct and submit 
 again'
 else:
 response.flash = 'Please fill out the damn form'
 return dict(form=form)
  


 def show_form():
 #rows = db().select(db.content.ALL)
 return dict(grid=SQLFORM.grid(db.content))





 #views 

 #tracker_form.html

 {{extend 'layout.html'}}
 h4centerTracking/center/h4
 {{=form}}
 {{=BEAUTIFY(request.vars)}}


 #show_form.html

 {{extend 'layout.html'}}
 h4centerRecords processed/center/h4

 {{=grid}}

 a href=http://127.0.0.1:8000/WnD/default/tracker_form;Back/a


 #index.html

 {{extend 'layout.html'}}
 titleWatch and Defend/title
 h4
 Current customers:
 /h4
 H4


 a href=http://127.0.0.1:8000/WnD/default/tracker_formcenterTracker 
 Monitoring click on the link/a/center
 
 /H4





-- 
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: tools to edit web2py layout

2014-01-21 Thread 黄祥
a, i see, seems, you guys prepare everything. what a wonthefull web 
framework.

thanks and best regards,
stifan

On Tuesday, January 21, 2014 10:48:42 PM UTC+7, Massimo Di Pierro wrote:

 You can set:

 response.delimiters = (r'{%',r'%}')

 But you would have to change the delimiters in all the views including 
 layout.html, web2py_ajax.html and generic.*.

 Massimo

 On Tuesday, 21 January 2014 09:33:49 UTC-6, 黄祥 wrote:

 yes, thank you so much, anthony, i think there is a special editor to 
 make the layout design easier. btw, pardon, oot, i see in the other 
 framework use something like {% %} in their view templates. is it supported 
 also in web2py?

 thanks and best regards,
 stifan

 On Tuesday, January 21, 2014 9:28:22 PM UTC+7, Anthony wrote:

 As for tools, just a text editor should do. To adapt a layout, the best 
 guide is to look at the welcome app layout as well as the 
 bookhttp://web2py.com/books/default/chapter/29/05/the-views#Page-layout
 .

 Anthony

 On Tuesday, January 21, 2014 7:46:28 AM UTC-5, 黄祥 wrote:

 hello folks,

 i just want to know which tools did you use to edit web2py layout 
 (twitter bootstrap)? for web2py layout i usually replace it from 
 bootswatch, download pingendo, create the layout, but don't know how to 
 adopt it with web2py layout. any hints, or suggestions?

 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.


[web2py] Re: Form input prolem

2014-01-21 Thread DAL read and variables
Thank you very much, it works good :)

Am Sonntag, 19. Januar 2014 19:28:23 UTC+1 schrieb Lucas Schreiber:

 Hi guys,

 i have this function:

 def login():
 form = FORM(
 'Name', INPUT(_name='name'),
 'password', INPUT(_password='password'), 
 INPUT(_type='submit'))
 if form.process().accepted:
 name = form.vars.name
 records = SQLTABLE(dba(dba.user.name== name).select(dba.user.
 password),headers='fieldname:capitalize')
 passworddb = records[1]
 password = form.vars.password
 dba.person.insert(name = 'test', email=password)
 if passworddb == password:
redirect(URL('register'))
 else:
redirect(URL('index'))
 
 return dict(form=form)


 As you can see, you enter name and password into a form, and from a db it 
 choose a password correspondending to the username. that part works fine. 
 but the problem is on the part:

 password = form.vars.password

 i think this doesnt work, since the line below


 dba.person.insert(name = 'test', email=password)

 inserts into another db test, none

 Do anyone has an idea how to fix this problem? Or can anyone tell me what 
 i did wrong?

 Thanks for the help,
 Darren


-- 
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: Static form control in case of read only field

2014-01-21 Thread Annet


 That doesn't look like it will work -- the first branch will only execute 
 if controls is an instance of all three types of widgets, which will never 
 be true. I think you want:

 if not isinstance(controls, (INPUT, SELECT, TEXTAREA)): 


No it didn't work :-)  clicking through some forms made that clear.
What did work was: if isinstance(controls, basestring):

I tried: if not isinstance(controls, (INPUT, SELECT, TEXTAREA)): 

But that adds a empty p class=form-control-static/p to other controls 
as well.


Why does the comment say: # embed _help into _controls


 Don't know. I thought that was your own custom function.



No, to have forms styled the bootstrap 3 way I took the def 
formstyle_bootstrap(form, fields):
function from gluon/sqlhtml as a starting point (line 756 - 798) and made 
some adjustments.

The only thing I am left with is styling radios and checkboxes. I tried the 
custom widget
code here: 
https://github.com/niphlod/w2p_tvseries/blob/master/modules/w2p_tvseries_utils.py#L100
It's exactly what I want but in case of a list:reference the checkboxes do 
not reflect the list in the database.

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 options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: DAL looping update

2014-01-21 Thread Mark Billion
This is perfect, thanks.  Meant it wouldnt run, and the values were NULL.

On Tuesday, January 21, 2014 11:25:39 AM UTC-5, Anthony wrote:

 What do you mean it won't run? Do you get an error, or just don't see the 
 changes you expect? Are the values in question in the database actually 
 None (i.e., NULL), or are they empty strings ('')?

 If you're trying to change all the records in the table, would be easier 
 to do:

 for field in ['name', 'address']:
 db(db.mytable[field] == None).update(**{field: 'Not Specified'})

 That will just issue two updates rather selecting the entire table and 
 then doing two updates per row.

 Also, if you have a Rows object and need to make multiple changes to a 
 given Row, you can do:

 row.update(...)
 row.update(...)
 row.update_record()

 The row.update() calls make changes to the Row object itself (but not the 
 database). Then, .update_record() updates the database with whatever 
 changes have been made to the Row.

 Anthony

 On Tuesday, January 21, 2014 11:00:10 AM UTC-5, Mark Billion wrote:

   I cannot seem to get this code to run, even though Im almost sure Im 
 right.any thoughts would be appreciated!

 for r in rows:

   . . . . . 

   for k, v in {'name': r.name, 'address': r.address . . .  }.items():
   if v is None:
 db(db.client.id==r.id).update(**{k:'Not Specified'})



-- 
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: DAL looping update

2014-01-21 Thread Anthony
What do you mean it won't run? Do you get an error, or just don't see the 
changes you expect? Are the values in question in the database actually 
None (i.e., NULL), or are they empty strings ('')?

If you're trying to change all the records in the table, would be easier to 
do:

for field in ['name', 'address']:
db(db.mytable[field] == None).update(**{field: 'Not Specified'})

That will just issue two updates rather selecting the entire table and then 
doing two updates per row.

Also, if you have a Rows object and need to make multiple changes to a 
given Row, you can do:

row.update(...)
row.update(...)
row.update_record()

The row.update() calls make changes to the Row object itself (but not the 
database). Then, .update_record() updates the database with whatever 
changes have been made to the Row.

Anthony

On Tuesday, January 21, 2014 11:00:10 AM UTC-5, Mark Billion wrote:

   I cannot seem to get this code to run, even though Im almost sure Im 
 right.any thoughts would be appreciated!

 for r in rows:

   . . . . . 

   for k, v in {'name': r.name, 'address': r.address . . .  }.items():
   if v is None:
 db(db.client.id==r.id).update(**{k:'Not Specified'})



-- 
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: Static form control in case of read only field

2014-01-21 Thread Annet



 Regarding the flash message position, here attached you'll find the 
 patched files of my package. Now the default position is on the rightside 
 but by adding in layout.html to the flash dom element the css class 
 centered it will horizontally centered on the page or by adding the css 
 class leftside the message will be positioned on the left. Please replace 
 the old files with these here attached.


I replaced the previous files with the attached files, I like the solution 
with classes.

Kind regards,

Anne 

-- 
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] How to create a dropdown selection page?

2014-01-21 Thread Adrian Zhang
Thank you so much for your continue support. I tried some clue from manual
and created a simple drop-down list with a bit defect.will post here
tomorrow.
Thank you again !
Have a nice day!

Adrian

黄祥 steve.van.chris...@gmail.com于2014年1月21日星期二写道:

 i'm sorry, my bad, i focus on your layout before
 selection.html
 -
 ___   ___
 | select a country |  | submit |
 ---  -

 ___   ___
 | select a brand|  | submit |
 ---  -

 *See all shops*

 for learning how sqlform manage it, i think there is on the web2py gluon
 modules sqlhtml.py

 for drop down form field, for start from simple, i think it created
 automatically if you set the field type as reference or list:reference
 (it's on models side). or if you want to create it in controllers side,
 please use the validators (IS_IN_DB(), IS_IN_SET())

 please read the book that related with :
 models : with field type reference and list:reference
 and validators like : IS_IN_DB() and IS_IN_SET()

 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/6591gnT-GVA/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com javascript:_e({}, 'cvml',
 'web2py%2bunsubscr...@googlegroups.com');.
 For more options, visit https://groups.google.com/groups/opt_out.



-- 
发自移动版 Gmail

-- 
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: Static form control in case of read only field

2014-01-21 Thread Anthony
On Tuesday, January 21, 2014 11:27:25 AM UTC-5, Annet wrote:


 That doesn't look like it will work -- the first branch will only execute 
 if controls is an instance of all three types of widgets, which will never 
 be true. I think you want:

 if not isinstance(controls, (INPUT, SELECT, TEXTAREA)): 


 No it didn't work :-)  clicking through some forms made that clear.
 What did work was: if isinstance(controls, basestring):


The only problem with that is if you use a represent attribute that wraps 
some text in an HTML helper -- it won't be a basestring in that case.
 

 I tried: if not isinstance(controls, (INPUT, SELECT, TEXTAREA)): 

 But that adds a empty p class=form-control-static/p to other 
 controls as well.


Good point. I guess there are a few other types of objects you'd have to 
account for.

Anthony

-- 
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: Weird problems generating menu from database

2014-01-21 Thread web2pygroup
I am unable to make it past the point of the database definition.  I put 
exactly what you have below in my db.py, and in my menu.py I left 
response.menu=[] so that I could populate the database because the function 
def menu_rec doesn't have anything so I thought to just avoid errors and 
for simplicity sake start with the db.  However immediately upon attempting 
to put data in the field with the editor I get the same: 
IntegrityError('FOREIGN KEY constraint failed',)  error message.

Not sure how I can test/incorporate anything with both suggestions causing 
an error immediately upon clicking submit for simply putting data in the 
field as is needed.

Yes I am using the latest web2py 2.8.2.

Totally confused because I've never seen any of my database setups act like 
that and I have a few other tables I setup for the products, etc.  Not a 
one has ever complained about a foreign key...

??

On Tuesday, January 21, 2014 9:45:27 AM UTC-6, Massimo Di Pierro wrote:

 First of all notice that if you use web2py2.8.2 you can do this:

 db.define_table('store_catalog',
 Field('title'),
 Field('slug',requires=IS_SLUG(),compute=lambda row: 
 IS_SLUG.urlify(row.title)),
 Field('parent_id','reference store_catalog'))

 def menu_rec(items): return 
 [(x.title,None,URL('action',args=x.slug),menu_rec(x.children)) for x in 
 items or []]
 response.menu = menu_rec(db(db.store_catalog).select().as_tree())

 And you get a recursive menu with arbitrary depth and a web interface to 
 edit it with slugs.

 On Tuesday, 21 January 2014 00:11:59 UTC-6, James Burke wrote:

 Hi,

 I managed to get one working a little while ago doing this. This has been 
 adapted for your situation, may require some tweaking:

 _tables.py - model
 db.define_table('store_catelog')


 db.define_table('store_catelog',
 Field('title', 'string'),
 Field('description', 'text'),
 Field('parent_catelog', 'reference store_catelog', default=None),
 format='%(title)s',
 redefine=True)

 menu.py - model
 response.menu = []

 categories = db(db.store_catelog.parent == None).select(orderby=db.
 store_catelog.id)

 for category in categories:
 response.menu+=[ (T(category.title), True if active_page == str(
 category.title.lower()) else False, URL('default','page/%s' % (category.
 title.lower())), [
 (T(i.title), True if active_page == str(i.id) else False, URL(
 'default','page/%s' % (i.id)), []) for i in db((db.stored_category.parent 
 == category.id)).select(db.store_category.ALL) if i.parent == category.id
 ]) ]

 The query returns any categories without a parent and adds them to the 
 menu. While doing so looks for any subcategories using the category as a 
 parent.

 Hope that helps you out.

 -James

 On Tuesday, January 21, 2014 9:33:50 AM UTC+13, americ...@gmail.comwrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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] Button in Component Stealing Focus?

2014-01-21 Thread EW
I have a load component with a button in it that seems to automatically 
have the focus such that if I go to my URL and press the enter key, that is 
the button that is triggered.  But, I also have a textbox and a button 
outside the component.  I would like it so that when you type something in 
the textbox and press enter, the adjacent button is clicked.  However, 
what happens is that the button in the component is clicked instead.  
 
I tried putting a jquery handler so that on keyup in my textbox, if the 
keycode is 13 (for enter), the adjacent button will be clicked, but it is 
not working--upon pressing enter, the component button is being clicked 
immediately such that my jquery handler is never reached.  I know that my 
jquery handler is correct though because it is reached when I type anything 
other than enter.
 
I also tried just setting the focus on my button when the page loads, which 
works in that going to the URL and pressing enter triggers it.  However, 
once I click on/type something in the textbox, the focus is returned to 
that button in the component, so this does not help at all.
 
Any ideas?  I am using IE btw.

-- 
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: Weird problems generating menu from database

2014-01-21 Thread web2pygroup
My code above seems to only be lacking the proper embedded if conditional 
statement.  I am able to output the same info I need without repeating it 
like in this example:

rows = db(db.store_categories).select()
for menucatchoice in rows:
if menucatchoice['subcategory'] == '':
print Main - %s  % menucatchoice['maincategory']
if menucatchoice['subcategory']:
print SubCategory -- %s  % menucatchoice['subcategory']
Which prints out:
Main - Animals 
SubCategory -- Dogs 
SubCategory -- Cats 

Why can't I get it to go like that with my code above?

My code is much smaller and actually works for seeing what happens.

With the suggested code that isn't working I'm unable to see anything and 
therefore unable to even debug it since it crashes immediately.

Also I was wondering if there was any actual way to see what MENU helper 
actually sees, and not just using the shell.  For example when you click on 
the response in the ticket it shows the menu but doesn't show the actual 
received output.  When I view that in the shell and make adjustments such 
as adding/subtracting []] or similar it is difficult to deduce what MENU 
has determined as a link, false, or whatever.  I have also tried other 
variations such as:

menu.py
response.menu = [T('Catalog'), False, '',[]]

maininfo=db(db.store_categories.subcategory=='').select(db.store_categories.maincategory)
for maincat in maininfo:
response.menu[-1]+=([(T(maincat.maincategory)), False, 'link'])
for subcat in 
db(db.store_categories.subcategory!='').select(db.store_categories.subcategory):
response.menu[-1]+=([[(T(subcat.subcategory)), False, 'link',]])

Which gets me this in the shell:
[lazyT 'Catalog',
 False,
 '',
 [lazyT 'Animals',
  False,
  'link',
  [lazyT 'Dogs', False, 'link'],
  [lazyT 'Cats', False, 'link']]]

And for the astute observer you can see the correct way (i statically 
created and works):
[(lazyT 'Catalog',
  False,
  '',
  [(lazyT 'Animals',
False,
'/beta/default/Animals',
[(lazyT 'Dogs', False, '/beta/default/Dogs'),
 (lazyT 'Cats', False, '/beta/default/Cats')])])]

You can see the slight differences so obviously I am very close.  For 
further clarity for myself and anyone else reading this(it has become clear 
others have tried this extensively), you can see I need to have one less 
bracket (if I'm correct).  I say this because in the working/correct 
version you can clearly see that the last entry (lazyT 'Cats', False, 
'/beta/default/Cats')])])] is missing the bracket that my generated one 
has [lazyT 'Cats', False, 'link']]].  I realize the () aren't the 
same however I noticed that in the shell unless the structure shows 
correctly as outlined above that it does not work regardless of the ().  
You can also see that the bracket only encompasses the subcategories.  So 
I'm wondering how I can get that one bracket out of here (again if I'm 
correct about the format).  I appreciate all the code samples but, it 
appears I'm doing something trivially wrong which doesn't suffice replacing 
the whole thing for (in my opinion due to one bracket being off).



On Monday, January 20, 2014 2:33:50 PM UTC-6, web2pygroup wrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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 

[web2py] Re: Weird problems generating menu from database

2014-01-21 Thread web2pygroup
Here's what I've tried so far and here's the results if it helps any to get 
me on the right track, plus I hope this helps someone else looking for this 
to because this is something very commonly done in PHP.

I have tried changing this:
response.menu3[-1]+=([[(T(subcat.subcategory)), False, 'link',]])

to this:
response.menu3[-1]+=([(T(subcat.subcategory)), False, 'link',])

Which changes the output in the shell to:
[lazyT 'Catalog',
 False,
 '',
 [lazyT 'Animals',
  False,
  'link',
  lazyT 'Dogs',
  False,
  'link',
  lazyT 'Cats',
  False,
  'link']]

Which obviously isn't correct.  

Continuing:

original:
response.menu3[-1]+=([[(T(subcat.subcategory)), False, 'link',]])

to this:
response.menu3+=([[(T(subcat.subcategory)), False, 'link',]])

Gives this in the shell output:
[lazyT 'Catalog',
 False,
 '',
 [lazyT 'Animals', False, 'link'],
 [lazyT 'Dogs', False, 'link'],
 [lazyT 'Cats', False, 'link']]

Again obviously incorrect.  Continuing:

original:
response.menu3+=([[(T(subcat.subcategory)), False, 'link',]])

changed:
response.menu3[-1]+=((T(subcat.subcategory)), False, 'link',)

Shell output shows:
[lazyT 'Catalog',
 False,
 '',
 [lazyT 'Animals',
  False,
  'link',
  lazyT 'Dogs',
  False,
  'link',
  lazyT 'Cats',
  False,
  'link']]

I tried additional variations but, not sure how much space we have here to 
keep going with my 2 weeks worth of work.  Essentially the end result is 
the same a bracket missing to seperate the subcategories.  I've been able 
to modify and add to lists before, however I've never really experienced a 
situation where the negative slice appears to be ignored (removing the 
bracket at the end of dogs and beginning of cats as it is doing for the 
main category Animals as can be seen), even removed the negative slice 
([-1]) for the main categories iteration and when I do it clearly shows 
that it is actually doing the negative slice properly because the brackets 
come back at the end of Animals, unlike the subcategories that do not 
appear to be removing the bracket(s)


On Monday, January 20, 2014 2:33:50 PM UTC-6, web2pygroup wrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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: Weird problems generating menu from database

2014-01-21 Thread James Burke
Sorry, I had the parent declared as catelog_parent in the table. If you 
change it to parent it should work ;)

Also += is the same as append.

On Wednesday, January 22, 2014 3:35:29 AM UTC+13, web2pygroup wrote:

 I attempted to copy/paste what you have so I can modify it for my needs.  
 However it immediately errors out with:

 AttributeError: 'Table' object has no attribute 'parent'

 So I thought I would comment out everything for the menu except 
 response.menu = [] and populate the database (have done this before and the 
 site comes up just no menu as expected).

 I then decided to try and populate the database fields.

 However when I try to populate it I immediately get an error 
 IntegrityError: FOREIGN KEY constraint failed. What I did was, put 
 Animals for the title, for description I put Main Animals Category, 
 then for the parent catelog I put Animals again.  Upon seeing this I'm 
 confused as to how a subcategory would get identified.  So I also tried 
 just putting Animals for the title, and filling in the description as 
 above, but leaving the parent catelog blank, it to also failed with exactly 
 the same error IntegrityError: FOREIGN KEY constraint failed.  So 
 effectively I'm unable to even put anything in the fields, an issue I never 
 had so I'm unsure what the problem is.

 Would it be possible to use the fields I have already established to 
 populate the menu?  Since you have 3 fields identified in your table albeit 
 with slight differences, would it be possible to somehow incorporate that 
 into what I have?  Could you also explain why you used += instead of 
 append?  Maybe I could figure out something from that.

 Thanks

 On Tuesday, January 21, 2014 12:11:59 AM UTC-6, James Burke wrote:

 Hi,

 I managed to get one working a little while ago doing this. This has been 
 adapted for your situation, may require some tweaking:

 _tables.py - model
 db.define_table('store_catelog')


 db.define_table('store_catelog',
 Field('title', 'string'),
 Field('description', 'text'),
 Field('parent_catelog', 'reference store_catelog', default=None),
 format='%(title)s',
 redefine=True)

 menu.py - model
 response.menu = []

 categories = db(db.store_catelog.parent == None).select(orderby=db.
 store_catelog.id)

 for category in categories:
 response.menu+=[ (T(category.title), True if active_page == str(
 category.title.lower()) else False, URL('default','page/%s' % (category.
 title.lower())), [
 (T(i.title), True if active_page == str(i.id) else False, URL(
 'default','page/%s' % (i.id)), []) for i in db((db.stored_category.parent 
 == category.id)).select(db.store_category.ALL) if i.parent == category.id
 ]) ]

 The query returns any categories without a parent and adds them to the 
 menu. While doing so looks for any subcategories using the category as a 
 parent.

 Hope that helps you out.

 -James

 On Tuesday, January 21, 2014 9:33:50 AM UTC+13, americ...@gmail.comwrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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: Weird problems generating menu from database

2014-01-21 Thread web2pygroup
Getting:

global name 'active_page' is not defined

What did you have for that so I can incorporate it? Or do I even need that 
since I'm not really caring at the moment about which page they're on (if I 
understand that variable correctly).  How would I remove it to still 
achieve the same effect?  Thanks



On Tuesday, January 21, 2014 12:29:04 PM UTC-6, James Burke wrote:

 Sorry, I had the parent declared as catelog_parent in the table. If you 
 change it to parent it should work ;)

 Also += is the same as append.

 On Wednesday, January 22, 2014 3:35:29 AM UTC+13, web2pygroup wrote:

 I attempted to copy/paste what you have so I can modify it for my needs.  
 However it immediately errors out with:

 AttributeError: 'Table' object has no attribute 'parent'

 So I thought I would comment out everything for the menu except 
 response.menu = [] and populate the database (have done this before and the 
 site comes up just no menu as expected).

 I then decided to try and populate the database fields.

 However when I try to populate it I immediately get an error 
 IntegrityError: FOREIGN KEY constraint failed. What I did was, put 
 Animals for the title, for description I put Main Animals Category, 
 then for the parent catelog I put Animals again.  Upon seeing this I'm 
 confused as to how a subcategory would get identified.  So I also tried 
 just putting Animals for the title, and filling in the description as 
 above, but leaving the parent catelog blank, it to also failed with exactly 
 the same error IntegrityError: FOREIGN KEY constraint failed.  So 
 effectively I'm unable to even put anything in the fields, an issue I never 
 had so I'm unsure what the problem is.

 Would it be possible to use the fields I have already established to 
 populate the menu?  Since you have 3 fields identified in your table albeit 
 with slight differences, would it be possible to somehow incorporate that 
 into what I have?  Could you also explain why you used += instead of 
 append?  Maybe I could figure out something from that.

 Thanks

 On Tuesday, January 21, 2014 12:11:59 AM UTC-6, James Burke wrote:

 Hi,

 I managed to get one working a little while ago doing this. This has 
 been adapted for your situation, may require some tweaking:

 _tables.py - model
 db.define_table('store_catelog')


 db.define_table('store_catelog',
 Field('title', 'string'),
 Field('description', 'text'),
 Field('parent_catelog', 'reference store_catelog', default=None),
 format='%(title)s',
 redefine=True)

 menu.py - model
 response.menu = []

 categories = db(db.store_catelog.parent == None).select(orderby=db.
 store_catelog.id)

 for category in categories:
 response.menu+=[ (T(category.title), True if active_page == str(
 category.title.lower()) else False, URL('default','page/%s' % (category.
 title.lower())), [
 (T(i.title), True if active_page == str(i.id) else False, URL(
 'default','page/%s' % (i.id)), []) for i in db((db.stored_category.parent 
 == category.id)).select(db.store_category.ALL) if i.parent == category.
 id
 ]) ]

 The query returns any categories without a parent and adds them to the 
 menu. While doing so looks for any subcategories using the category as a 
 parent.

 Hope that helps you out.

 -James

 On Tuesday, January 21, 2014 9:33:50 AM UTC+13, americ...@gmail.comwrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category 
 and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly appreciated.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- 

[web2py] Re: Weird problems generating menu from database

2014-01-21 Thread James Burke
You could simply declare it for testing purposes. 

Set it to false. 

-- 
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: Install Web2py on Windows with Apache and Mod WSGI (using command line, *nix flavour)

2014-01-21 Thread Paolo Valleri
Well done, 
under scripts/setup_* there are several scripts for deployments on linux 
environment, it would be very nice to have something for windows too.

Paolo

On Tuesday, January 21, 2014 5:04:12 PM UTC+1, 黄祥 wrote:

 done, i'm sorry, forgot to tell that it tested work in windows 7 ultimate 
 32 bit.

 ref:

 http://www.web2pyslices.com/slice/show/1941/install-web2py-on-windows-with-apache-and-mod-wsgi-using-command-line-nix-flavou

 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] How to create a dropdown selection page?

2014-01-21 Thread Tim Richardson
to get drop downs you need to set a validator in the field definition. 
IS_IN_SET is one validator which causes SQLFORM to automatically make a 
dropdown.  so you don't do anything in SQLFORM. Rather you set up your data 
model when defining tables. 

-- 
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: Button in Component Stealing Focus?

2014-01-21 Thread Niphlod
pack a minimal app to reproduce the behaviour. Without it, we'll just 
provide unuseful hints.

On Tuesday, January 21, 2014 6:32:30 PM UTC+1, EW wrote:

 I have a load component with a button in it that seems to automatically 
 have the focus such that if I go to my URL and press the enter key, that is 
 the button that is triggered.  But, I also have a textbox and a button 
 outside the component.  I would like it so that when you type something in 
 the textbox and press enter, the adjacent button is clicked.  However, 
 what happens is that the button in the component is clicked instead.  
  
 I tried putting a jquery handler so that on keyup in my textbox, if the 
 keycode is 13 (for enter), the adjacent button will be clicked, but it is 
 not working--upon pressing enter, the component button is being clicked 
 immediately such that my jquery handler is never reached.  I know that my 
 jquery handler is correct though because it is reached when I type anything 
 other than enter.
  
 I also tried just setting the focus on my button when the page loads, 
 which works in that going to the URL and pressing enter triggers it.  
 However, once I click on/type something in the textbox, the focus is 
 returned to that button in the component, so this does not help at all.
  
 Any ideas?  I am using IE btw.


-- 
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: Grid in component edit twice issue

2014-01-21 Thread Niphlod
still can't reproduce in 2.8.2 with Firefox 26.0 or chrome 32

The edit link should have this attribute in the source-code *data-w2p_target 
*that enables the load into component behaviour. The button markup 
**should** look like
 
a href=/test_grid/default/component.load/edit/person/2 data-w2p_target=
*c345058654325* data-w2p_method=GET data-w2p_disable_with=default 
class=button btnspan class=icon pen icon-pencil/spanspan title=
*Edit* class=buttontext button*Edit*/span/a

The bold parts are the only one allowed to change, and they are 
respectively the randomly-generated cid and the Edit translations. If you 
can confirm that this is indeed the source-code but your app is behaving 
differently, then we can look at the reason why the default js handler is 
not working in your environment.
In that case: can you open your debug console in FF and see if there are 
any js errors ?

On Monday, January 20, 2014 10:53:47 PM UTC+1, Jim Karsten wrote:

 I attached a simple application. Add a record to the table. Click the Edit 
 button for a record in the grid, submit the Edit form. Click the Edit 
 button of the record a second time and the edit form is displayed without 
 the layout.html formatting. 

 I am testing with Firefox 5.0 if it matters.
 Thanks,
 Jim




-- 
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] filepaths for library and images ?

2014-01-21 Thread Stef Mientki

hello,

Q1:
I want to store uploaded files manually, but I'm asking myself if this 
is the correct way to create the filepath, or is there a better way ?


Filename = os.path.join ( 'applications', 
request.application,'static\images\pic_%s.png' % Edit_Select), 'wb')



Q2:
I made some libraries that I want to use more than one project.
Now I stored these in
   ..controllers/my_support_libs.py

but when I try to import this lib into a controller, I get an error 
message can't import my_support_libs


cheers,
Stef

--
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: Install Web2py on Windows with Apache and Mod WSGI (using command line, *nix flavour)

2014-01-21 Thread 黄祥
i plan to use bat script or create an exe too using autoit for this. but 
the main problem in my pov is about the software version. let say in linux 
you just type e.g.
sudo apt-get install -y apache2
it will get the latest version of apache, if you not explicit tell which 
version, yet in windows, i think can not, i manually download from website 
and then put url link on powershell.
in linux there is repo that is maintain by the distro, n in windows there 
is no repo, any ideas or suggestion?

i plan to create the web2py service too like the book said, but i still 
confuse what is it about :
python web2py.py -W install

see the help python web2py.py didn't found -W is about. just a suggestion 
why not create it simple windows service using sc command e.g. tested work
sc create web2py binpath= python 
C:\Users\sugizo\Desktop\web2py\web2py\web2py.py -i 127.0.0.1 -p 8000 -a 
'password' start= auto
sc start web2py

but user can not pick their flavour about those parameters.

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: multiple functions in one view

2014-01-21 Thread En Ware
Thank you so much; this awesome I appreciate your time.

On Tuesday, January 21, 2014 9:37:04 AM UTC-6, En Ware wrote:

 Hello, 

   I am trying to figure out how to call more then function per view.
 I would like to be to have users fill out a form and and then as soon as they 
 submit 
 show the results sort of like SQLFORM. I also want to make the grid 
 editable so
 that users can hide rows and columns. 

 Thanks in Advance.



 #controller default.py

 def index():
 return dict()


 def tracker_form():
 record = db.content(request.args(0))
 show_record = request.args(0)
 form = SQLFORM(db.content, record, show_record)
 if form.process().accepted:
 response.flash = 'Submitted Successfully!'
 #response.view = 'http://127.0.0.1:8000/WnD/default/show_form'
 #return dict(show_record=show_record)
 elif form.errors: 
 response.flash = 'Form is not correct; please correct and submit 
 again'
 else:
 response.flash = 'Please fill out the damn form'
 return dict(form=form)
  


 def show_form():
 #rows = db().select(db.content.ALL)
 return dict(grid=SQLFORM.grid(db.content))





 #views 

 #tracker_form.html

 {{extend 'layout.html'}}
 h4centerTracking/center/h4
 {{=form}}
 {{=BEAUTIFY(request.vars)}}


 #show_form.html

 {{extend 'layout.html'}}
 h4centerRecords processed/center/h4

 {{=grid}}

 a href=http://127.0.0.1:8000/WnD/default/tracker_form;Back/a


 #index.html

 {{extend 'layout.html'}}
 titleWatch and Defend/title
 h4
 Current customers:
 /h4
 H4


 a href=http://127.0.0.1:8000/WnD/default/tracker_formcenterTracker 
 Monitoring click on the link/a/center
 
 /H4





-- 
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: Weird problems generating menu from database

2014-01-21 Thread web2pygroup
Ok that works, and I'm curious about that variable if you could please 
explain maybe I could use it and not have to ask to many more questions :)

Also I was wondering how I could incorporate what I had also posted 
originally - ([T('
Catalog'), False, '' - where this was the heading for the menu then the 
rest of the items come after it.  So instead of animals being first it 
would show catalog, then when the user puts the mouse over it drops down 
showing, animals, etc.

I tried changing the brackets around but to no avail.  Any pointers?  I 
tried using what I had originally created but all it does is create a 
seperate catalog right next to animals on the navbar with animals 
being the only thing doing the drop down.

Thanks again for your code it was nice to see it working unlike mine.


On Tuesday, January 21, 2014 12:52:35 PM UTC-6, James Burke wrote:

 You could simply declare it for testing purposes. 

 Set it to false. 


-- 
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: filepaths for library and images ?

2014-01-21 Thread Anthony


  Filename = os.path.join ( 'applications', 
 request.application,'static\images\pic_%s.png' % Edit_Select), 'wb') 


os.path.join(request.folder, 'static', 'images', 'pic_%s.png' % Edit_Select) 

Q2: 
 I made some libraries that I want to use more than one project. 
 Now I stored these in 
 ..controllers/my_support_libs.py


Controllers are not Python modules and cannot be imported. If you need to 
share a module, put it anywhere in the pythonpath and import from there. 
You can put it in the /modules folder of a given app and import from other 
apps via:

import applications.myapp.modules.mymodule

Anthony

-- 
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: Weird problems generating menu from database

2014-01-21 Thread web2pygroup
I decided to try and make Catalog my first choice in the menu by setting 
it as the first entry in the DB.  Then I put Animals with Catalog as 
its parent, then I added Dogs and set that with Animals as the parent.

Unfortunately it does not show the Dogs category.  Have I possibly done 
something?  I'm not seeing Dogs in the shell when I look at the 
response.menu...  I do see it in the DB though.

On Tuesday, January 21, 2014 12:52:35 PM UTC-6, James Burke wrote:

 You could simply declare it for testing purposes. 

 Set it to false. 


-- 
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: Weird problems generating menu from database

2014-01-21 Thread web2pygroup
I have also been trying your solution and have gotten to this point, when I 
try to run the shell to test it errors out immediately with:

AttributeError: 'Rows' object has no attribute 'as_tree'

Any hints on how to fix? Or something else I might try?  I do have the 
2.8.2 version..  I noticed when I do a db.store_catalog.tab key (within 
ipython2) I get this as options .as_dict, as_json, .as_xml, .as_yaml.  The 
only thing I'm familiar with that might be a tree is the .as_xml, is that 
what you meant?

Thanks for any/all time you can help it's greatly appreciated!

On Tuesday, January 21, 2014 9:45:27 AM UTC-6, Massimo Di Pierro wrote:

 First of all notice that if you use web2py2.8.2 you can do this:

 db.define_table('store_catalog',
 Field('title'),
 Field('slug',requires=IS_SLUG(),compute=lambda row: 
 IS_SLUG.urlify(row.title)),
 Field('parent_id','reference store_catalog'))

 def menu_rec(items): return 
 [(x.title,None,URL('action',args=x.slug),menu_rec(x.children)) for x in 
 items or []]
 response.menu = menu_rec(db(db.store_catalog).select().as_tree())

 And you get a recursive menu with arbitrary depth and a web interface to 
 edit it with slugs.

 On Tuesday, 21 January 2014 00:11:59 UTC-6, James Burke wrote:

 Hi,

 I managed to get one working a little while ago doing this. This has been 
 adapted for your situation, may require some tweaking:

 _tables.py - model
 db.define_table('store_catelog')


 db.define_table('store_catelog',
 Field('title', 'string'),
 Field('description', 'text'),
 Field('parent_catelog', 'reference store_catelog', default=None),
 format='%(title)s',
 redefine=True)

 menu.py - model
 response.menu = []

 categories = db(db.store_catelog.parent == None).select(orderby=db.
 store_catelog.id)

 for category in categories:
 response.menu+=[ (T(category.title), True if active_page == str(
 category.title.lower()) else False, URL('default','page/%s' % (category.
 title.lower())), [
 (T(i.title), True if active_page == str(i.id) else False, URL(
 'default','page/%s' % (i.id)), []) for i in db((db.stored_category.parent 
 == category.id)).select(db.store_category.ALL) if i.parent == category.id
 ]) ]

 The query returns any categories without a parent and adds them to the 
 menu. While doing so looks for any subcategories using the category as a 
 parent.

 Hope that helps you out.

 -James

 On Tuesday, January 21, 2014 9:33:50 AM UTC+13, americ...@gmail.comwrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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: Weird problems generating menu from database

2014-01-21 Thread web2pygroup
Ok figured out I needed to change that to as_trees.  However the database 
suggestion you gave is causing a

IntegrityError: FOREIGN KEY constraint failed

 error immediately upon trying to put any data into any field.  For example 
if I put Animals in the title and leave the other field parent_id blank 
it gives me the error.  If I put a number in parent_id with the title an 
error, and if I just put a number in the parent_id field also an error.

Any ideas?

Thanks

On Tuesday, January 21, 2014 9:45:27 AM UTC-6, Massimo Di Pierro wrote:

 First of all notice that if you use web2py2.8.2 you can do this:

 db.define_table('store_catalog',
 Field('title'),
 Field('slug',requires=IS_SLUG(),compute=lambda row: 
 IS_SLUG.urlify(row.title)),
 Field('parent_id','reference store_catalog'))

 def menu_rec(items): return 
 [(x.title,None,URL('action',args=x.slug),menu_rec(x.children)) for x in 
 items or []]
 response.menu = menu_rec(db(db.store_catalog).select().as_tree())

 And you get a recursive menu with arbitrary depth and a web interface to 
 edit it with slugs.

 On Tuesday, 21 January 2014 00:11:59 UTC-6, James Burke wrote:

 Hi,

 I managed to get one working a little while ago doing this. This has been 
 adapted for your situation, may require some tweaking:

 _tables.py - model
 db.define_table('store_catelog')


 db.define_table('store_catelog',
 Field('title', 'string'),
 Field('description', 'text'),
 Field('parent_catelog', 'reference store_catelog', default=None),
 format='%(title)s',
 redefine=True)

 menu.py - model
 response.menu = []

 categories = db(db.store_catelog.parent == None).select(orderby=db.
 store_catelog.id)

 for category in categories:
 response.menu+=[ (T(category.title), True if active_page == str(
 category.title.lower()) else False, URL('default','page/%s' % (category.
 title.lower())), [
 (T(i.title), True if active_page == str(i.id) else False, URL(
 'default','page/%s' % (i.id)), []) for i in db((db.stored_category.parent 
 == category.id)).select(db.store_category.ALL) if i.parent == category.id
 ]) ]

 The query returns any categories without a parent and adds them to the 
 menu. While doing so looks for any subcategories using the category as a 
 parent.

 Hope that helps you out.

 -James

 On Tuesday, January 21, 2014 9:33:50 AM UTC+13, americ...@gmail.comwrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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.


Re: [web2py] Re: filepaths for library and images ?

2014-01-21 Thread Stef Mientki

thanks Anthony,
the import now works partially.

The lib needs to know the database db is it possible to import that.
from db import db
doesn't work

cheers,
Stef

On 21-01-14 23:55, Anthony wrote:


 Filename = os.path.join ( 'applications',
request.application,'static\images\pic_%s.png' % Edit_Select), 'wb')


|
os.path.join(request.folder,'static','images','pic_%s.png'%Edit_Select)
|

Q2:
I made some libraries that I want to use more than one project.
Now I stored these in
..controllers/my_support_libs.py


Controllers are not Python modules and cannot be imported. If you need 
to share a module, put it anywhere in the pythonpath and import from 
there. You can put it in the /modules folder of a given app and import 
from other apps via:


|
importapplications.myapp.modules.mymodule
|

Anthony
--
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.


[web2py] Re: Button in Component Stealing Focus?

2014-01-21 Thread Ezer Silva
Same here. In my case, always that the URL ends with a '#' 
(url.com/app/controller/function#) the focus goes to a text box; when the 
url doesn't end with '#' it doesn't occur. I don't know why it's generating 
this behaviour, because I'm passing only unnamed args (request.args), not 
named args (request.vars).

-- 
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] SQLFORM.grid and smartgrid translate headings

2014-01-21 Thread Boris Aguilar
Do table headings can be translated when creating an smartgrid or grid? I 
can't find it on documentation. (and entries don't get created in my 
languages files)

-- 
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] How to create a dropdown selection page?

2014-01-21 Thread Adrian Zhang
Thank you, Tim. My previous confusion comes from which field should be 
format as IS_IN_SET or IS_IN_DB once 2 tables have many-to-many links or 
single-to-many links, how to represent related field in controller and 
view. Previously listed web posts really take confusions to a beginner. So 
I will post my experience, a simple case to explain that.

On Wednesday, January 22, 2014 4:02:00 AM UTC+8, Tim Richardson wrote:

 to get drop downs you need to set a validator in the field definition. 
 IS_IN_SET is one validator which causes SQLFORM to automatically make a 
 dropdown.  so you don't do anything in SQLFORM. Rather you set up your data 
 model when defining tables. 

-- 
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 and smartgrid translate headings

2014-01-21 Thread 黄祥
if you define the field label with translation it will support 
internationalization.
e.g. 
db.book.title.label = T('Title')

browse the page that select book table with others language selected, e.g. 
Indonesian

then goes to languages folder and then translate it manually 
languages\id.py.
'Title': 'Judul',

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: filepaths for library and images ?

2014-01-21 Thread Anthony
Please see 
http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules
.

On Tuesday, January 21, 2014 7:14:05 PM UTC-5, aapaap wrote:

  thanks Anthony,
 the import now works partially.

 The lib needs to know the database db is it possible to import that.
 from db import db 
 doesn't work

 cheers,
 Stef

 On 21-01-14 23:55, Anthony wrote:
  
   Filename = os.path.join ( 'applications', 
 request.application,'static\images\pic_%s.png' % Edit_Select), 'wb') 


  os.path.join(request.folder, 'static', 'images', 'pic_%s.png' % 
 Edit_Select) 
  
  Q2: 
 I made some libraries that I want to use more than one project. 
 Now I stored these in 
 ..controllers/my_support_libs.py


  Controllers are not Python modules and cannot be imported. If you need 
 to share a module, put it anywhere in the pythonpath and import from there. 
 You can put it in the /modules folder of a given app and import from other 
 apps via:

  import applications.myapp.modules.mymodule
  
  Anthony
  -- 
 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+un...@googlegroups.com javascript:.
 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.


[web2py] pass as parameter or import

2014-01-21 Thread Jayadevan M
From my scheduler function under models, I can call my function under 
modules like this 

mymodule.myfunction(db)

I can also do it this way - 

In db.py,
from gluon import current
..
current.db = db

In my function in modules, do
from gluon import current
..
db = current.db

Which is the right/better approach? Why?

-- 
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: Install Web2py on Windows with Apache and Mod WSGI (using command line, *nix flavour)

2014-01-21 Thread Massimo Di Pierro
I'd be happy to include it in web2py when you make it.

On Tuesday, 21 January 2014 16:21:29 UTC-6, 黄祥 wrote:

 i plan to use bat script or create an exe too using autoit for this. but 
 the main problem in my pov is about the software version. let say in linux 
 you just type e.g.
 sudo apt-get install -y apache2
 it will get the latest version of apache, if you not explicit tell which 
 version, yet in windows, i think can not, i manually download from website 
 and then put url link on powershell.
 in linux there is repo that is maintain by the distro, n in windows there 
 is no repo, any ideas or suggestion?

 i plan to create the web2py service too like the book said, but i still 
 confuse what is it about :
 python web2py.py -W install

 see the help python web2py.py didn't found -W is about. just a suggestion 
 why not create it simple windows service using sc command e.g. tested work
 sc create web2py binpath= python 
 C:\Users\sugizo\Desktop\web2py\web2py\web2py.py -i 127.0.0.1 -p 8000 -a 
 'password' start= auto
 sc start web2py

 but user can not pick their flavour about those parameters.

 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: Weird problems generating menu from database

2014-01-21 Thread Massimo Di Pierro
Sorry typo. Let's try again:

db.define_table('store_catalog',
Field('title'),
Field('slug',requires=IS_SLUG(),compute=lambda row: 
IS_SLUG.urlify(row.titl\
e)),
Field('parent_id','reference store_catalog'))

id1 = db.store_catalog.insert(title='main')
id2 = db.store_catalog.insert(title='one',parent_id=id1)
id3 = db.store_catalog.insert(title='two',parent_id=id2)

def menu_rec(items): return 
[(x.title,None,URL('action',args=x.slug),menu_rec(x\
.children)) for x in items or []]
response.menu = menu_rec(db(db.store_catalog).select().as_trees())
print response.menu

On Tuesday, 21 January 2014 12:17:19 UTC-6, web2pygroup wrote:

 Here's what I've tried so far and here's the results if it helps any to 
 get me on the right track, plus I hope this helps someone else looking for 
 this to because this is something very commonly done in PHP.

 I have tried changing this:
 response.menu3[-1]+=([[(T(subcat.subcategory)), False, 'link',]])

 to this:
 response.menu3[-1]+=([(T(subcat.subcategory)), False, 'link',])

 Which changes the output in the shell to:
 [lazyT 'Catalog',
  False,
  '',
  [lazyT 'Animals',
   False,
   'link',
   lazyT 'Dogs',
   False,
   'link',
   lazyT 'Cats',
   False,
   'link']]

 Which obviously isn't correct.  

 Continuing:

 original:
 response.menu3[-1]+=([[(T(subcat.subcategory)), False, 'link',]])

 to this:
 response.menu3+=([[(T(subcat.subcategory)), False, 'link',]])

 Gives this in the shell output:
 [lazyT 'Catalog',
  False,
  '',
  [lazyT 'Animals', False, 'link'],
  [lazyT 'Dogs', False, 'link'],
  [lazyT 'Cats', False, 'link']]

 Again obviously incorrect.  Continuing:

 original:
 response.menu3+=([[(T(subcat.subcategory)), False, 'link',]])

 changed:
 response.menu3[-1]+=((T(subcat.subcategory)), False, 'link',)

 Shell output shows:
 [lazyT 'Catalog',
  False,
  '',
  [lazyT 'Animals',
   False,
   'link',
   lazyT 'Dogs',
   False,
   'link',
   lazyT 'Cats',
   False,
   'link']]

 I tried additional variations but, not sure how much space we have here to 
 keep going with my 2 weeks worth of work.  Essentially the end result is 
 the same a bracket missing to seperate the subcategories.  I've been able 
 to modify and add to lists before, however I've never really experienced a 
 situation where the negative slice appears to be ignored (removing the 
 bracket at the end of dogs and beginning of cats as it is doing for the 
 main category Animals as can be seen), even removed the negative slice 
 ([-1]) for the main categories iteration and when I do it clearly shows 
 that it is actually doing the negative slice properly because the brackets 
 come back at the end of Animals, unlike the subcategories that do not 
 appear to be removing the bracket(s)


 On Monday, January 20, 2014 2:33:50 PM UTC-6, web2pygroup wrote:


 Hi all,

 I have been trying for a little over 2 weeks to figure this out...

 I'm trying to generate a menu that drops down, I have been able to 
 statically create it by overwriting sample app that has the same drop down 
 menu like the web2py.com site.

 I have this in my db.py:
 db.define_table('store_catalog',
 Field('maincategory', 'string'),
 Field('subcategory', 'string'),
 Field('description', 'text'))


 in my menu.py I have gotten this so far:
 response.menu=[]
 response.menu.append([T('Catalog'), False, '',
[(T('%s' % menucatchoice['maincategory']), False, 'link',
 [(T('%s' % menucatchoice['subcategory']), False, 
 'link'),]) for menucatchoice in rows ] ])

 It gets me a drop down menu except that for each subcategory it repeats 
 adding it to the main category. Let's say there is only 1 main category and 
 2 subs that go after that
 Catalog (this just shows with the caret next to it as intended)
 MainCategory
 Sub
 Sub
 What I have does put the Catalog for the first but, what I get is:
 MainCategory
 (blank)
 MainCategory(don't want this it's being repeated)
Subcategory
 MainCategory(and this one is also a repeat)
Subcategory

 I have tried to break out the response.menu with so many different 
 .appends it's not funny.  I have also tried adding the [-1].  This was 
 the closest I have gotten to what I want it to look like.  I'm at an 
 absolute loss on this, any and all help would be greatly 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.