Re: [web2py] Re: admin-page and ignore_common_filters
This is the new code: from gluon.fileutils import check_credentials db.auth_group._common_filter=lambda query: \ (db.auth_group.org==session.org) *or check_credentials(request)* I have tested check_credentials(request): it returns True - good! But - sorry! - it did not solve the problem: - Let's say I have 100 auth_group rows with org==1 and 100 auth_group rows with org==2 - The admin application tells me 100 selected, but I can *see all 200*rows. - I have tried to change one record. I can open this row, change any field and submit it. - I get the flash *Done* But nothing has happened - the old values are in the table. About the message value not in database: my fault - a wrong db.auth_group.org.requires somewhere in the model. 2012/8/21 Massimo Di Pierro massimo.dipie...@gmail.com Apologies check_credentials(request) instead of check_credentials('admin') On Monday, 20 August 2012 14:33:55 UTC-5, mweissen wrote: A little bit more code: db.define_table('org', Field('orgnr', Field(shortname', length=20, requires=IS_LENGTH(maxsize=20,**minsize=3)), ... ) auth.settings.extra_fields['**auth_group']=[ Field('org','reference org', default=lambda: session.org, requires=IS_IN_DB(db, 'org.id', '%(shortname)s', error_message=T('Not allowed')), ),... from gluon.fileutils import check_credentials db.auth_group._common_filter=**lambda query: (db.auth_group.org==session.**org http://session.org) or check_credentials('admin') Now I am using the admin interface and I try to change one row of auth_group. The same result as before (without check_credentials('admin')) - The value of auth_group.org==1. - The error messae is value not in database - And, of course, there is a record in db.org with db.org.id==1 To learn more about check_credentials I added: if check_credentials('admin'): print 'Admin' Only for the test. And I get a new error message: 127.0.0.1.2012-08-20.21-05-04.**43dc8360-a22d-408d-8889-**00fe62ef4a38 type 'exceptions.AttributeError' 'str' object has no attribute 'env' Version web2py™ (2, 0, 0, datetime.datetime(2012, 8, 9, 8, 57, 54), 'dev') Python Python 2.7.2: D:\Python27\python.exe Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. Traceback (most recent call last): File D:\...\web2py\gluon\**restricted.py, line 205, in restricted exec ccode in environment File D:/.../web2py/applications/**secure/models/db.py http://127.0.0.1:8000/admin/default/edit/secure/models/db.py, line 389, in module if check_credentials('admin'): print 'Admin' File D:\...\web2py\gluon\**fileutils.py, line 328, in check_credentials if request.env.web2py_runtime_gae**: AttributeError: 'str' object has no attribute 'env' 2012/8/20 Massimo Di Pierro massimo@gmail.com You can do: db.define_table(, common_filter = None if not session.org else (lambda query:(db.my_table.org==sessio**n.org http://session.org/))) you can also use the check: from gluon.fileutils import check_credentials check_credentials('admin') #returns true if you are logged as admin. On Monday, 20 August 2012 12:48:29 UTC-5, mweissen wrote: (1) session.org will be set with the login. But I am an administrator: I think I should use the admin application without a login to the application itself. (2) Lets say session.org==1: now it is not possible to change a record with my_table.org==2 using the admin app. (3) Did you mean: common_filter = lambda query: (db.my_table.org==session.org) if session.org else True Interesting idea! 2012/8/20 Massimo Di Pierro massimo@gmail.com How do you set the common filter? Seems to me if session.org is not set, the common filter should not be set. web2py cannot ignore it because it does the wrong thing. On Monday, 20 August 2012 11:41:41 UTC-5, mweissen wrote: I have an application which should be used by some organizations. Therefore I have added Field('org','reference org', default=lambda:session.org), and common_filter = lambda query: db.my_table.org==session.org to my_table. session.org contails the id of the respective organization. Great feature,works fine! But using the database administration of the admin-application the common filter is still active. There is an ignore_rw=True in the admin application and I think I have read somewhere that there is also an ignore_common_filters=True . If session.org is not set, a database db select shows strange effects: - I can see the first 100 rows. - But the message is 0 selected - It is not possible to Update a record A simple ignore_common_filters=True at the appropriate location should solve the problem. I have taken a quick look at the code, but I think this statement has to be very inside, therefore I have no concrete proposal. Regards, Martin -- -- -- --
[web2py] Re: web2py.css changes for bootstrap
web2py.css includes styling for common html tags in addition to specific web2py stuff. The loading order in current layout.html is below. {{ response.files.append(URL('static','css/bootstrap.min.css')) response.files.append(URL('static','css/bootstrap-responsive.min.css')) response.files.append(URL('static','css/web2py.css')) response.files.append(URL('static','css/bootswatch.css')) }} Perhaps we should be loading web2py.css first? Did you try that? On Tuesday, August 21, 2012 2:13:12 AM UTC+1, Michael W wrote: By default web2py.css is pretty heavy-handed on form controls. Would it be possible to restrict the form controls in web2py.css by class? It might require setting a default class on all generated forms. grid and smartgrid do this already, but using default SQLFORM() does not set a default class on the form currently. My thought is to change SQLFORM so it sets a default 'web2py_form' class which is what grid and smartgrid already do. I would then restrict all the form controls in web2py.css to this class. This would make it much easier to use non-web2py css frameworks like bootstrap with forms. Right now to get it working properly I have to comment/remove a lot from web2py.css to get it using bootstrap fully in my forms, even with the new bootstrap formstyle that's in trunk. Would this break anything? Michael --
[web2py] Re: Standalone application (mac/win)
My original application is done few years ago and some things has changed, so I'm getting an error when importing application to the a new web2py. Maybe someone can help what to do with library gluon: Traceback (most recent call last): File gluon/restricted.py, line 205, in restricted File /Users/markom/Downloads/web2py/web2py.app/Contents/Resources/applications/yllapito/models/forms.py http://127.0.0.1:8002/admin/default/edit/yllapito/models/forms.py, line 1, in module File gluon/custom_import.py, line 293, in __call__ File gluon/custom_import.py, line 78, in __call__ ImportError: No module named htmlextended I placed whole gluon directory to the web2py root, maybe it needs to be imported somewhere? I'm using gluon/htmlextended.py library on forms.py model file... -Marko maanantai, 20. elokuuta 2012 15.08.27 UTC+3 mmstud kirjoitti: Is it possible to create easy to use standalone web2py application for mac and win users? I have registry application and remote database which should be available for clients. I'm searching for a solution where user just clicks the application icon and then browser (maybe internal?) starts up to the correct localhostaddress. Then users signs in to the application and uses it. Regards, -Marko --
[web2py] Re: Pre-populate profile form
Correct! Thanks Anthony. On Tuesday, August 21, 2012 1:07:34 AM UTC+2, Anthony wrote: You never processed the form. You have to call form.process() or form.accepts() for your variable assignments to get transferred to the widgets. Anthony On Monday, August 20, 2012 5:30:19 AM UTC-4, Daniel Gonzalez wrote: Hi, I am trying to pre-populate the profile form with some random data, which I am using for testing, like this: def random_pre_populate(form): register_data = RegisterData().random() form.vars.first_name = register_data['first_name'] form.vars.surname1 = register_data['surname1'] form.vars.surname2 = register_data['surname2'] form.vars.email = register_data['email'] form.vars.address= register_data['address'] form.vars.postcode = register_data['postcode'] form.vars.city = register_data['city'] form.vars.country= register_data['country'] return form def index(): response.flash = T(Welcome to Acme!) response.my_header = False login_form= FORM(INPUT(_name='email', _style = 'width:360px;height:28px;margin-bottom:0px;', requires=IS_EMAIL( error_message=auth.messages.invalid_email), _placeholder = T('Email')), INPUT(_type = 'submit', _value = T('Sign In'),_class = 'btn btn-large'), _action = URL(r = request, f = agent_redirect)) register_form = FORM(INPUT(_name='email', _style = 'width:360px;height:28px;margin-bottom:0px;', requires=IS_EMAIL( error_message=auth.messages.invalid_email), _placeholder = T('Email')), INPUT(_type = 'submit', _value = T('Try Out'),_class = 'btn btn-large btn-primary'), _action = URL(r = request, f = 'user/register')) # Pre-populate the register_form - this is useful for testing, to avoid having to type this data register_form = random_pre_populate(register_form) return dict(message = T('Hello world!'), login_form= login_form, register_form = register_form) The data generation is done in RegisterData().random(), which just uses mostly-random data. Unfortunately the data does not appear in the profile form. How can I achieve this? Thanks, Daniel --
[web2py] Re: web2py.css changes for bootstrap
Are you talking about the stuff at the top of web2py.css marked these MUST stay ( http://code.google.com/p/web2py/source/browse/applications/welcome/static/css/web2py.css#1)? Now that we're using Bootstrap, I think most if not all of that section can probably be cut since Bootstrap already handles basic styles. web2py.css should be limited to web2py-specific things only. Anthony On Monday, August 20, 2012 9:13:12 PM UTC-4, Michael W wrote: By default web2py.css is pretty heavy-handed on form controls. Would it be possible to restrict the form controls in web2py.css by class? It might require setting a default class on all generated forms. grid and smartgrid do this already, but using default SQLFORM() does not set a default class on the form currently. My thought is to change SQLFORM so it sets a default 'web2py_form' class which is what grid and smartgrid already do. I would then restrict all the form controls in web2py.css to this class. This would make it much easier to use non-web2py css frameworks like bootstrap with forms. Right now to get it working properly I have to comment/remove a lot from web2py.css to get it using bootstrap fully in my forms, even with the new bootstrap formstyle that's in trunk. Would this break anything? Michael --
[web2py] Re: Displaying a message following auth.requires_login() redirect
That's perfect, thanks Anthony. On Tuesday, 21 August 2012 00:00:16 UTC+1, Anthony wrote: Maybe try: def failed_authentication(url): session.flash = You must be logged in to view this page redirect(url) auth.settings.on_failed_authentication = failed_authentication Anthony On Monday, August 20, 2012 5:48:33 AM UTC-4, Rob Goldsmith wrote: Is it possible to display a message to the user on the login form when they have been redirected as a result of an auth.requires_login() redirect? (e.g. You must be logged in to view this page) I found this discussion of the functionality from 2010 https://groups.google.com/forum/?fromgroups#!topic/web2py/iEHCEFQYXrw%5B1-25%5D but it doesn't look like it was ever adopted. Is there an alternative way of doing this? Thanks. --
[web2py] Re: web2py.css changes for bootstrap
Putting web2py.css at the top of this list fixes many things for me actually, in relation to bootstrap and forms. The only problem left that I see is the div.error rule in web2py.css, it should be less specific so bootstrap or another css framework can override it properly. Michael On Monday, August 20, 2012 11:12:28 PM UTC-7, villas wrote: web2py.css includes styling for common html tags in addition to specific web2py stuff. The loading order in current layout.html is below. {{ response.files.append(URL('static','css/bootstrap.min.css')) response.files.append(URL('static','css/bootstrap-responsive.min.css')) response.files.append(URL('static','css/web2py.css')) response.files.append(URL('static','css/bootswatch.css')) }} Perhaps we should be loading web2py.css first? Did you try that? On Tuesday, August 21, 2012 2:13:12 AM UTC+1, Michael W wrote: By default web2py.css is pretty heavy-handed on form controls. Would it be possible to restrict the form controls in web2py.css by class? It might require setting a default class on all generated forms. grid and smartgrid do this already, but using default SQLFORM() does not set a default class on the form currently. My thought is to change SQLFORM so it sets a default 'web2py_form' class which is what grid and smartgrid already do. I would then restrict all the form controls in web2py.css to this class. This would make it much easier to use non-web2py css frameworks like bootstrap with forms. Right now to get it working properly I have to comment/remove a lot from web2py.css to get it using bootstrap fully in my forms, even with the new bootstrap formstyle that's in trunk. Would this break anything? Michael --
[web2py] TypeError: 'lazyT' object is not callable
Something was broken by updates in recent days from the trunk. From this code: response.flash(T(Searching...)) I get the error in the subject line. Previously I could use this without a problem. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) --
[web2py] Router for multiple controllers
Hello, I have the following routing requirements, which I am unable to configure in routes.py: www.mysite.com/hello - application1, controller1, hello www.mysite.com/bye - application1, controller2, bye As you can see, the functions hello and bye are in different controllers. Is it possible to achieve this with routes.py? Thanks, Daniel --
[web2py] Can a table field reference a list?
Hi guys, db.define_table('activities', Field('name', 'string',length=255,requires=IS_NOT_EMPTY()), Field('description','text'), format='%(name)s' ) db.define_table('activity', Field('user_id','reference auth_user',default=auth.user_id), Field('activity_id','reference activities'), ) Instead of the above code, can I have the second table reference a list / tuple instead of a table? How should I do it? --
[web2py] Re: Can a table field reference a list?
As I know, you can write code like, Field('activity_id','list:reference activities'), From official document, http://web2py.com/books/default/chapter/29/6#DAL,-Table,-Field list:reference tableIS_IN_DB(db,table.field,format,multiple=True) 2012년 8월 21일 화요일 오후 6시 24분 9초 UTC+9, lyn2py 님의 말: Hi guys, db.define_table('activities', Field('name', 'string',length=255,requires=IS_NOT_EMPTY()), Field('description','text'), format='%(name)s' ) db.define_table('activity', Field('user_id','reference auth_user',default=auth.user_id), Field('activity_id','reference activities'), ) Instead of the above code, can I have the second table reference a list / tuple instead of a table? How should I do it? --
[web2py] Re: Can a table field reference a list?
Sorry I think my language could be off and subject to misinterpretation. I meant, I define a dict like activities = {1:diving,2:swimming,3:skiing} And reference it in the second table. On Tuesday, August 21, 2012 5:24:09 PM UTC+8, lyn2py wrote: Hi guys, db.define_table('activities', Field('name', 'string',length=255,requires=IS_NOT_EMPTY()), Field('description','text'), format='%(name)s' ) db.define_table('activity', Field('user_id','reference auth_user',default=auth.user_id), Field('activity_id','reference activities'), ) Instead of the above code, can I have the second table reference a list / tuple instead of a table? How should I do it? --
[web2py] Re: Major speed improvement need testers
This line does not seem to work in latest trunk. Is that because of the new Storage object? session.setdefault(history, []) On Saturday, 18 August 2012 04:00:44 UTC+1, Massimo Di Pierro wrote: There are two major speed improvements in trunk and I am not sure whether they should go in web2py 2.0 next week. 1) Lazy table (based on ideas from Bruno). db = DAL(, lazy_tables=True) db.define_table('person',Field('name')) the table is instantiated only when db.person is accessed. So with some care: Field(, requires=) # LAZY (good) db.table.field.requires = ... # NOT LAZY (bad) Field('other','reference table') # LAZY (good) Field('other',db.table) # NOT LAZY (bad) this may be a big speedup. 2) There is a new implementation of class Storage. This is a most accessed object within web2py and now it is 10x faster. Yet I am not sure if this breaks something. It would be great if you could try the nightly build (or trunk) and report if you experienced any problem. It would be even better if you could run some benchmarks of your code before and after the changes suggested at 1). Massimo --
[web2py] NameError: global name 'requests' is not defined
Hi, I am using mailgun libraries to send mail from my web2py application,I followed example given in mailgun site mailgun.com: 1. requests.post((https://api.mailgun.net/v2/samples.mailgun.org/messages;), 2. auth=(api, key-3ax6xnjp29jd6fds4gc373sgvjxteol0), 3. data={ 4. from: Excited User m...@samples.mailgun.org, 5. to: [d...@mailgun.net, 6.d...@mailgun.net], 7. subject: Hello, 8. text: Testing some Mailgun awesomeness!}) but when i am using the above code, web2py gives error NameError: global name 'requests' is not defined, what is this requests variable and how to initialize it?OR do i need to use some other libraries which already has this variable to make use of it. Please guide me to resolve this issue. --
[web2py] Can you compute fields from another table?
Can a computed field take values from other tables? Thanks! --
[web2py] Re: NameError: global name 'requests' is not defined
requests is a cool library (don't confuse that with the request object (without the s) that is available in web2py). Their examples lacks of the import line (import requests). Of course you need to install that to be able to use it with pip install requests. Il giorno martedì 21 agosto 2012 12:09:24 UTC+2, Amit ha scritto: Hi, I am using mailgun libraries to send mail from my web2py application,I followed example given in mailgun site mailgun.com: 1. requests.post((https://api.mailgun.net/v2/samples.mailgun.org/messages;), 2. auth=(api, key-3ax6xnjp29jd6fds4gc373sgvjxteol0), 3. data={ 4. from: Excited User m...@samples.mailgun.org javascript:, 5. to: [du...@mailgun.net javascript:, 6.de...@mailgun.net javascript:], 7. subject: Hello, 8. text: Testing some Mailgun awesomeness!}) but when i am using the above code, web2py gives error NameError: global name 'requests' is not defined, what is this requests variable and how to initialize it?OR do i need to use some other libraries which already has this variable to make use of it. Please guide me to resolve this issue. --
[web2py] bug in dbnew part of ticket-system fixed
hi, i came across a bug in the ticket system while trying to switch from filesystem to db. the db_ready variable needs to be returned in admin/controllers/default.py also in the dbnew part. line 1196: return dict(errors = [x[1] for x in decorated], app=app, method=method, db_ready=db_ready) instead of just return dict(errors = [x[1] for x in decorated], app=app, method=method) ciao, sven --
Re: [web2py] Re: NameError: global name 'requests' is not defined
Thanks Niphold :), I installed requests libraries using easy install and able to see requests folder named requests-0.13.8-py2.7.egg in site-packages folder and used import statement like : from requests import * but still getting same error :( what I observed is : there is no module name requests in the library but there is a folder name requests available inside requests-0.13.8-py2.7.egg folder, so not sure what to import from this libray? On Tue, Aug 21, 2012 at 3:43 PM, Niphlod niph...@gmail.com wrote: requests is a cool library (don't confuse that with the request object (without the s) that is available in web2py). Their examples lacks of the import line (import requests). Of course you need to install that to be able to use it with pip install requests. Il giorno martedì 21 agosto 2012 12:09:24 UTC+2, Amit ha scritto: Hi, I am using mailgun libraries to send mail from my web2py application,I followed example given in mailgun site mailgun.com: 1. requests.post((https://api.**mailgun.net/v2/samples.**mailgun.org/messages https://api.mailgun.net/v2/samples.mailgun.org/messages), 2. auth=(api, key-**3ax6xnjp29jd6fds4gc373sgvjxteo**l0), 3. data={ 4. from: Excited User m...@samples.mailgun.org, 5. to: [du...@mailgun.net, 6.de...@mailgun.net], 7. subject: Hello, 8. text: Testing some Mailgun awesomeness!}) but when i am using the above code, web2py gives error NameError: global name 'requests' is not defined, what is this requests variable and how to initialize it?OR do i need to use some other libraries which already has this variable to make use of it. Please guide me to resolve this issue. -- --
Re: [web2py] Re: NameError: global name 'requests' is not defined
I resolved the issue, somehow after installing it to Lib/site-packages of python installation path , it has not added to PYTHONPATH, because of that requests is not recognized, i have explicitly added it to the PYTHONPATH then its working fine. Thanks, Amit On Tue, Aug 21, 2012 at 4:02 PM, Amit amit.khaw...@gmail.com wrote: Thanks Niphold :), I installed requests libraries using easy install and able to see requests folder named requests-0.13.8-py2.7.egg in site-packages folder and used import statement like : from requests import * but still getting same error :( what I observed is : there is no module name requests in the library but there is a folder name requests available inside requests-0.13.8-py2.7.egg folder, so not sure what to import from this libray? On Tue, Aug 21, 2012 at 3:43 PM, Niphlod niph...@gmail.com wrote: requests is a cool library (don't confuse that with the request object (without the s) that is available in web2py). Their examples lacks of the import line (import requests). Of course you need to install that to be able to use it with pip install requests. Il giorno martedì 21 agosto 2012 12:09:24 UTC+2, Amit ha scritto: Hi, I am using mailgun libraries to send mail from my web2py application,I followed example given in mailgun site mailgun.com: 1. requests.post((https://api.**mailgun.net/v2/samples.**mailgun.org/messages https://api.mailgun.net/v2/samples.mailgun.org/messages), 2. auth=(api, key-**3ax6xnjp29jd6fds4gc373sgvjxteo**l0), 3. data={ 4. from: Excited User m...@samples.mailgun.org, 5. to: [du...@mailgun.net, 6.de...@mailgun.net], 7. subject: Hello, 8. text: Testing some Mailgun awesomeness!}) but when i am using the above code, web2py gives error NameError: global name 'requests' is not defined, what is this requests variable and how to initialize it?OR do i need to use some other libraries which already has this variable to make use of it. Please guide me to resolve this issue. -- --
[web2py] Nice presentations -- impress.js
http://bartaz.github.com/impress.js mic --
Re: [web2py] Re: admin-page and ignore_common_filters
I think you want: from gluon.fileutils import check_credentials if not *check_credentials(request):* * if not session.org: redirect('some_error_page') * db.auth_group._common_filter=lambda query: (db.auth_group.org== session.org) On Tuesday, 21 August 2012 01:04:38 UTC-5, mweissen wrote: This is the new code: from gluon.fileutils import check_credentials db.auth_group._common_filter=lambda query: \ (db.auth_group.org==session.org) *or check_credentials(request)* I have tested check_credentials(request): it returns True - good! But - sorry! - it did not solve the problem: - Let's say I have 100 auth_group rows with org==1 and 100 auth_group rows with org==2 - The admin application tells me 100 selected, but I can *see all 200 * rows. - I have tried to change one record. I can open this row, change any field and submit it. - I get the flash *Done* But nothing has happened - the old values are in the table. About the message value not in database: my fault - a wrong db.auth_group.org.requires somewhere in the model. 2012/8/21 Massimo Di Pierro massimo@gmail.com javascript: Apologies check_credentials(request) instead of check_credentials('admin') On Monday, 20 August 2012 14:33:55 UTC-5, mweissen wrote: A little bit more code: db.define_table('org', Field('orgnr', Field(shortname', length=20, requires=IS_LENGTH(maxsize=20,**minsize=3)), ... ) auth.settings.extra_fields['**auth_group']=[ Field('org','reference org', default=lambda: session.org, requires=IS_IN_DB(db, 'org.id', '%(shortname)s', error_message=T('Not allowed')), ),... from gluon.fileutils import check_credentials db.auth_group._common_filter=**lambda query: (db.auth_group.org==session.**org http://session.org) or check_credentials('admin') Now I am using the admin interface and I try to change one row of auth_group. The same result as before (without check_credentials('admin')) - The value of auth_group.org==1. - The error messae is value not in database - And, of course, there is a record in db.org with db.org.id==1 To learn more about check_credentials I added: if check_credentials('admin'): print 'Admin' Only for the test. And I get a new error message: 127.0.0.1.2012-08-20.21-05-04.**43dc8360-a22d-408d-8889-**00fe62ef4a38 type 'exceptions.AttributeError' 'str' object has no attribute 'env' Version web2py™ (2, 0, 0, datetime.datetime(2012, 8, 9, 8, 57, 54), 'dev') Python Python 2.7.2: D:\Python27\python.exe Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. Traceback (most recent call last): File D:\...\web2py\gluon\**restricted.py, line 205, in restricted exec ccode in environment File D:/.../web2py/applications/**secure/models/db.py http://127.0.0.1:8000/admin/default/edit/secure/models/db.py, line 389, in module if check_credentials('admin'): print 'Admin' File D:\...\web2py\gluon\**fileutils.py, line 328, in check_credentials if request.env.web2py_runtime_gae**: AttributeError: 'str' object has no attribute 'env' 2012/8/20 Massimo Di Pierro massimo@gmail.com You can do: db.define_table(, common_filter = None if not session.org else (lambda query:(db.my_table.org==sessio**n.org http://session.org/))) you can also use the check: from gluon.fileutils import check_credentials check_credentials('admin') #returns true if you are logged as admin. On Monday, 20 August 2012 12:48:29 UTC-5, mweissen wrote: (1) session.org will be set with the login. But I am an administrator: I think I should use the admin application without a login to the application itself. (2) Lets say session.org==1: now it is not possible to change a record with my_table.org==2 using the admin app. (3) Did you mean: common_filter = lambda query: (db.my_table.org==session.org) if session.org else True Interesting idea! 2012/8/20 Massimo Di Pierro massimo@gmail.com How do you set the common filter? Seems to me if session.org is not set, the common filter should not be set. web2py cannot ignore it because it does the wrong thing. On Monday, 20 August 2012 11:41:41 UTC-5, mweissen wrote: I have an application which should be used by some organizations. Therefore I have added Field('org','reference org', default=lambda:session.org), and common_filter = lambda query: db.my_table.org==session.org to my_table. session.org contails the id of the respective organization. Great feature,works fine! But using the database administration of the admin-application the common filter is still active. There is an ignore_rw=True in the admin application and I think I have read somewhere that there is also an ignore_common_filters=True. If session.org is not set, a database db select shows strange effects: - I can see
[web2py] Re: Can a table field reference a list?
Do you mean something like this? activities = {1:'diving',2:'swimming',3:'skiing'} Field('activity_id','integer',requires=IS_IN_SET(activities),represent=lambda i: activities[i]) On Tuesday, 21 August 2012 04:24:09 UTC-5, lyn2py wrote: Hi guys, db.define_table('activities', Field('name', 'string',length=255,requires=IS_NOT_EMPTY()), Field('description','text'), format='%(name)s' ) db.define_table('activity', Field('user_id','reference auth_user',default=auth.user_id), Field('activity_id','reference activities'), ) Instead of the above code, can I have the second table reference a list / tuple instead of a table? How should I do it? --
[web2py] Re: Major speed improvement need testers
What does not work? The new store has for now been reverted. On Tuesday, 21 August 2012 05:07:32 UTC-5, simon wrote: This line does not seem to work in latest trunk. Is that because of the new Storage object? session.setdefault(history, []) On Saturday, 18 August 2012 04:00:44 UTC+1, Massimo Di Pierro wrote: There are two major speed improvements in trunk and I am not sure whether they should go in web2py 2.0 next week. 1) Lazy table (based on ideas from Bruno). db = DAL(, lazy_tables=True) db.define_table('person',Field('name')) the table is instantiated only when db.person is accessed. So with some care: Field(, requires=) # LAZY (good) db.table.field.requires = ... # NOT LAZY (bad) Field('other','reference table') # LAZY (good) Field('other',db.table) # NOT LAZY (bad) this may be a big speedup. 2) There is a new implementation of class Storage. This is a most accessed object within web2py and now it is 10x faster. Yet I am not sure if this breaks something. It would be great if you could try the nightly build (or trunk) and report if you experienced any problem. It would be even better if you could run some benchmarks of your code before and after the changes suggested at 1). Massimo --
[web2py] Re: Can you compute fields from another table?
yes. Field('name',compute=lambda row: db.other_table(row.other_id).other_field) On Tuesday, 21 August 2012 05:11:29 UTC-5, lyn2py wrote: Can a computed field take values from other tables? Thanks! --
[web2py] Re: bug in dbnew part of ticket-system fixed
This should already be fixed in trunk. Thanks for reporting it. On Tuesday, 21 August 2012 05:25:49 UTC-5, sunny wrote: hi, i came across a bug in the ticket system while trying to switch from filesystem to db. the db_ready variable needs to be returned in admin/controllers/default.py also in the dbnew part. line 1196: return dict(errors = [x[1] for x in decorated], app=app, method=method, db_ready=db_ready) instead of just return dict(errors = [x[1] for x in decorated], app=app, method=method) ciao, sven --
[web2py] How to apply language translation on requires field when showing other table field values.
In my application I have to specify a title field as below Field('title', type='string',label=T('Title'),requires=IS_IN_DB(db,db.t_title.id, '%(name)s',orderby=db.t_title.id)) all the title options are mentioned in the t_title table. For example in t_title table I have values Mr. and Mrs. For english language this is fine. But for german language I have to display Herr and Frau. How can I set language translation 'T()' to title values. So I can add the corresponding title names in other language files. --
[web2py] Re: default tab key behavior change in fields
Hi, This is the script, i have generated but anyhow, it jumps to next key and tries to validate and the it looses focus. Another problem is, my script only work for a certain kind of input fields. is there a way to get all the input fields when i add it into web2py_ajax.html script type=text/javascript $(document).ready(function(){ textboxes = $(input.double); $(.double).click(function(){ if ($.browser.mozilla) { $(textboxes).keypress (checkForEnter); } else { $(textboxes).keydown (checkForEnter); } }); }); function checkForEnter (event) { if (event.keyCode == 13) { currentBoxNumber = textboxes.index(this); if (textboxes[currentBoxNumber + 1] != null) { nextBox = textboxes[currentBoxNumber + 1] nextBox.focus(); nextBox.select(); } else{ event.preventDefault(); return false; } } } /script Am Montag, 20. August 2012 21:51:10 UTC+2 schrieb Anthony: Either directly in layout.html or in a JS file loaded into every page, include the code that checks for enter key presses in input fields (use the $('input') jQuery selector to find all input fields on the page). Anthony On Monday, August 20, 2012 8:56:18 AM UTC-4, max wrote: hi anthony, i can include the change in the views/xyz.html , but how cupld i set it globally for all the forms? Am Montag, 13. August 2012 15:50:25 UTC+2 schrieb max: thank anthony. Am Montag, 13. August 2012 15:30:24 UTC+2 schrieb Anthony: On Monday, August 13, 2012 9:24:13 AM UTC-4, max wrote: I want to add the enter key instead of tab keys to the forms. is it possible to intergrate into web2py. Sure, but this has to be handled on the client side via Javascript. Here's one solution: http://thinksimply.com/blog/jquery-enter-tab. Anthony --
[web2py] Re: Nice presentations -- impress.js
I like reveal.js better: Here is the code for markmin - presentation. https://github.com/mdipierro/markmin-reveal-slides Here is a demo: https://dl.dropbox.com/u/18065445/MarkminSlides/test.html This is based on the old markmin2html.py. It should be ported to the newer markmin with includes oembed support. Massimo On Tuesday, 21 August 2012 06:47:21 UTC-5, Michele Comitini wrote: http://bartaz.github.com/impress.js mic --
[web2py] Re: I need help understanding an issue with SQLFORM.factory ( in the context of a form wizard )
thank you Anthony for the explanation .. I tried to do it that way, but it does not work .. what am I doing wrong ??? def testpage(): STEPS = {0: ('Iagreeto','first_name','last_name','email','password', 'sex','birth_date','usertype'), # fields for 1st table and first step 1: ('user_adrss','user_city','user_prov','user_postalcode', 'Country'), # fields for 2nd table and 2nd step 2: ('language_spoken','Other_language','user_picture', 'user_description','user_story'), # fields for the final table and 3rd step 3: URL('done')} step = int(request.args(0) or 0) if not step in STEPS: redirect(URL(args=0)) fields = STEPS[step] if step==0: session.testpage = {} if isinstance(fields,tuple): mytables = ['auth_user','user_location', 'user_profile'] form_fields = [] [form_fields.extend([db[t][f] for f in db[t].fields if f in fields]) for t in mytables] form = SQLFORM.factory(*form_fields) if form.accepts(request,session): session.wizard.update(form.vars) redirect(URL(args=step+1)) else: for k in mytables : db[k].insert(**session.testpage) session.flash = T('wizard completed') redirect(fields) return dict(form=form,step=step) and it does not work what am I doing wrong ... --
[web2py] Re: I need help understanding an issue with SQLFORM.factory ( in the context of a form wizard )
well .. with session.testpage instead of session.wizard in the code pasted above ! --
[web2py] App Cookbook friends.html - class 'sqlite3.OperationalError' no such column: auth_user.first_name
I'm working through the Friends example in the Web2py Application Cookbook, and when I try the friends.html view, I get the following error: class 'sqlite3.OperationalError' no such column: auth_user.first_name My friends.html view is as follows: {{extend 'layout.html'}} h2Friendship Offered/h2 table {{for friend in friends:}} tr td{{=A(name_of(db.auth_user(friend.source)),_href=URL('wall',args=friend.source))}} /td td{{if friend.accepted:}}accepted{{else:}}button onclick=ajax('{{=URL('friendship',args=('accept',friend.source))}}', [],null); $(this).parent().html('accepted')accept/button{{pass}}/ td tdbutton onclick=ajax('{{=URL('friendship',args=('deny',friend.source))}}', [],null); $(this).parent().html('denied')deny/button/td /tr {{pass}} /table h2Friendship Requested/h2 table {{for friend in requests:}} tr td{{=A(name_of(db.auth_user(friend.target)),_href=URL('wall',args=friend.target))}} /td td{{if friend.accepted:}}accepted{{else:}}pending{{pass}}/td tdbutton onclick=ajax('{{=URL('friendship',args=('deny',friend.target))}}', [],null); $(this).parent().html('removed')remove/button/td /tr {{pass}} /table Any help with this error would be greatly appreciated! --
[web2py] Rocket and concurrency issue when benchmarking on win7
I have latest web2py from trunk, Python 2.7(win7) with standalone web2py (using default Rocket server) . I just benchmarked a simple page without a model (just to see how high I can get when striping all unnecessary code ...) and can see some strange thing for me. To test I'm using apache benchmark. When I set concurrency level 5 or up to 10, I'm getting cca 90 req/sec. When increasing concurrency level to 20 (or higher) the req/sec drops to around 15-20 req/sec . Why is this? Is there a way how to get(configure something?) stable performance even under higher load? --
[web2py] Re: App Cookbook friends.html - class 'sqlite3.OperationalError' no such column: auth_user.first_name
please try delete eveything in yourapp/databasaes On Tuesday, 21 August 2012 08:35:52 UTC-5, pjryan126 wrote: I'm working through the Friends example in the Web2py Application Cookbook, and when I try the friends.html view, I get the following error: class 'sqlite3.OperationalError' no such column: auth_user.first_name My friends.html view is as follows: {{extend 'layout.html'}} h2Friendship Offered/h2 table {{for friend in friends:}} tr td{{=A(name_of(db.auth_user(friend.source)),_href=URL('wall',args=friend.source))}} /td td{{if friend.accepted:}}accepted{{else:}}button onclick=ajax('{{=URL('friendship',args=('accept',friend.source))}}', [],null); $(this).parent().html('accepted')accept/button{{pass}}/ td tdbutton onclick=ajax('{{=URL('friendship',args=('deny',friend.source))}}', [],null); $(this).parent().html('denied')deny/button/td /tr {{pass}} /table h2Friendship Requested/h2 table {{for friend in requests:}} tr td{{=A(name_of(db.auth_user(friend.target)),_href=URL('wall',args=friend.target))}} /td td{{if friend.accepted:}}accepted{{else:}}pending{{pass}}/td tdbutton onclick=ajax('{{=URL('friendship',args=('deny',friend.target))}}', [],null); $(this).parent().html('removed')remove/button/td /tr {{pass}} /table Any help with this error would be greatly appreciated! --
Re: [web2py] Re: Standalone application (mac/win)
On windows I 1) download web2py source, 2) install apache (as described in book with wsgi module -don't install certificates if you don't need admin enabled on client machine--) and my web2py app is up and running (you need to create a shortcut of course) I believe should be same thing for mac os. this is one of the best things about web2py, its just ready for deployment on any platform. if you still have trouble setting this up (should take like 30 minutes for first time) just ask here again. On Tue, Aug 21, 2012 at 9:11 AM, mmstud mms...@gmail.com wrote: I added all old gluon directory code to the site-packages directory and made it to work. maanantai, 20. elokuuta 2012 15.08.27 UTC+3 mmstud kirjoitti: Is it possible to create easy to use standalone web2py application for mac and win users? I have registry application and remote database which should be available for clients. I'm searching for a solution where user just clicks the application icon and then browser (maybe internal?) starts up to the correct localhostaddress. Then users signs in to the application and uses it. Regards, -Marko -- --
[web2py] Re: Rocket and concurrency issue when benchmarking on win7
This is probably an effect of the Python GIL. Python has no real parallelization even if you have concurrency. The more concurrent request the more inefficient it gets, even if (and specifically if) you have multiple computing cores. The way you achieve better performance is by using processes, not threads. Other web servers allow you to configure multiple processes, but rocket does not. On Tuesday, 21 August 2012 08:38:29 UTC-5, David Marko wrote: I have latest web2py from trunk, Python 2.7(win7) with standalone web2py (using default Rocket server) . I just benchmarked a simple page without a model (just to see how high I can get when striping all unnecessary code ...) and can see some strange thing for me. To test I'm using apache benchmark. When I set concurrency level 5 or up to 10, I'm getting cca 90 req/sec. When increasing concurrency level to 20 (or higher) the req/sec drops to around 15-20 req/sec . Why is this? Is there a way how to get(configure something?) stable performance even under higher load? --
[web2py] Re: I need help understanding an issue with SQLFORM.factory ( in the context of a form wizard )
Finally ... Anthony, Thank you Bro ! You are a real prince !!! ... I got it to work in a wizard format with 3 steps 3 tables !! ... My god ! this feels liberating ! My only problem now is with the image upload in the form on the last step ... but that is a separate issue ! ... I will try to work it out later ! thanks again ! ;) --
[web2py] menu, mobile phones and tablets
I have played with some menu details and these are my results First try: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_mobile or request.user_agent().is_mobile)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_tablet), ]) ] *Desktop:* I have expected and I got: Home | Dummy1 | Dummy2 | Desktop (#1) *Mobile phone:* I have expected: Home | Dummy1 | Dummy2 | Mobile I got: Home | Dummy1 | Mobile (#2) *Tablet:* I have expected: Home | Dummy1 | Dummy2 | Tablet I got: Home | Dummy1 | Mobile | Tablet (#2, #3) Now a second try: response.menu = [ (T('Home'), False, None, [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_mobile or request.user_agent().is_mobile)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_tablet), ]) ] *Desktop:* I have expected and I got: Home | Dummy1 | Dummy2 | Desktop (#1) *Mobile phone:* I have expected: Home | Dummy1 | Dummy2 | Mobile I got: empty menu (#2, #4) *Tablet:* I have expected: Home | Dummy1 | Dummy2 | Tablet I got: empty menu (#2, #4) Comments: #1: Everything works as expected, but only on a desktop pc #2: Menu items without a link are not displayed on a mobile device #3: Interesting: a tablet is a tablet *and *a mobile phone #4: The empty menu is very confusing. It took some hours to find it out, because my real menu is more complicated. Maybe #2, #3 and #4 are *features *and not *bugs*, but I think, these things should be documented or changed. My proposal: menu items should not become invisible depending on the device. If somebody wants this behavior he could use the fifth component. Maybe is_tablet should be True only for tablets and not for mobile phones too. But in this case there should be not only a mobile.html view but also a tablet.html. And this would make things more complicated. Regards, Martin --
[web2py] Re: default tab key behavior change in fields
All the other small problems other than general integration solved. There i need some help. script src=http://code.jquery.com/jquery-latest.js;/script script type=text/javascript $(document).ready(function(){ //textboxes = $(input.double); //textboxes = $(:input:not(:submit)); textboxes = $(:input:not(:hidden)); $(textboxes).click(function(){ if ($.browser.mozilla) { $(textboxes).keypress (checkForEnter); } else { $(textboxes).keydown (checkForEnter); } }); }); function checkForEnter (event) { if (event.keyCode == 13) { currentBoxNumber = textboxes.index(this); if (textboxes[currentBoxNumber + 1] != null) { nextBox = textboxes[currentBoxNumber + 1] nextBox.focus(); nextBox.select(); if (currentBoxNumber textboxes.length-2){ event.preventDefault(); } } else{ return false; //event.preventDefault(); } } } /script Am Dienstag, 21. August 2012 15:13:21 UTC+2 schrieb max: Hi, This is the script, i have generated but anyhow, it jumps to next key and tries to validate and the it looses focus. Another problem is, my script only work for a certain kind of input fields. is there a way to get all the input fields when i add it into web2py_ajax.html script type=text/javascript $(document).ready(function(){ textboxes = $(input.double); $(.double).click(function(){ if ($.browser.mozilla) { $(textboxes).keypress (checkForEnter); } else { $(textboxes).keydown (checkForEnter); } }); }); function checkForEnter (event) { if (event.keyCode == 13) { currentBoxNumber = textboxes.index(this); if (textboxes[currentBoxNumber + 1] != null) { nextBox = textboxes[currentBoxNumber + 1] nextBox.focus(); nextBox.select(); } else{ event.preventDefault(); return false; } } } /script Am Montag, 20. August 2012 21:51:10 UTC+2 schrieb Anthony: Either directly in layout.html or in a JS file loaded into every page, include the code that checks for enter key presses in input fields (use the $('input') jQuery selector to find all input fields on the page). Anthony On Monday, August 20, 2012 8:56:18 AM UTC-4, max wrote: hi anthony, i can include the change in the views/xyz.html , but how cupld i set it globally for all the forms? Am Montag, 13. August 2012 15:50:25 UTC+2 schrieb max: thank anthony. Am Montag, 13. August 2012 15:30:24 UTC+2 schrieb Anthony: On Monday, August 13, 2012 9:24:13 AM UTC-4, max wrote: I want to add the enter key instead of tab keys to the forms. is it possible to intergrate into web2py. Sure, but this has to be handled on the client side via Javascript. Here's one solution: http://thinksimply.com/blog/jquery-enter-tab. Anthony --
[web2py] AttributeError: 'thread._local' object has no attribute 'request'
I was stupid enough not to be careful now I have a serious problem. I am using the trunk on my laptop where I do my development. This morning I found that certain functions that works on my laptop does not work on the server (which had a slightly older version of the web2py-trunk). I then rsynced the web2py-directory (excluding the applications directory) to the server. Since then I cannot get the app to work on the server despite having put back the original web2py from a backup. The ticket looks like this and I am so far unsuccessful in solving this problem. Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/www-data/web2py/applications/init/models/db.py, line 40, in module auth = Auth(db)# authentication/authorization File /home/www-data/web2py/gluon/tools.py, line 901, in __init__ request = current.request AttributeError: 'thread._local' object has no attribute 'request' and the first part of db.py (I have removed the commented lines if request.env.web2py_runtime_gae:# if running on Google App Engine db = DAL('google:datastore') # connect to Google BigTable # optional DAL('gae://namespace') session.connect(request, response, db = db) # and store sessions and tickets there db = settings.database_uri from gluon import current current.db = db from gluon.tools import Mail, Auth, Crud, Service, PluginManager, prettydate mail = Mail() # mailer auth = Auth(db) What is causing this problem?. It must be something in the app because other apps on the server work. Regards Johann --
[web2py] Re: AttributeError: 'thread._local' object has no attribute 'request'
People have reported theading issues on GAE with threadsafe: true in app.yaml. Make sure you have threadsafe: false until we get to the bottom to this. On Tuesday, 21 August 2012 09:01:30 UTC-5, Johann Spies wrote: I was stupid enough not to be careful now I have a serious problem. I am using the trunk on my laptop where I do my development. This morning I found that certain functions that works on my laptop does not work on the server (which had a slightly older version of the web2py-trunk). I then rsynced the web2py-directory (excluding the applications directory) to the server. Since then I cannot get the app to work on the server despite having put back the original web2py from a backup. The ticket looks like this and I am so far unsuccessful in solving this problem. Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/www-data/web2py/applications/init/models/db.py, line 40, in module auth = Auth(db)# authentication/authorization File /home/www-data/web2py/gluon/tools.py, line 901, in __init__ request = current.request AttributeError: 'thread._local' object has no attribute 'request' and the first part of db.py (I have removed the commented lines if request.env.web2py_runtime_gae:# if running on Google App Engine db = DAL('google:datastore') # connect to Google BigTable # optional DAL('gae://namespace') session.connect(request, response, db = db) # and store sessions and tickets there db = settings.database_uri from gluon import current current.db = db from gluon.tools import Mail, Auth, Crud, Service, PluginManager,prettydate mail = Mail() # mailer auth = Auth(db) What is causing this problem?. It must be something in the app because other apps on the server work. Regards Johann --
Re: [web2py] Re: admin-page and ignore_common_filters
Maybe I can say it in other words: (1) If I am normal user, I should only see my part of the table and I can work with it. This is perfectly assured by db.auth_group._common_filter=**lambda query: (db.auth_group.org==session.** org http://session.org/) (2) If I am the admin and if I use the admin application I want to see all whole tables and of course I want to have the right to edit all tables with common filters, independent of the value of session.org. Or, more simple: an admin (using the admin application) has access to all tables and all fields. ignore_rw does it for the readonly/writonly attribute and the same should be done with ignore_common_filters 2012/8/21 Massimo Di Pierro massimo.dipie...@gmail.com I think you want: from gluon.fileutils import check_credentials if not *check_credentials(request):* * if not session.org: redirect('some_error_page') * db.auth_group._common_filter=**lambda query: (db.auth_group.org== session.**org http://session.org/) On Tuesday, 21 August 2012 01:04:38 UTC-5, mweissen wrote: This is the new code: from gluon.fileutils import check_credentials db.auth_group._common_filter=**lambda query: \ (db.auth_group.org==session.**org http://session.org) *or check_credentials(request)* I have tested check_credentials(request): it returns True - good! But - sorry! - it did not solve the problem: - Let's say I have 100 auth_group rows with org==1 and 100 auth_group rows with org==2 - The admin application tells me 100 selected, but I can *see all 200* rows. - I have tried to change one record. I can open this row, change any field and submit it. - I get the flash *Done* But nothing has happened - the old values are in the table. About the message value not in database: my fault - a wrong db.auth_group.org.requires somewhere in the model. 2012/8/21 Massimo Di Pierro massimo@gmail.com Apologies check_credentials(request) instead of check_credentials('admin') On Monday, 20 August 2012 14:33:55 UTC-5, mweissen wrote: A little bit more code: db.define_table('org', Field('orgnr', Field(shortname', length=20, requires=IS_LENGTH(maxsize=20,minsize=3)), ... ) auth.settings.extra_fields['**au**th_group']=[ Field('org','reference org', default=lambda: session.org, requires=IS_IN_DB(db, 'org.id', '%(shortname)s', error_message=T('Not allowed')), ),... from gluon.fileutils import check_credentials db.auth_group._common_filter=**l**ambda query: (db.auth_group.org==session.**or**g http://session.org) or check_credentials('admin') Now I am using the admin interface and I try to change one row of auth_group. The same result as before (without check_credentials('admin')) - The value of auth_group.org==1. - The error messae is value not in database - And, of course, there is a record in db.org with db.org.id==1 To learn more about check_credentials I added: if check_credentials('admin'): print 'Admin' Only for the test. And I get a new error message: 127.0.0.1.2012-08-20.21-05-04.43dc8360-a22d-408d-8889-**00fe62** ef4a38 type 'exceptions.AttributeError' 'str' object has no attribute 'env' Version web2py™ (2, 0, 0, datetime.datetime(2012, 8, 9, 8, 57, 54), 'dev') Python Python 2.7.2: D:\Python27\python.exe Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. Traceback (most recent call last): File D:\...\web2py\gluon\**restricte**d.py, line 205, in restricted exec ccode in environment File D:/.../web2py/applications/**se**cure/models/db.py http://127.0.0.1:8000/admin/default/edit/secure/models/db.py, line 389, in module if check_credentials('admin'): print 'Admin' File D:\...\web2py\gluon\**fileutils**.py, line 328, in check_credentials if request.env.web2py_runtime_gae: AttributeError: 'str' object has no attribute 'env' 2012/8/20 Massimo Di Pierro massimo@gmail.com You can do: db.define_table(, common_filter = None if not session.org else (lambda query:(db.my_table.org==session.org http://session.org/ ))) you can also use the check: from gluon.fileutils import check_credentials check_credentials('admin') #returns true if you are logged as admin. On Monday, 20 August 2012 12:48:29 UTC-5, mweissen wrote: (1) session.org will be set with the login. But I am an administrator: I think I should use the admin application without a login to the application itself. (2) Lets say session.org==1: now it is not possible to change a record with my_table.org==2 using the admin app. (3) Did you mean: common_filter = lambda query: (db.my_table.org==session.org)** if session.org else True Interesting idea! 2012/8/20 Massimo Di Pierro massimo@gmail.com How do you set the common filter? Seems to me if session.org is not set, the common filter should not be set.
[web2py] Re: Rocket and concurrency issue when benchmarking on win7
I see, so is it the way to limit the max number of threads to e.g. 10, so the system is not killed by the concurrency and as a result I will get 90 req/sec back? Dne úterý, 21. srpna 2012 15:45:58 UTC+2 Massimo Di Pierro napsal(a): This is probably an effect of the Python GIL. Python has no real parallelization even if you have concurrency. The more concurrent request the more inefficient it gets, even if (and specifically if) you have multiple computing cores. The way you achieve better performance is by using processes, not threads. Other web servers allow you to configure multiple processes, but rocket does not. On Tuesday, 21 August 2012 08:38:29 UTC-5, David Marko wrote: I have latest web2py from trunk, Python 2.7(win7) with standalone web2py (using default Rocket server) . I just benchmarked a simple page without a model (just to see how high I can get when striping all unnecessary code ...) and can see some strange thing for me. To test I'm using apache benchmark. When I set concurrency level 5 or up to 10, I'm getting cca 90 req/sec. When increasing concurrency level to 20 (or higher) the req/sec drops to around 15-20 req/sec . Why is this? Is there a way how to get(configure something?) stable performance even under higher load? --
[web2py] Re: Can a table field reference a list?
Thanks Massimo once again! On Tuesday, August 21, 2012 9:03:45 PM UTC+8, Massimo Di Pierro wrote: Do you mean something like this? activities = {1:'diving',2:'swimming',3:'skiing'} Field('activity_id','integer',requires=IS_IN_SET(activities),represent=lambda i: activities[i]) On Tuesday, 21 August 2012 04:24:09 UTC-5, lyn2py wrote: Hi guys, db.define_table('activities', Field('name', 'string',length=255,requires=IS_NOT_EMPTY()), Field('description','text'), format='%(name)s' ) db.define_table('activity', Field('user_id','reference auth_user',default=auth.user_id), Field('activity_id','reference activities'), ) Instead of the above code, can I have the second table reference a list / tuple instead of a table? How should I do it? --
Re: [web2py] Re: admin-page and ignore_common_filters
Now I understand better. Please open an issue for enhancement and link this thread. For now you'll have to handle with the suggested logic or perhaps: if *request.controller!='appadmin':* * if not session.org: redirect('some_error_page') * db.auth_group._common_filter=lambda query: (db.auth_group.org== session.org) On Tuesday, 21 August 2012 09:12:15 UTC-5, mweissen wrote: Maybe I can say it in other words: (1) If I am normal user, I should only see my part of the table and I can work with it. This is perfectly assured by db.auth_group._common_filter=**lambda query: (db.auth_group.org==session.* *org http://session.org/) (2) If I am the admin and if I use the admin application I want to see all whole tables and of course I want to have the right to edit all tables with common filters, independent of the value of session.org. Or, more simple: an admin (using the admin application) has access to all tables and all fields. ignore_rw does it for the readonly/writonly attribute and the same should be done with ignore_common_filters 2012/8/21 Massimo Di Pierro massimo@gmail.com javascript: I think you want: from gluon.fileutils import check_credentials if not *check_credentials(request):* * if not session.org: redirect('some_error_page') * db.auth_group._common_filter=**lambda query: (db.auth_group.org== session.**org http://session.org/) On Tuesday, 21 August 2012 01:04:38 UTC-5, mweissen wrote: This is the new code: from gluon.fileutils import check_credentials db.auth_group._common_filter=**lambda query: \ (db.auth_group.org==session.**org http://session.org) *or check_credentials(request)* I have tested check_credentials(request): it returns True - good! But - sorry! - it did not solve the problem: - Let's say I have 100 auth_group rows with org==1 and 100 auth_group rows with org==2 - The admin application tells me 100 selected, but I can *see all 200* rows. - I have tried to change one record. I can open this row, change any field and submit it. - I get the flash *Done* But nothing has happened - the old values are in the table. About the message value not in database: my fault - a wrong db.auth_group.org.requires somewhere in the model. 2012/8/21 Massimo Di Pierro massimo@gmail.com Apologies check_credentials(request) instead of check_credentials('admin') On Monday, 20 August 2012 14:33:55 UTC-5, mweissen wrote: A little bit more code: db.define_table('org', Field('orgnr', Field(shortname', length=20, requires=IS_LENGTH(maxsize=20,minsize=3)), ... ) auth.settings.extra_fields['**au**th_group']=[ Field('org','reference org', default=lambda: session.org, requires=IS_IN_DB(db, 'org.id', '%(shortname)s', error_message=T('Not allowed')), ),... from gluon.fileutils import check_credentials db.auth_group._common_filter=**l**ambda query: (db.auth_group.org==session.**or**g http://session.org) or check_credentials('admin') Now I am using the admin interface and I try to change one row of auth_group. The same result as before (without check_credentials('admin')) - The value of auth_group.org==1. - The error messae is value not in database - And, of course, there is a record in db.org with db.org.id==1 To learn more about check_credentials I added: if check_credentials('admin'): print 'Admin' Only for the test. And I get a new error message: 127.0.0.1.2012-08-20.21-05-04.43dc8360-a22d-408d-8889-**00fe62** ef4a38 type 'exceptions.AttributeError' 'str' object has no attribute 'env' Version web2py™ (2, 0, 0, datetime.datetime(2012, 8, 9, 8, 57, 54), 'dev') Python Python 2.7.2: D:\Python27\python.exe Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. Traceback (most recent call last): File D:\...\web2py\gluon\**restricte**d.py, line 205, in restricted exec ccode in environment File D:/.../web2py/applications/**se**cure/models/db.py http://127.0.0.1:8000/admin/default/edit/secure/models/db.py, line 389, in module if check_credentials('admin'): print 'Admin' File D:\...\web2py\gluon\**fileutils**.py, line 328, in check_credentials if request.env.web2py_runtime_gae: AttributeError: 'str' object has no attribute 'env' 2012/8/20 Massimo Di Pierro massimo@gmail.com You can do: db.define_table(, common_filter = None if not session.org else (lambda query:(db.my_table.org==session.org http://session.org/ ))) you can also use the check: from gluon.fileutils import check_credentials check_credentials('admin') #returns true if you are logged as admin. On Monday, 20 August 2012 12:48:29 UTC-5, mweissen wrote: (1) session.org will be set with the login. But I am an administrator: I think I should use the admin application without a login to
[web2py] json - Not Serializable error
When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: Major speed improvement need testers
This was the error: File C:/web2py/applications/crm/models/db.py http://localhost:8080/admin/default/edit/crm/models/db.py, line 85, in module session.setdefault(history, []) TypeError: 'NoneType' object is not callable However now I get a different error in latest trunk: File C:/web2py/applications/crm/models/dbtables.py http://localhost:8080/admin/default/edit/crm/models/dbtables.py, line 65, in module format=lambda r: A(r.name, _href=URL(c='customer', f='singleview.html', args=(r.id File C:\web2py\gluon\dal.py, line 6934, in define_table table = self.lazy_define_table(tablename,*fields,**args) File C:\web2py\gluon\dal.py, line 6945, in lazy_define_table fields = fields + self._common_fields TypeError: can only concatenate tuple (not list) to tuple On Tuesday, 21 August 2012 14:04:26 UTC+1, Massimo Di Pierro wrote: What does not work? The new store has for now been reverted. On Tuesday, 21 August 2012 05:07:32 UTC-5, simon wrote: This line does not seem to work in latest trunk. Is that because of the new Storage object? session.setdefault(history, []) On Saturday, 18 August 2012 04:00:44 UTC+1, Massimo Di Pierro wrote: There are two major speed improvements in trunk and I am not sure whether they should go in web2py 2.0 next week. 1) Lazy table (based on ideas from Bruno). db = DAL(, lazy_tables=True) db.define_table('person',Field('name')) the table is instantiated only when db.person is accessed. So with some care: Field(, requires=) # LAZY (good) db.table.field.requires = ... # NOT LAZY (bad) Field('other','reference table') # LAZY (good) Field('other',db.table) # NOT LAZY (bad) this may be a big speedup. 2) There is a new implementation of class Storage. This is a most accessed object within web2py and now it is 10x faster. Yet I am not sure if this breaks something. It would be great if you could try the nightly build (or trunk) and report if you experienced any problem. It would be even better if you could run some benchmarks of your code before and after the changes suggested at 1). Massimo --
[web2py] Re: menu, mobile phones and tablets
+1 https://groups.google.com/d/msg/web2py-developers/FMCF0HTs64A/CJ-PNCaIsuwJ 2012. augusztus 21., kedd 15:58:27 UTC+2 időpontban mweissen a következőt írta: I have played with some menu details and these are my results First try: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_mobile or request.user_agent().is_mobile)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_tablet), ]) ] *Desktop:* I have expected and I got: Home | Dummy1 | Dummy2 | Desktop (#1) *Mobile phone:* I have expected: Home | Dummy1 | Dummy2 | Mobile I got: Home | Dummy1 | Mobile (#2) *Tablet:* I have expected: Home | Dummy1 | Dummy2 | Tablet I got: Home | Dummy1 | Mobile | Tablet (#2, #3) Now a second try: response.menu = [ (T('Home'), False, None, [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_mobile or request.user_agent().is_mobile)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_tablet), ]) ] *Desktop:* I have expected and I got: Home | Dummy1 | Dummy2 | Desktop (#1) *Mobile phone:* I have expected: Home | Dummy1 | Dummy2 | Mobile I got: empty menu (#2, #4) *Tablet:* I have expected: Home | Dummy1 | Dummy2 | Tablet I got: empty menu (#2, #4) Comments: #1: Everything works as expected, but only on a desktop pc #2: Menu items without a link are not displayed on a mobile device #3: Interesting: a tablet is a tablet *and *a mobile phone #4: The empty menu is very confusing. It took some hours to find it out, because my real menu is more complicated. Maybe #2, #3 and #4 are *features *and not *bugs*, but I think, these things should be documented or changed. My proposal: menu items should not become invisible depending on the device. If somebody wants this behavior he could use the fifth component. Maybe is_tablet should be True only for tablets and not for mobile phones too. But in this case there should be not only a mobile.html view but also a tablet.html. And this would make things more complicated. Regards, Martin --
[web2py] Re: json - Not Serializable error
I must add that the below code are working when as a normal function that means def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy is OK But @service.json def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy is NOT OK On Tuesday, August 21, 2012 10:37:56 PM UTC+8, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: Rocket and concurrency issue when benchmarking on win7
I think so but this may be server dependent and machine dependent. Async servers probably do not have this problem. On Tuesday, 21 August 2012 09:17:10 UTC-5, David Marko wrote: I see, so is it the way to limit the max number of threads to e.g. 10, so the system is not killed by the concurrency and as a result I will get 90 req/sec back? Dne úterý, 21. srpna 2012 15:45:58 UTC+2 Massimo Di Pierro napsal(a): This is probably an effect of the Python GIL. Python has no real parallelization even if you have concurrency. The more concurrent request the more inefficient it gets, even if (and specifically if) you have multiple computing cores. The way you achieve better performance is by using processes, not threads. Other web servers allow you to configure multiple processes, but rocket does not. On Tuesday, 21 August 2012 08:38:29 UTC-5, David Marko wrote: I have latest web2py from trunk, Python 2.7(win7) with standalone web2py (using default Rocket server) . I just benchmarked a simple page without a model (just to see how high I can get when striping all unnecessary code ...) and can see some strange thing for me. To test I'm using apache benchmark. When I set concurrency level 5 or up to 10, I'm getting cca 90 req/sec. When increasing concurrency level to 20 (or higher) the req/sec drops to around 15-20 req/sec . Why is this? Is there a way how to get(configure something?) stable performance even under higher load? --
[web2py] Re: Major speed improvement need testers
Thanks for testing this. Can you check this is fixed in trunk? On Tuesday, 21 August 2012 09:44:51 UTC-5, simon wrote: This was the error: File C:/web2py/applications/crm/models/db.py http://localhost:8080/admin/default/edit/crm/models/db.py, line 85, in module session.setdefault(history, []) TypeError: 'NoneType' object is not callable However now I get a different error in latest trunk: File C:/web2py/applications/crm/models/dbtables.py http://localhost:8080/admin/default/edit/crm/models/dbtables.py, line 65, in module format=lambda r: A(r.name, _href=URL(c='customer', f='singleview.html', args=(r.id File C:\web2py\gluon\dal.py, line 6934, in define_table table = self.lazy_define_table(tablename,*fields,**args) File C:\web2py\gluon\dal.py, line 6945, in lazy_define_table fields = fields + self._common_fields TypeError: can only concatenate tuple (not list) to tuple On Tuesday, 21 August 2012 14:04:26 UTC+1, Massimo Di Pierro wrote: What does not work? The new store has for now been reverted. On Tuesday, 21 August 2012 05:07:32 UTC-5, simon wrote: This line does not seem to work in latest trunk. Is that because of the new Storage object? session.setdefault(history, []) On Saturday, 18 August 2012 04:00:44 UTC+1, Massimo Di Pierro wrote: There are two major speed improvements in trunk and I am not sure whether they should go in web2py 2.0 next week. 1) Lazy table (based on ideas from Bruno). db = DAL(, lazy_tables=True) db.define_table('person',Field('name')) the table is instantiated only when db.person is accessed. So with some care: Field(, requires=) # LAZY (good) db.table.field.requires = ... # NOT LAZY (bad) Field('other','reference table') # LAZY (good) Field('other',db.table) # NOT LAZY (bad) this may be a big speedup. 2) There is a new implementation of class Storage. This is a most accessed object within web2py and now it is 10x faster. Yet I am not sure if this breaks something. It would be great if you could try the nightly build (or trunk) and report if you experienced any problem. It would be even better if you could run some benchmarks of your code before and after the changes suggested at 1). Massimo --
[web2py] Re: menu, mobile phones and tablets
Can you elaborate? Is there a problem that need to be solved? On Tuesday, 21 August 2012 09:46:35 UTC-5, szimszon wrote: +1 https://groups.google.com/d/msg/web2py-developers/FMCF0HTs64A/CJ-PNCaIsuwJ 2012. augusztus 21., kedd 15:58:27 UTC+2 időpontban mweissen a következőt írta: I have played with some menu details and these are my results First try: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_mobile or request.user_agent().is_mobile)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_tablet), ]) ] *Desktop:* I have expected and I got: Home | Dummy1 | Dummy2 | Desktop (#1) *Mobile phone:* I have expected: Home | Dummy1 | Dummy2 | Mobile I got: Home | Dummy1 | Mobile (#2) *Tablet:* I have expected: Home | Dummy1 | Dummy2 | Tablet I got: Home | Dummy1 | Mobile | Tablet (#2, #3) Now a second try: response.menu = [ (T('Home'), False, None, [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_mobile or request.user_agent().is_mobile)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_tablet), ]) ] *Desktop:* I have expected and I got: Home | Dummy1 | Dummy2 | Desktop (#1) *Mobile phone:* I have expected: Home | Dummy1 | Dummy2 | Mobile I got: empty menu (#2, #4) *Tablet:* I have expected: Home | Dummy1 | Dummy2 | Tablet I got: empty menu (#2, #4) Comments: #1: Everything works as expected, but only on a desktop pc #2: Menu items without a link are not displayed on a mobile device #3: Interesting: a tablet is a tablet *and *a mobile phone #4: The empty menu is very confusing. It took some hours to find it out, because my real menu is more complicated. Maybe #2, #3 and #4 are *features *and not *bugs*, but I think, these things should be documented or changed. My proposal: menu items should not become invisible depending on the device. If somebody wants this behavior he could use the fifth component. Maybe is_tablet should be True only for tablets and not for mobile phones too. But in this case there should be not only a mobile.html view but also a tablet.html. And this would make things more complicated. Regards, Martin --
[web2py] Re: json - Not Serializable error
Make sure you have the latest trunk. On Tuesday, 21 August 2012 09:37:56 UTC-5, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: json - Not Serializable error
I have just grabbed a copy of trunk about 12 hours ago. I have just grabbed it again 5 mins ago. Now it won't even let me access the page? I'm quite confused. It doesn't even generate a ticket... On Safari it says the operation cannot be completed. On Tuesday, August 21, 2012 10:54:46 PM UTC+8, Massimo Di Pierro wrote: Make sure you have the latest trunk. On Tuesday, 21 August 2012 09:37:56 UTC-5, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: need a simple wiki...
Two issues for debugging: -In a new scaffolding app with auth.wiki() appadmin does not show wiki tables, but they are defined (db.tables() return their names). -There's an auth_membership for wiki_editor with user_id set to None, I suppose it was created when loading the wiki feature without a logged in user --
[web2py] Re: json - Not Serializable error
To clarify my abve post, I am using this code, and it fails without a ticket: def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy And I get a not serializable when I use this code @service.json def myfunc(): rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy On Tuesday, August 21, 2012 10:54:46 PM UTC+8, Massimo Di Pierro wrote: Make sure you have the latest trunk. On Tuesday, 21 August 2012 09:37:56 UTC-5, lyn2py wrote: When I perform: rows = db(db.table.id0).select() return rows It is OK But when I perform: rows = db(db.table.id0).select() dummy = [] for r in rows: if some_condition: r.item=False dummy.append(r) else: dummy.append(r) return dummy I get the not serializable error. What am I doing wrong? --
[web2py] Re: How to apply language translation on requires field when showing other table field values.
Try: IS_IN_DB(db, db.t_title.id, lambda r: T(r.name), orderby=db.t_title.id) The label argument to IS_IN_DB can be a function that takes a Row object and returns a label for that row. Anthony On Tuesday, August 21, 2012 9:12:22 AM UTC-4, Pradeeshnarayan wrote: In my application I have to specify a title field as below Field('title', type='string',label=T('Title'),requires=IS_IN_DB(db, db.t_title.id, '%(name)s',orderby=db.t_title.id)) all the title options are mentioned in the t_title table. For example in t_title table I have values Mr. and Mrs. For english language this is fine. But for german language I have to display Herr and Frau. How can I set language translation 'T()' to title values. So I can add the corresponding title names in other language files. I would greatly appreciate any suggestions. --
[web2py] How to extend IMG to preprocess url
Hi guys, Any advice on howto extend IMG to preprocess url? I simply want to mangle url before it passed to IMG and this should be done every time an IMG tag is used. Thanks! -- Profile: http://it.linkedin.com/in/compagnucciangelo --
[web2py] Re: Major speed improvement need testers
yes it works now. On Tuesday, 21 August 2012 15:52:29 UTC+1, Massimo Di Pierro wrote: Thanks for testing this. Can you check this is fixed in trunk? On Tuesday, 21 August 2012 09:44:51 UTC-5, simon wrote: This was the error: File C:/web2py/applications/crm/models/db.py http://localhost:8080/admin/default/edit/crm/models/db.py, line 85, in module session.setdefault(history, []) TypeError: 'NoneType' object is not callable However now I get a different error in latest trunk: File C:/web2py/applications/crm/models/dbtables.py http://localhost:8080/admin/default/edit/crm/models/dbtables.py, line 65, in module format=lambda r: A(r.name, _href=URL(c='customer', f='singleview.html', args=(r.id File C:\web2py\gluon\dal.py, line 6934, in define_table table = self.lazy_define_table(tablename,*fields,**args) File C:\web2py\gluon\dal.py, line 6945, in lazy_define_table fields = fields + self._common_fields TypeError: can only concatenate tuple (not list) to tuple On Tuesday, 21 August 2012 14:04:26 UTC+1, Massimo Di Pierro wrote: What does not work? The new store has for now been reverted. On Tuesday, 21 August 2012 05:07:32 UTC-5, simon wrote: This line does not seem to work in latest trunk. Is that because of the new Storage object? session.setdefault(history, []) On Saturday, 18 August 2012 04:00:44 UTC+1, Massimo Di Pierro wrote: There are two major speed improvements in trunk and I am not sure whether they should go in web2py 2.0 next week. 1) Lazy table (based on ideas from Bruno). db = DAL(, lazy_tables=True) db.define_table('person',Field('name')) the table is instantiated only when db.person is accessed. So with some care: Field(, requires=) # LAZY (good) db.table.field.requires = ... # NOT LAZY (bad) Field('other','reference table') # LAZY (good) Field('other',db.table) # NOT LAZY (bad) this may be a big speedup. 2) There is a new implementation of class Storage. This is a most accessed object within web2py and now it is 10x faster. Yet I am not sure if this breaks something. It would be great if you could try the nightly build (or trunk) and report if you experienced any problem. It would be even better if you could run some benchmarks of your code before and after the changes suggested at 1). Massimo --
[web2py] Re: Standalone application (mac/win)
Do you want to use web2py features from a desktop application? For importing web2py features from other software there is https://github.com/mdipierro/gluino For wxPython and web2py integration check gui2pyhttp://code.google.com/p/gui2py/ If you just want your web2py to be available in a given network, you can start web2py with it's built-in server and use links to the machine on each host so they can access the web interface with a standard browser. --
[web2py] Re: How to extend IMG to preprocess url
Maybe something like: class MYIMG(IMG): def __init__(self, *components, **attributes): if '_src' in attributes: attributes['_src'] = mangle(attributes['_src']) return super(MYIMG, self).__init__(*components, **attributes) Then you can do: MYIMG(_src=URL('static', 'someimage.jpg')) and the _src URL will be altered automatically. Anthony On Tuesday, August 21, 2012 11:36:18 AM UTC-4, AngeloC wrote: Hi guys, Any advice on howto extend IMG to preprocess url? I simply want to mangle url before it passed to IMG and this should be done every time an IMG tag is used. Thanks! -- Profile: http://it.linkedin.com/in/compagnucciangelo --
Re: [web2py] Re: menu, mobile phones and tablets
Proposal: In gluon/html.py, line 2200 I have changed from def serialize_mobile(self, data, select=None, prefix=''): if not select: select = SELECT(**self.attributes) for item in data: if len(item) = 4 or item[4] == True: * if item[2]: # remove this line* select.append(OPTION(CAT(prefix, item[0]), _value=item[2], _selected=item[1])) if len(item)3 and len(item[3]): self.serialize_mobile(item[3], select, prefix = CAT(prefix, item[0], '/')) select['_onchange'] = 'window.location=this.value' return select to: def serialize_mobile(self, data, select=None, prefix=''): if not select: select = SELECT(**self.attributes) for item in data: if len(item) = 4 or item[4] == True: select.append(OPTION(CAT(prefix, item[0]), _value=item[2], _selected=item[1])) if len(item)3 and len(item[3]): self.serialize_mobile(item[3], select, prefix = CAT(prefix, item[0], '/')) select['_onchange'] = 'window.location=this.value' return select Now there is no difference between the desktop and the mobile version of the menu. A menu item without a link and with subitems will be displayed on all devices. --- Addendum 1: If somebody wants the original behavior, he has to change (e.g.) from response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [], ), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().is_ **tablet)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] to response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [], *not request.user_agent().is_mobile* ), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().is_ **tablet)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] Addendum 2: There is an error in my examples, this is the corrected code: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().* is_tablet*)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] and: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().* is_tablet*)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] 2012/8/21 Massimo Di Pierro massimo.dipie...@gmail.com Can you elaborate? Is there a problem that need to be solved? On Tuesday, 21 August 2012 09:46:35 UTC-5, szimszon wrote: +1 https://groups.google.com/d/**msg/web2py-developers/** FMCF0HTs64A/CJ-PNCaIsuwJhttps://groups.google.com/d/msg/web2py-developers/FMCF0HTs64A/CJ-PNCaIsuwJ 2012. augusztus 21., kedd 15:58:27 UTC+2 időpontban mweissen a következőt írta: I have played with some menu details and these are my results First try: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().is_**mobile)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] *Desktop:* I have expected and I got: Home | Dummy1 | Dummy2 | Desktop (#1) *Mobile phone:* I have expected: Home | Dummy1 | Dummy2 | Mobile I got: Home | Dummy1 | Mobile (#2) *Tablet:* I have expected:
Re: [web2py] Re: admin-page and ignore_common_filters
Done - thank you! 2012/8/21 Massimo Di Pierro massimo.dipie...@gmail.com Now I understand better. Please open an issue for enhancement and link this thread. For now you'll have to handle with the suggested logic or perhaps: if *request.controller!='appadmin':* * if not session.org: redirect('some_error_page') * db.auth_group._common_filter=**lambda query: (db.auth_group.org== session.**org http://session.org/) On Tuesday, 21 August 2012 09:12:15 UTC-5, mweissen wrote: Maybe I can say it in other words: (1) If I am normal user, I should only see my part of the table and I can work with it. This is perfectly assured by db.auth_group._common_filter=**l**ambda query: (db.auth_group.org== session.**or**g http://session.org/) (2) If I am the admin and if I use the admin application I want to see all whole tables and of course I want to have the right to edit all tables with common filters, independent of the value of session.org. Or, more simple: an admin (using the admin application) has access to all tables and all fields. ignore_rw does it for the readonly/writonly attribute and the same should be done with ignore_common_filters 2012/8/21 Massimo Di Pierro massimo@gmail.com I think you want: from gluon.fileutils import check_credentials if not *check_credentials(request):* * if not session.org: redirect('some_error_page') * db.auth_group._common_filter=lambda query: (db.auth_group.org== session.**or**g http://session.org/) On Tuesday, 21 August 2012 01:04:38 UTC-5, mweissen wrote: This is the new code: from gluon.fileutils import check_credentials db.auth_group._common_filter=**l**ambda query: \ (db.auth_group.org==session.**or**g http://session.org) *or check_credentials(request)* I have tested check_credentials(request): it returns True - good! But - sorry! - it did not solve the problem: - Let's say I have 100 auth_group rows with org==1 and 100 auth_group rows with org==2 - The admin application tells me 100 selected, but I can *see all 200* rows. - I have tried to change one record. I can open this row, change any field and submit it. - I get the flash *Done* But nothing has happened - the old values are in the table. About the message value not in database: my fault - a wrong db.auth_group.org.requires somewhere in the model. 2012/8/21 Massimo Di Pierro massimo@gmail.com Apologies check_credentials(request) instead of check_credentials('admin') On Monday, 20 August 2012 14:33:55 UTC-5, mweissen wrote: A little bit more code: db.define_table('org', Field('orgnr', Field(shortname', length=20, requires=IS_LENGTH(maxsize=20,**minsize=3)), ... ) auth.settings.extra_fields['**auth_group']=[ Field('org','reference org', default=lambda: session.org, requires=IS_IN_DB(db, 'org.id', '%(shortname)s', error_message=T('Not allowed')), ),... from gluon.fileutils import check_credentials db.auth_group._common_filter=**lambda query: (db.auth_group.org==session.**org http://session.org) or check_credentials('admin') Now I am using the admin interface and I try to change one row of auth_group. The same result as before (without check_credentials('admin')) - The value of auth_group.org==1. - The error messae is value not in database - And, of course, there is a record in db.org with db.org.id==1 To learn more about check_credentials I added: if check_credentials('admin'): print 'Admin' Only for the test. And I get a new error message: 127.0.0.1.2012-08-20.21-05-04.**43dc8360-a22d-408d-8889-**00fe62* ***ef4a38 type 'exceptions.AttributeError' 'str' object has no attribute 'env' Version web2py™ (2, 0, 0, datetime.datetime(2012, 8, 9, 8, 57, 54), 'dev') Python Python 2.7.2: D:\Python27\python.exe Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. Traceback (most recent call last): File D:\...\web2py\gluon\**restricted.py, line 205, in restricted exec ccode in environment File D:/.../web2py/applications/**secure/models/db.py http://127.0.0.1:8000/admin/default/edit/secure/models/db.py, line 389, in module if check_credentials('admin'): print 'Admin' File D:\...\web2py\gluon\**fileutils.py, line 328, in check_credentials if request.env.web2py_runtime_gae**: AttributeError: 'str' object has no attribute 'env' 2012/8/20 Massimo Di Pierro massimo@gmail.com You can do: db.define_table(, common_filter = None if not session.org else (lambda query:(db.my_table.org==sessio**n.orghttp://session.org/ ))) you can also use the check: from gluon.fileutils import check_credentials check_credentials('admin') #returns true if you are logged as admin. On Monday, 20 August 2012 12:48:29 UTC-5, mweissen wrote: (1) session.org will be set with the
Re: [web2py] Re: Nice presentations -- impress.js
T +adesst -Original Message- From: Massimo Di Pierro massimo.dipie...@gmail.com Sender: web2py@googlegroups.com Date: Tue, 21 Aug 2012 06:15:57 To: web2py@googlegroups.com Reply-To: web2py@googlegroups.com Subject: [web2py] Re: Nice presentations -- impress.js I like reveal.js better: Here is the code for markmin - presentation. https://github.com/mdipierro/markmin-reveal-slides Here is a demo: https://dl.dropbox.com/u/18065445/MarkminSlides/test.html This is based on the old markmin2html.py. It should be ported to the newer markmin with includes oembed support. Massimo On Tuesday, 21 August 2012 06:47:21 UTC-5, Michele Comitini wrote: http://bartaz.github.com/impress.js mic -- --
[web2py] Re: Web2Py compute fields not working on update
Thank you so much i got it working. I removed the readable=false and writable=false and it works on update now. Those are not needed anyway because when the compute field is added on the model it hides it automatically. Brandon On Thursday, August 9, 2012 2:14:42 PM UTC-6, Deidre wrote: If you look at issue 822 you will see an example of a thumb that works on update. As the comments say, you have to not set writeable to false for the thumb. If you do set writeable to false then compute only works on add not edit or update. So my experience is that compute for images to create a thumb does work on update. Peter On Thursday, August 9, 2012 5:04:28 PM UTC+1, Brandon Reynolds wrote: Has anyone found a way to fix this yet? Or is there a thumbnail module out now? Like django's http://djangothumbnails.com/ Brandon On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote: I have this problem when i try to generate thumbnails. If the field is empty it inserts the photo thumb into the thumbnail. But when i try to update that record the thumbnail doesn't change. Here is my model: # coding: utf8 from image import THUMBER db.define_table('park', Field('park_name', requires=IS_NOT_EMPTY()), Field('park_city', requires=IS_NOT_EMPTY()), Field('park_state', requires=IS_NOT_EMPTY()), Field('park_address', requires=IS_NOT_EMPTY()), Field('park_zip', requires=IS_NOT_EMPTY()), Field('country', default=USA, notnull=True, readable=False, writable=False), Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')), Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))), Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))), Field('photo1', 'upload'), Field('photo_thumb1', 'upload', readable=False, writable=False), Field('photo2', 'upload'), Field('photo_thumb2', 'upload', readable=False, writable=False), Field('photo3', 'upload'), Field('photo_thumb3', 'upload', readable=False, writable=False), Field('photo4', 'upload'), Field('photo_thumb4', 'upload', readable=False, writable=False), Field('photo5', 'upload'), Field('photo_thumb5', 'upload', readable=False, writable=False), Field('manager', requires=IS_NOT_EMPTY()), Field('manager_email', requires=IS_EMAIL()), Field('spaces', 'integer', requires=IS_NOT_EMPTY()), Field('vacant', 'integer'), Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()), Field('water', 'boolean'), Field('sewer', 'boolean'), Field('trash', 'boolean'), Field('pool', 'boolean'), Field('playground', 'boolean'), Field('clubhouse', 'boolean'), Field('laundromat', 'boolean'), Field('rv_spaces', 'boolean'), Field('storage', 'boolean'), Field('handicap_accessible', 'boolean'), Field('community_description', 'text'), format='%(park_name)s') db.define_table('home', Field('pid', notnull=True, readable=False, writable=False), Field('lot'), Field('year', length=4, requires=IS_NOT_EMPTY()), Field('make'), Field('model'), Field('width', requires=IS_NOT_EMPTY()), Field('length', requires=IS_NOT_EMPTY()), Field('wide', requires=IS_NOT_EMPTY()), Field('for_sale', 'boolean', default=True), Field('beds', requires=IS_NOT_EMPTY()), Field('baths', requires=IS_NOT_EMPTY()), Field('fridge', 'boolean'), Field('stove', 'boolean'), Field('dishwasher', 'boolean'), Field('microwave', 'boolean'), Field('washer', 'boolean'), Field('dryer', 'boolean'), Field('photo1', 'upload'), Field('photo1_text'), Field('photo_thumb1', 'upload', readable=False, writable=False), Field('photo2', 'upload'), Field('photo2_text'), Field('photo_thumb2', 'upload', readable=False, writable=False), Field('photo3', 'upload'), Field('photo3_text'), Field('photo_thumb3', 'upload', readable=False, writable=False), Field('photo4', 'upload'), Field('photo4_text'), Field('photo_thumb4', 'upload', readable=False, writable=False), Field('photo5', 'upload'), Field('photo5_text'), Field('photo_thumb5', 'upload', readable=False, writable=False), Field('price',requires=IS_NOT_EMPTY()), Field('description', 'text', requires=IS_NOT_EMPTY()), Field('posted_on', 'datetime', readable=False, writable=False)) db.define_table('state', Field('name'), Field('full_name')) db.define_table('wide', Field('type'), format='%(type)s') db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s (%(name)s)', zero=T('Select State')) db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', zero=T('Select Home Type')) db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, photo_thumb1, 144, 115) db.park.photo_thumb2.compute = lambda row: THUMBER(row.photo2, photo_thumb2, 144, 115) db.park.photo_thumb3.compute = lambda row: THUMBER(row.photo3, photo_thumb3, 144, 115) db.park.photo_thumb4.compute = lambda row: THUMBER(row.photo4, photo_thumb4, 144, 115) db.park.photo_thumb5.compute = lambda row: THUMBER(row.photo5, photo_thumb5, 144, 115) db.home.photo_thumb1.compute = lambda
Re: [web2py] Re: How to extend IMG to preprocess url
Wow! I'll try ASAP, thank you! 2012/8/21 Anthony abasta...@gmail.com Maybe something like: class MYIMG(IMG): def __init__(self, *components, **attributes): if '_src' in attributes: attributes['_src'] = mangle(attributes['_src']) return super(MYIMG, self).__init__(*components, **attributes) Then you can do: MYIMG(_src=URL('static', 'someimage.jpg')) and the _src URL will be altered automatically. Anthony On Tuesday, August 21, 2012 11:36:18 AM UTC-4, AngeloC wrote: Hi guys, Any advice on howto extend IMG to preprocess url? I simply want to mangle url before it passed to IMG and this should be done every time an IMG tag is used. Thanks! -- Profile: http://it.linkedin.com/in/**compagnucciangelohttp://it.linkedin.com/in/compagnucciangelo -- -- Profile: http://it.linkedin.com/in/compagnucciangelo --
[web2py] Re: Router for multiple controllers
routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller1/bye')) On Tuesday, August 21, 2012 1:28:49 AM UTC-7, Daniel Gonzalez wrote: Hello, I have the following routing requirements, which I am unable to configure in routes.py: www.mysite.com/hello - application1, controller1, hello www.mysite.com/bye - application1, controller2, bye As you can see, the functions hello and bye are in different controllers. Is it possible to achieve this with routes.py? Thanks, Daniel --
[web2py] SEO Friendly URLs and Page Titles
1. What is the easiest way to make it so each page has it's own title? Currently it is set by layout.html, but what if I want its own page to have an independent title? 2. How can I make it so the title of the page is the name of a field in a model? I am using SQLForm now, and have /product/1 and would like to have /product/purple-desk 3. How can I make it so the meta description on each page has its own ? For example, the description is the data in the field 'product description' used in the model. Thanks. --
Re: [web2py] Re: Standalone application (mac/win)
with apache installed you don't have to worry about starting services or restarting them, its all handled for you for free ! also apache is a very solid and well tested platform. On Tue, Aug 21, 2012 at 4:44 PM, Alan Etkin spame...@gmail.com wrote: Do you want to use web2py features from a desktop application? For importing web2py features from other software there is https://github.com/mdipierro/gluino For wxPython and web2py integration check gui2pyhttp://code.google.com/p/gui2py/ If you just want your web2py to be available in a given network, you can start web2py with it's built-in server and use links to the machine on each host so they can access the web interface with a standard browser. -- --
[web2py] Re: SEO Friendly URLs and Page Titles
You can set response.title and response.meta in the controller or function to make it specific to particular controllers or functions (or you can set them conditionally in a model file). If you need to use a database value, just do a query to get the value (your probably want to cache it to improve performance). Anthony On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote: 1. What is the easiest way to make it so each page has it's own title? Currently it is set by layout.html, but what if I want its own page to have an independent title? 2. How can I make it so the title of the page is the name of a field in a model? I am using SQLForm now, and have /product/1 and would like to have /product/purple-desk 3. How can I make it so the meta description on each page has its own ? For example, the description is the data in the field 'product description' used in the model. Thanks. --
[web2py] Clearing session for single user
Is it possible to clear a session for a single user? Currently, if we need to block user access, we must delete the user record or set registration key = blocked, and then clear session for the entire site. Is there a better way? --
Re: [web2py] Clearing session for single user
I believe if you store sessions in db (which is very easy and out of the box if you opt for it), you can delete entry of user from it to disconnect him instantly, without affecting other users. this table has a name like : web2py_session_YourApplicationName Regards On Tue, Aug 21, 2012 at 6:22 PM, Yarin ykess...@gmail.com wrote: Is it possible to clear a session for a single user? Currently, if we need to block user access, we must delete the user record or set registration key = blocked, and then clear session for the entire site. Is there a better way? -- --
Re: [web2py] Clearing session for single user
Khali- I've never seen a session table in web2py before. Neither basic app nor wizard-generated nor welcome app have one- where have you seen this? On Tuesday, August 21, 2012 1:31:04 PM UTC-4, Khalil KHAMLICHI wrote: I believe if you store sessions in db (which is very easy and out of the box if you opt for it), you can delete entry of user from it to disconnect him instantly, without affecting other users. this table has a name like : web2py_session_YourApplicationName Regards On Tue, Aug 21, 2012 at 6:22 PM, Yarin ykes...@gmail.com javascript:wrote: Is it possible to clear a session for a single user? Currently, if we need to block user access, we must delete the user record or set registration key = blocked, and then clear session for the entire site. Is there a better way? -- --
[web2py] Re: SQLFORM.factory + Multiple Tables + Upload Field + GAE Blob Problem
I found a work around to solve this problem I added these 3 lines after form accepted if request.env.web2py_runtime_gae: request.vars.file.file.seek(0) form.vars.file_blob = request.vars.file.file.read() Cause file_blob was None, I just set it. This thread was helpful. https://groups.google.com/forum/?fromgroups=#!search/%5Bweb2py%5D$20Re:$20Uploading$20Excel$20and$20reading$20from$20it/web2py/3wKcHVPBFI0/IobcR5OGcu8J 2012년 8월 21일 화요일 오후 2시 13분 37초 UTC+9, JungHyun Kim 님의 말: I opend the ticket. Issue 948 http://code.google.com/p/web2py/issues/detail?id=948:SQLFORM.factory + Multiple Tables + Upload Field + GAE Blob Problem Thank you Massimo. 2012년 8월 21일 화요일 오후 12시 25분 57초 UTC+9, Massimo Di Pierro 님의 말: Please open a ticket about this. On Monday, 20 August 2012 11:49:14 UTC-5, JungHyun Kim wrote: Hello! I have a problem with upload field. I tried to upload a file through one form with two tables using SQLFORM.factory. It worked OK on web2py rocket server. But with GAE server (both local test server and real GAE server), I can't upload files. The problem is blob is None after uploaded. I defined two tables. db.define_table('mibmessage', Field('user',db.auth_user,writable=False,readable= False,default=auth.user_id,), Field('message','text',notnull=True, widget = lambda field, value: SQLFORM. widgets.text.widget(field, value, _class='my-string')), Field('attached_files','list:reference attached_file', writable=False, default=[], readable=False), ) db.define_table('attached_file', Field('file','upload'), Field('original_filename', writable=False, notnull= False), Field('mibmessage',db.mibmessage), ) And in controller, I saved them. # Make a form form = SQLFORM.factory(db.mibmessage, db.attached_file, table_name= 'attached_file') # Save New Message if form.process().accepted: try: # Insert a message message_id = db.mibmessage.insert(**db.mibmessage. _filter_fields(form.vars)) form.vars.mibmessage=message_id if form.vars.file != '': form.vars.original_filename = request.vars.file.filename # Insert an attached file image_file_id = db.attached_file.insert(**db. attached_file._filter_fields(form.vars)) # The message has a list of attached files db.mibmessage[message_id].update_record(attached_files=[ image_file_id]) db.commit() except Exception: db.rollback() After uploaded, both rows are created. But 'file_blob' field of the 'attached_file' is None. If I upload an file using SQLFORM with single table (attached_file), it is OK. Did I use SQLFORM.factory wrong? I read this thread ( https://groups.google.com/forum/?fromgroups#!searchin/web2py/SQLFORM.factory$20one$20form$20multiple$20tables$20blob/web2py/O6D1J8h_MNA/lmFbEF1XzWcJ%5B1-25%5D), but I couldn't understand it. --
[web2py] Re: need a simple wiki...
Do I have to set something to get this to embedd youtube? Thanks, Rob ## Index Rob page content http://youtu.be/AHBjHCAUjus On Monday, August 20, 2012 9:30:09 PM UTC-4, Massimo Di Pierro wrote: I think the problem is that we broke trunk as we are running some tests... On Monday, 20 August 2012 14:21:40 UTC-5, Timmie wrote: I just gave it a try and it didnt work as stated. In my index.py file I have the return auth.wiki() directive there but whenever I try to view the page I get a login page and after that a 401 unauthorized error. I also have a problem to create a new user (register) from the frontend. With current git, I create a welcome app. 1) Then I try to register a user - nothing happens after hitting submit 2) when I create a new user, I am not able to log in from the frontend to that user. What could be the reason? Is there a way to test this without the authentication? --
Re: [web2py] Re: menu, mobile phones and tablets
Can you email me the patch? On Tuesday, 21 August 2012 10:59:21 UTC-5, mweissen wrote: Proposal: In gluon/html.py, line 2200 I have changed from def serialize_mobile(self, data, select=None, prefix=''): if not select: select = SELECT(**self.attributes) for item in data: if len(item) = 4 or item[4] == True: * if item[2]: # remove this line* select.append(OPTION(CAT(prefix, item[0]), _value=item[2], _selected=item[1])) if len(item)3 and len(item[3]): self.serialize_mobile(item[3], select, prefix = CAT(prefix, item[0], '/')) select['_onchange'] = 'window.location=this.value' return select to: def serialize_mobile(self, data, select=None, prefix=''): if not select: select = SELECT(**self.attributes) for item in data: if len(item) = 4 or item[4] == True: select.append(OPTION(CAT(prefix, item[0]), _value=item[2], _selected=item[1])) if len(item)3 and len(item[3]): self.serialize_mobile(item[3], select, prefix = CAT(prefix, item[0], '/')) select['_onchange'] = 'window.location=this.value' return select Now there is no difference between the desktop and the mobile version of the menu. A menu item without a link and with subitems will be displayed on all devices. --- Addendum 1: If somebody wants the original behavior, he has to change (e.g.) from response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [], ), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().is_**tablet)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] to response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [], *not request.user_agent().is_mobile * ), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().is_**tablet)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] Addendum 2: There is an error in my examples, this is the corrected code: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().* is_tablet*)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] and: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().* is_tablet*)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ] 2012/8/21 Massimo Di Pierro massimo@gmail.com javascript: Can you elaborate? Is there a problem that need to be solved? On Tuesday, 21 August 2012 09:46:35 UTC-5, szimszon wrote: +1 https://groups.google.com/d/**msg/web2py-developers/** FMCF0HTs64A/CJ-PNCaIsuwJhttps://groups.google.com/d/msg/web2py-developers/FMCF0HTs64A/CJ-PNCaIsuwJ 2012. augusztus 21., kedd 15:58:27 UTC+2 időpontban mweissen a következőt írta: I have played with some menu details and these are my results First try: response.menu = [ (T('Home'), False, URL('default','index'), [ (T('Dummy1'), False, URL('default','index'), [],), (T('Dummy2'), False, None, [],), (T('Desktop'), False, URL('default','index'), [], not (request.user_agent().is_**mobile or request.user_agent().is_**mobile)), (T('Mobile'), False, URL('default','index'), [], request.user_agent().is_**mobile), (T('Tablet'), False, URL('default','index'), [], request.user_agent().is_**tablet), ]) ]
[web2py] Re: need a simple wiki...
You have to use http://www.youtube.com/watch?v=AHBjHCAUjus else web2py does not know what oembed service to use. youtu.be is not a well known oembed service provider. On Tuesday, 21 August 2012 13:20:08 UTC-5, Rob_McC wrote: Do I have to set something to get this to embedd youtube? Thanks, Rob ## Index Rob page content http://youtu.be/AHBjHCAUjus On Monday, August 20, 2012 9:30:09 PM UTC-4, Massimo Di Pierro wrote: I think the problem is that we broke trunk as we are running some tests... On Monday, 20 August 2012 14:21:40 UTC-5, Timmie wrote: I just gave it a try and it didnt work as stated. In my index.py file I have the return auth.wiki() directive there but whenever I try to view the page I get a login page and after that a 401 unauthorized error. I also have a problem to create a new user (register) from the frontend. With current git, I create a welcome app. 1) Then I try to register a user - nothing happens after hitting submit 2) when I create a new user, I am not able to log in from the frontend to that user. What could be the reason? Is there a way to test this without the authentication? --
Re: [web2py] Clearing session for single user
pretty easy just after db definition example : db = DAL('postgres://postgres:Nour@localhost/asterisk') add this line : session.connect(request, response, db, masterapp=None) refresh and look inside database for a table called : web2py_session_YourAppNameHere On Tue, Aug 21, 2012 at 6:44 PM, Yarin ykess...@gmail.com wrote: Khali- I've never seen a session table in web2py before. Neither basic app nor wizard-generated nor welcome app have one- where have you seen this? On Tuesday, August 21, 2012 1:31:04 PM UTC-4, Khalil KHAMLICHI wrote: I believe if you store sessions in db (which is very easy and out of the box if you opt for it), you can delete entry of user from it to disconnect him instantly, without affecting other users. this table has a name like : web2py_session_**YourApplicationName Regards On Tue, Aug 21, 2012 at 6:22 PM, Yarin ykes...@gmail.com wrote: Is it possible to clear a session for a single user? Currently, if we need to block user access, we must delete the user record or set registration key = blocked, and then clear session for the entire site. Is there a better way? -- -- --
[web2py] Re: Clearing session for single user
the relevant book session is http://web2py.com/books/default/chapter/29/13#Sessions-in-database file sessions of db won't save you. You are in the need of having to know the relationship between session and user_id. Every app has different requirements, so you could implement the logic to store somewhere the relationship and not having to scan them all. Web2py doesn't expose that relationship because: a) sessions are created also for not registered users b) one registered user can have multiple sessions (one in chrome, the other in firefox), even in multiple devices (desktop, nettop, tablet, cell phone, etc) and they are considered (rightfully) valid. On Tuesday, August 21, 2012 7:22:42 PM UTC+2, Yarin wrote: Is it possible to clear a session for a single user? Currently, if we need to block user access, we must delete the user record or set registration key = blocked, and then clear session for the entire site. Is there a better way? --
[web2py] Re: Clearing session for single user
Perfect- this will get me there- thanks both On Tuesday, August 21, 2012 2:40:31 PM UTC-4, Niphlod wrote: the relevant book section is http://web2py.com/books/default/chapter/29/13#Sessions-in-database However, file sessions of db won't save you. You are in the need of having to know the relationship between session and user_id. Every app has different requirements, so you could implement the logic to store somewhere the relationship and not having to scan them all. Web2py doesn't expose that relationship because: a) sessions are created also for not registered users b) one registered user can have multiple sessions (one in chrome, the other in firefox), even in multiple devices (desktop, nettop, tablet, cell phone, etc) and they are considered (rightfully) valid. On Tuesday, August 21, 2012 7:22:42 PM UTC+2, Yarin wrote: Is it possible to clear a session for a single user? Currently, if we need to block user access, we must delete the user record or set registration key = blocked, and then clear session for the entire site. Is there a better way? --
Re: [web2py] Re: Clearing session for single user
You are right without some additional work to map users to session IDs its useless, but there are many ways from there : for example every user must have his own IP you can easily map a user to an ip upon login for example by using : auth.settings.login_onaccept = lambda func: usr_connect()#this function logs IP of user to some table auth.settings.logout_onlogout = lambda func2: usr_disconnect() #this function deletes Ip of user from table On Tue, Aug 21, 2012 at 7:40 PM, Niphlod niph...@gmail.com wrote: the relevant book session is http://web2py.com/books/default/chapter/29/13#Sessions-in-database file sessions of db won't save you. You are in the need of having to know the relationship between session and user_id. Every app has different requirements, so you could implement the logic to store somewhere the relationship and not having to scan them all. Web2py doesn't expose that relationship because: a) sessions are created also for not registered users b) one registered user can have multiple sessions (one in chrome, the other in firefox), even in multiple devices (desktop, nettop, tablet, cell phone, etc) and they are considered (rightfully) valid. On Tuesday, August 21, 2012 7:22:42 PM UTC+2, Yarin wrote: Is it possible to clear a session for a single user? Currently, if we need to block user access, we must delete the user record or set registration key = blocked, and then clear session for the entire site. Is there a better way? -- --
[web2py] Re: need a simple wiki...
I reverted trunk to the older Storage but this is not the end of this. We are still working to replace it in a backward compatible way OK, now it works. But why do I always get Registration needs Verification? Can this be switched off? --
[web2py] Re: Router for multiple controllers
wrong. routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller*2*/bye')) On Tuesday, August 21, 2012 9:42:27 AM UTC-7, howesc wrote: routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller1/bye')) On Tuesday, August 21, 2012 1:28:49 AM UTC-7, Daniel Gonzalez wrote: Hello, I have the following routing requirements, which I am unable to configure in routes.py: www.mysite.com/hello - application1, controller1, hello www.mysite.com/bye - application1, controller2, bye As you can see, the functions hello and bye are in different controllers. Is it possible to achieve this with routes.py? Thanks, Daniel --
Re: [web2py] Re: Router for multiple controllers
that's what i get for typing so quickly! thanks for spotting my mistake. :) On 8/21/12 12:15 , Derek wrote: wrong. routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller*2*/bye')) On Tuesday, August 21, 2012 9:42:27 AM UTC-7, howesc wrote: routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller1/bye')) On Tuesday, August 21, 2012 1:28:49 AM UTC-7, Daniel Gonzalez wrote: Hello, I have the following routing requirements, which I am unable to configure in routes.py: www.mysite.com/hello - application1, controller1, hello www.mysite.com/bye - application1, controller2, bye As you can see, the functions hello and bye are in different controllers. Is it possible to achieve this with routes.py? Thanks, Daniel --
[web2py] Re: Clearing session for single user
You could have a function that goes through each session file and looks for auth.user.id, and if it matches the id of the blocked user, delete the file. For some ideas on the logic for processing through all the session files, see http://code.google.com/p/web2py/source/browse/scripts/sessions2trash.py. Another option is to include something like this in your app: if auth.user and db.auth_user[auth.user_id].registration_key == 'blocked': [code to logout user and either clear the session or delete the session file] The downside of that is it involves a database hit on every request for logged in users. You could reduce the db hits by only running the check if the requested function is one that requires login. Anthony On Tuesday, August 21, 2012 1:22:42 PM UTC-4, Yarin wrote: Is it possible to clear a session for a single user? Currently, if we need to block user access, we must delete the user record or set registration key = blocked, and then clear session for the entire site. Is there a better way? --
Re: [web2py] Re: Router for multiple controllers
Thanks howesc and Derek, Your solution is working, but it is conflicting with routers. This is my full routes.py: routers = dict( BASE = dict( default_application = 'app1', ), myapp = dict( default_controller = 'controller1', default_function = 'start', ), ) routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller2/bye'), ) I need both the shortcuts /hello and /bye, and the routers configuration. Is this possible? BR, Daniel On Tuesday, August 21, 2012 9:17:06 PM UTC+2, howesc wrote: that's what i get for typing so quickly! thanks for spotting my mistake. :) On 8/21/12 12:15 , Derek wrote: wrong. routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller*2*/bye')) On Tuesday, August 21, 2012 9:42:27 AM UTC-7, howesc wrote: routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller1/bye')) On Tuesday, August 21, 2012 1:28:49 AM UTC-7, Daniel Gonzalez wrote: Hello, I have the following routing requirements, which I am unable to configure in routes.py: www.mysite.com/hello - application1, controller1, hello www.mysite.com/bye - application1, controller2, bye As you can see, the functions hello and bye are in different controllers. Is it possible to achieve this with routes.py? Thanks, Daniel --
Re: [web2py] Re: Router for multiple controllers
i *think* it is one or the other, but not both. :( there may be a routers equivalent to my suggestion, but i don't know it. :( i know that you can convert routers into the routes_in/routes_out style. On 8/21/12 12:41 , Daniel Gonzalez wrote: Thanks howesc and Derek, Your solution is working, but it is conflicting with routers. This is my full routes.py: routers = dict( BASE = dict( default_application = 'app1', ), myapp = dict( default_controller = 'controller1', default_function = 'start', ), ) routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller2/bye'), ) I need both the shortcuts /hello and /bye, and the routers configuration. Is this possible? BR, Daniel On Tuesday, August 21, 2012 9:17:06 PM UTC+2, howesc wrote: that's what i get for typing so quickly! thanks for spotting my mistake. :) On 8/21/12 12:15 , Derek wrote: wrong. routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller*2*/bye')) On Tuesday, August 21, 2012 9:42:27 AM UTC-7, howesc wrote: routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller1/bye')) On Tuesday, August 21, 2012 1:28:49 AM UTC-7, Daniel Gonzalez wrote: Hello, I have the following routing requirements, which I am unable to configure in routes.py: www.mysite.com/hello - application1, controller1, hello www.mysite.com/bye - application1, controller2, bye As you can see, the functions hello and bye are in different controllers. Is it possible to achieve this with routes.py? Thanks, Daniel --
Re: [web2py] Re: Router for multiple controllers
No, the parameter-based and pattern-based rewrite systems are mutually exclusive -- you cannot combine them (mentioned at the end of the second paragraph here: http://web2py.com/books/default/chapter/29/4#URL-rewrite). Anthony On Tuesday, August 21, 2012 3:41:11 PM UTC-4, Daniel Gonzalez wrote: Thanks howesc and Derek, Your solution is working, but it is conflicting with routers. This is my full routes.py: routers = dict( BASE = dict( default_application = 'app1', ), myapp = dict( default_controller = 'controller1', default_function = 'start', ), ) routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller2/bye'), ) I need both the shortcuts /hello and /bye, and the routers configuration. Is this possible? BR, Daniel On Tuesday, August 21, 2012 9:17:06 PM UTC+2, howesc wrote: that's what i get for typing so quickly! thanks for spotting my mistake. :) On 8/21/12 12:15 , Derek wrote: wrong. routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller*2*/bye')) On Tuesday, August 21, 2012 9:42:27 AM UTC-7, howesc wrote: routes_in = ( ('/hello', '/app1/controller1/hello'), ('/bye', '/app1/controller1/bye')) On Tuesday, August 21, 2012 1:28:49 AM UTC-7, Daniel Gonzalez wrote: Hello, I have the following routing requirements, which I am unable to configure in routes.py: www.mysite.com/hello - application1, controller1, hello www.mysite.com/bye - application1, controller2, bye As you can see, the functions hello and bye are in different controllers. Is it possible to achieve this with routes.py? Thanks, Daniel --
[web2py] timezone support in dal, assumes local time is gmt time
Could you explain this functionality, its application and settings? https://github.com/web2py/web2py/commit/ed485d38abe90e2c8f6578252d69fa9ebd4b98c1 --
[web2py] Re: SEO Friendly URLs and Page Titles
Thanks, what about URLs so it is www.domain.com/product/{{fieldname title}} On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote: You can set response.title and response.meta in the controller or function to make it specific to particular controllers or functions (or you can set them conditionally in a model file). If you need to use a database value, just do a query to get the value (your probably want to cache it to improve performance). Anthony On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote: 1. What is the easiest way to make it so each page has it's own title? Currently it is set by layout.html, but what if I want its own page to have an independent title? 2. How can I make it so the title of the page is the name of a field in a model? I am using SQLForm now, and have /product/1 and would like to have /product/purple-desk 3. How can I make it so the meta description on each page has its own ? For example, the description is the data in the field 'product description' used in the model. Thanks. --
[web2py] Field to get file path
Hi, I want to create a field where a user can select a file. But I dont want to upload the file, I just want to record the file path in the database. How do I do this? Thanks Simon --
[web2py] Re: Field to get file path
Are you saying you want to record the file path of the file on the user's machine? I'm not sure that's possible without some kind of browser plugin, as it would present a security risk (i.e., the browser won't send that information to the server). Anthony On Tuesday, August 21, 2012 4:32:01 PM UTC-4, Simon Carr wrote: Hi, I want to create a field where a user can select a file. But I dont want to upload the file, I just want to record the file path in the database. How do I do this? Thanks Simon --
[web2py] Re: SEO Friendly URLs and Page Titles
What is {{fieldname title}}? How do you get that value? On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote: Thanks, what about URLs so it is www.domain.com/product/{{fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}} On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote: You can set response.title and response.meta in the controller or function to make it specific to particular controllers or functions (or you can set them conditionally in a model file). If you need to use a database value, just do a query to get the value (your probably want to cache it to improve performance). Anthony On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote: 1. What is the easiest way to make it so each page has it's own title? Currently it is set by layout.html, but what if I want its own page to have an independent title? 2. How can I make it so the title of the page is the name of a field in a model? I am using SQLForm now, and have /product/1 and would like to have /product/purple-desk 3. How can I make it so the meta description on each page has its own ? For example, the description is the data in the field 'product description' used in the model. Thanks. --
Re: [web2py] Re: Field to get file path
OK, I will just have to have the user paste in the file path. Not a problem. Simon On 21 August 2012 21:42, Anthony abasta...@gmail.com wrote: Are you saying you want to record the file path of the file on the user's machine? I'm not sure that's possible without some kind of browser plugin, as it would present a security risk (i.e., the browser won't send that information to the server). Anthony On Tuesday, August 21, 2012 4:32:01 PM UTC-4, Simon Carr wrote: Hi, I want to create a field where a user can select a file. But I dont want to upload the file, I just want to record the file path in the database. How do I do this? Thanks Simon -- --
[web2py] Hiding items in foreign key dropdown menus?
I have a support table with the field 'isactive', which is a boolean. When someone is adding to a table that is supported by the first table, I want only items with isactive as True to be included in the dropdown. Here is some simplified example code: model -- db.define_table('fruits', Field('name', requires = IS_NOT_EMPTY()), Field('isactive', 'boolean')) db.define_table('grocery', Field(fruits', db.fruits, requires = IS_EMPTY_OR(IS_IN_DB(db, db.fruits, '%(name)s')), represent=lambda id, row: db.fruits(id).name if id else '')) --- In a SQLFORM generated from the grocery table, how can I only show fruits that are active? Thanks! -Joe Peacock --
[web2py] Re: need a simple wiki...
Thanks ! works perfectly. youtu.be is not a well known oembed service provider. Funny the http://youtu.be/theVideoID tag, is all they've been using to SHARE a link lately. Also, the markmin syntax seems to work well. http://web2py.com/examples/static/markmin.html https://lh4.googleusercontent.com/-ME6HiUjk7_I/UDP5unu2F5I/ATI/qDnQZSauU5U/s1600/Screen+Shot+2012-08-21+at+5.11.09+PM.png --
[web2py] Re: SEO Friendly URLs and Page Titles
I didnt mean to do {{ }}, but I mean domain.com/product/productname (Product name being the name of the variable in the field from the model) On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote: What is {{fieldname title}}? How do you get that value? On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote: Thanks, what about URLs so it is www.domain.com/product/{{fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}} On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote: You can set response.title and response.meta in the controller or function to make it specific to particular controllers or functions (or you can set them conditionally in a model file). If you need to use a database value, just do a query to get the value (your probably want to cache it to improve performance). Anthony On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote: 1. What is the easiest way to make it so each page has it's own title? Currently it is set by layout.html, but what if I want its own page to have an independent title? 2. How can I make it so the title of the page is the name of a field in a model? I am using SQLForm now, and have /product/1 and would like to have /product/purple-desk 3. How can I make it so the meta description on each page has its own ? For example, the description is the data in the field 'product description' used in the model. Thanks. --
[web2py] Re: Hiding items in foreign key dropdown menus?
IS_IN_DB can take a set. It is mentioned in the book. Use something like: db(db.fruits.isactive==True) in place of db.fruits On Tuesday, August 21, 2012 10:13:52 PM UTC+1, joe wrote: I have a support table with the field 'isactive', which is a boolean. When someone is adding to a table that is supported by the first table, I want only items with isactive as True to be included in the dropdown. Here is some simplified example code: model -- db.define_table('fruits', Field('name', requires = IS_NOT_EMPTY()), Field('isactive', 'boolean')) db.define_table('grocery', Field(fruits', db.fruits, requires = IS_EMPTY_OR(IS_IN_DB(db, db.fruits, '%(name)s')), represent=lambda id, row: db.fruits(id).name if id else '')) --- In a SQLFORM generated from the grocery table, how can I only show fruits that are active? Thanks! -Joe Peacock --
Re: [web2py] Re: SEO Friendly URLs and Page Titles
You want to create a slug? web2py comes with IS_SLUG validator which helps with this. db.define_table(product, Field(title, unique=True), ... ... Field(slug, compute=lambda row: IS_SLUG()(row.title)[0] ) So now you can use slug field to build your urls. URL(product, show, args=product.slug) in product/show/product-name def show(): try: product = db.product[int(request.args(0))] except: product = db(db.product.slug == request.args(0)).select().first() return product On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus morrisjamespatr...@gmail.comwrote: I didnt mean to do {{ }}, but I mean domain.com/product/productname (Product name being the name of the variable in the field from the model) On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote: What is {{fieldname title}}? How do you get that value? On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote: Thanks, what about URLs so it is www.domain.com/product/{{**fieldnamehttp://www.domain.com/product/%7B%7Bfieldnametitle}} On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote: You can set response.title and response.meta in the controller or function to make it specific to particular controllers or functions (or you can set them conditionally in a model file). If you need to use a database value, just do a query to get the value (your probably want to cache it to improve performance). Anthony On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote: 1. What is the easiest way to make it so each page has it's own title? Currently it is set by layout.html, but what if I want its own page to have an independent title? 2. How can I make it so the title of the page is the name of a field in a model? I am using SQLForm now, and have /product/1 and would like to have /product/purple-desk 3. How can I make it so the meta description on each page has its own ? For example, the description is the data in the field 'product description' used in the model. Thanks. -- --
[web2py] Re: IS_IN_DB cannot pull the data from the table
Is there any other way I can try ? I can see the data in the both table no problem. It just cannot use IS_IN_DB function for it. On Monday, August 20, 2012 2:33:39 PM UTC-5, Omi Chiba wrote: Is the problem only in appadmin? No, it happnes anywhere. Can you produce a minimum program with some sample data to reproduce this? I tried MySQL, MSSQL and DB2, and found only DB2 has this problem. This is how to reproduce the error on db2. This is very critical for my current project and I hope we can find the problem or find another way to do the dropdown which works on db2. 1. create table below models/db_tables.py - # coding: utf8 db.define_table('dog', Field('dogid'), Field('name'), format='%(name)s', primarykey=['dogid']) db.define_table('cat', Field('catid'), Field('name'), format='%(name)s', primarykey=['catid']) db.define_table('person', Field('personid'), Field('name'), Field('mydog'), Field('mycat'), format='%(name)s', primarykey=['personid']) db.person.mydog.requires=IS_IN_DB(db,db.dog.dogid,'%(name)s') db.person.mycat.requires=IS_IN_DB(db,db.cat.catid,'%(name)s') - 2. create the table on db2 from dds person - A* A R PERSONR A* APERSONID 5A ANAME 50A AMYDOG 5A AMYCAT 5A A* A* KEY FIELDS A* A K PERSONID A* - Dog - A* A R DOGR A* ADOGID 5A ANAME 50A A* A* KEY FIELDS A* A K DOGID A* - Cat - A* A R CATR A* ACATID 5A ANAME 50A A* A* KEY FIELDS A* A K CATID A* - 3. Insert test data - Dog dogid = '12345' name = 'HACHI' Cat catid='CAT01' name = 'TAMA' - 4. Result I can pull the data from Dog table but not Cat table (see attached) As you can see the dog and cat table is exactly the same type of table but dog has data begin with number and cat begin with alphabet. On Sunday, August 19, 2012 10:08:07 AM UTC-5, Massimo Di Pierro wrote: Is the problem only in appadmin? Can you produce a minimum program with some sample data to reproduce this? On Friday, 17 August 2012 23:56:39 UTC-5, Omi Chiba wrote: Issue #939 is assigned. http://code.google.com/p/web2py/issues/detail?id=939 On Friday, August 17, 2012 9:51:48 PM UTC-5, Massimo Di Pierro wrote: Please open a ticket pointing to this thread. Will look at it asap. On Friday, 17 August 2012 17:33:51 UTC-5, Omi Chiba wrote: I finally figured this should be a bug on the current in trunk version (Version 2.0.0 (2012-08-15 17:30:38) dev) I can pull the data when the data in primarykey field begin with numeric numbers for example 12345 or 1ABCDE (See NG-1,2.jpg) but cannot pull the data begin with alphabet like A1234. (See OK-1,2.jpg) # MF - EDI CUSTOMER db.define_table('EDMACF00', Field('ACDIID', length=5, label=Dist Code), Field('ACNAME', length=20, label=Dist Name), Field('AC855F', length=1, label=PO ACK FLAG), Field('AC856F', length=1, label=ASN FLAG), Field('AC810F', length=1, label=INVOICE FLAG), Field('ACUPFL', length=1, label=OZ UPLOAD FLAG), Field('ACCRBY', length=20, default = auth.user.username.upper() if auth.user else None, label=Created by), Field('ACCRDT', 'datetime', default =request.now, label=Created on), Field('ACUPBY', length=20, update = auth.user.username.upper() if auth.user else None, label=Updated by), Field('ACUPDT',
[web2py] Re: timezone support in dal, assumes local time is gmt time
http://code.google.com/p/web2py/issues/detail?id=941can=1q=timezone For now it simply allows you to pass a string with a +04:00 timezone and it converts it to GMT. On Tuesday, 21 August 2012 15:20:46 UTC-5, Timmie wrote: Could you explain this functionality, its application and settings? https://github.com/web2py/web2py/commit/ed485d38abe90e2c8f6578252d69fa9ebd4b98c1 --