[web2py] response view with markdown

2017-10-15 Thread 黄祥
i plan to reduce db io by put the static data that rarely change into markdown file (*.md) e.g. *controllers/default.py* def testmd(): response.view = 'testmd.md' return locals() views/default/testmd.md content is using web2py README.markdown content (just for testing) when access http:

[web2py] Re: response view with markdown

2017-10-15 Thread Anthony
It should be: response.view = 'default/testmd.md' Also, anything outside the {{...}} delimiters in a view will simply be returned as is, so any markdown in the file will be sent to the browser untransformed. Anthony On Sunday, October 15, 2017 at 8:32:44 AM UTC-4, 黄祥 wrote: > > i plan to

[web2py] New plugin: Authman

2017-10-15 Thread Bernhard Radermacher
I developed a little plugin to facilitate authorization management. It can be found at: https://github.com/bradermacher/web2py-plugin-authman I appreciate any comments. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: New plugin: Authman

2017-10-15 Thread Anthony
Very nice. Thanks for posting. This appears to be much more complete, but note that every app includes some basic functionality for managing users, roles, and permissions via the URL /myapp/appadmin/manage/auth. All you have to do is include the following line in a model: auth.settings.auth_man

[web2py] Re: How to get rid if the /init/default/ in the URL?

2017-10-15 Thread Anthony
On Friday, October 13, 2017 at 5:12:13 AM UTC-4, Joe wrote: > > Thanks very much Anthony for all your help with this one. I copied the > exact code you posted but nothing changed. > > I wonder if this has to do with having multiple apps in the web2py > directory. > No, the above example also inc

[web2py] Re: How to get rid if the /init/default/ in the URL?

2017-10-15 Thread Anthony
On Friday, October 13, 2017 at 7:22:42 PM UTC-4, Joe wrote: > > Hi Dave, I have reloaded the apps in web2py if that's what you mean. I > can't restart web2py, I can only reload the apps, I guess. > Is there an other way on pythonanywhere? I mean, restarting web2py instead > of reloading the apps?

[web2py] Re: New plugin: Authman

2017-10-15 Thread Bernhard Radermacher
That is correct. But this accesses the respective auth tables directly. authman adds additional tables, that allow - extensive editing before activation - roles can be included in other roles, thereby creating an organizational structure. For example: - Role Accounting Manager includes

[web2py] Re: New plugin: Authman

2017-10-15 Thread Bernhard Radermacher
Forgot to mention that assignment is a bit easier, too:

[web2py] Re: response view with markdown

2017-10-15 Thread Bernhard Radermacher
I use the following to display the contents of a MARKDOWN. from https://github.com/bradermacher/web2py-plugin-authman/blob/master/controllers/plugin_authman.py def index(): # Read plugin description and display. # Some logic in view (status of plugin and authorization from os.path

[web2py] Update form fields on submit

2017-10-15 Thread backseat
I have a page that is a report, and at the top of that page is a form with a 'from' and 'to' date field so that the user can select the date range to report on. By default, the dates select and the first to the last of last month. That works fine. I want to add a combo that will allow the selec

[web2py] Re: Update form fields on submit

2017-10-15 Thread Bernhard Radermacher
Might not be the most efficient, but if you put the from date and to date as arguments and then redirect in the form.accepts: if form.accepts(request,session): #calculate the new dates... session.flash='Updated date range' redirect(URL('report',args=[from_date,to_date])) -- Resourc

[web2py] Re: How to create specific migrations files per sqlite database in same app

2017-10-15 Thread Bernhard Radermacher
Not sure if that's the issue, but first you should use os.path.join to join every part: os.path.join(request.folder, 'databases', 'clients', 'client_{0}'.format(tenant)) otherwise you introduce a OS dependency. I would try con='sqlite://' + os.path.join(request.folder, 'databases', 'clients'

[web2py] Re: How to create specific migrations files per sqlite database in same app

2017-10-15 Thread AlighaThor
Yep...that worked. In the meantime I did this per table definition: def migration(table): return '{0}/{1}.table'.format(tenant_folder, table) #In the tables definitions ... migrate=migration('buildings') That worked, but I like your clarification more. Thanks mate. El domingo, 15 de octubr

[web2py] Re: How to create specific migrations files per sqlite database in same app

2017-10-15 Thread Bernhard Radermacher
Glad I could help. I found that you better use absolute paths as soon as you want to go down to sub directories. Using '.' as the begin of the path might work, but I have not tested that. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2p

[web2py] Re: Update form fields on submit

2017-10-15 Thread backseat
Thanks, Bernhard. The solution I ended up with is quite messy, but it does work: # Set defaults if request.get_vars: filter_bar.vars.from_date = datetime.datetime.strptime( request.get_vars.from_date, "%Y-%m-%d").date() filter_bar.vars.to_date = datetime.dateti