new Starter app (alternative to Welcome app)

560 views
Skip to first unread message

Michael Beller

unread,
Mar 22, 2016, 10:17:41 PM3/22/16
to web2py-users
I created a new 'starter' app for the types of data and process management apps I tend to build.

I used https://almsaeedstudio.com/preview as the template and I'm hosting a preview at https://mjbeller.pythonanywhere.com/starter.

I'd welcome any feedback but also wanted to share the code at https://github.com/mjbeller/web2py-starter for anybody that may want to explore.

I started with the goal to create a new web2py app without using the Welcome app to help me learn a little more about web2py.  I found myself slowly adding more and more code (primarily CSS and JS) from the Welcome app to support some features such as Smartgrids.  I'd like to evolve Starter to support the upcoming form.py and grid.py that the core team is evaluating and developing.

Richard Vézina

unread,
Mar 23, 2016, 12:31:35 AM3/23/16
to web2py-users
Michael,

The preview is really "fucking" nice!!

It that what your starter app is capable really?

Richard

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

Michael Beller

unread,
Mar 23, 2016, 12:52:35 AM3/23/16
to web2py-users
Thank you!  All due credit to almsaeedstudio.com for the HTML/CSS/JS template.  I modified the template to match the web2py standards and the starter app now includes all the capabilities.  I've created a menu item helper to create menu items and also included Anthony's appadmin/manage by default for administrators.  I'm still using the web2py styling for forms and smartgrids (but I use a pattern in the Starter app in the controllers using Datatables.net which you can see with the sample Dogs and Persons models).  I'd like to create the web2py native form and grid styling but I think it may make sense to wait for the new form.py and grid.py that I think Massimo is creating for the upcoming release.

One other nice feature - open the site on a mobile phone and it renders very nicely with the menus sliding in from the left and right.  I did just notice the web2py user login menu doesn't render correctly on my phone so I need to fix that.

Massimo Di Pierro

unread,
Mar 23, 2016, 1:43:41 AM3/23/16
to web2py-users
this is really nice.  We should make a list of welcome apps so people can pick and choose.

P.S. Have you seen this? (similar but CSS only) .

Jason Brower

unread,
Mar 23, 2016, 1:47:46 AM3/23/16
to web...@googlegroups.com
I agree Massimo.  We should have a small wizard to help select what kind of layout we would want.
Blank
Stupid CSS
This one
Bookstrap 3
Angular example
etc...
--

webm...@trytha.com

unread,
Mar 23, 2016, 2:17:15 AM3/23/16
to web2py-users
Really dig that responsive transition when changing window sizes.  I know it will never be seen by a non-programmer, but it looks totally sweet.  Need to work that in to my own apps.

If we could get all the web2py HTML in a Jade version, that'd be pretty awesome, too.  Much more pleasant to go between Python and Jade than Python and HTML.  Likewise with Stylus, but I roll my own CSS, so that's less compelling on a personal level.  If you haven't tried it, Jade is basically Python syntax for HTML and Stylus is (to a lesser extent) Python syntax for CSS.  Both transpile perfectly into their respective languages.  There's also Coffeescript (Python-like JS), but that's just putting lipstick on a pig.

I'll mark all this down as a back-burner side project.

Massimiliano

unread,
Mar 23, 2016, 5:40:32 AM3/23/16
to web...@googlegroups.com
Very very nice. 

Thank you for sharing

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



--
Massimiliano

António Ramos

unread,
Mar 23, 2016, 6:19:23 AM3/23/16
to web...@googlegroups.com
Nice but i get an error installing it as "starter" application
any help ?

Imagem inline 1

Ron Chatterjee

unread,
Mar 23, 2016, 6:23:16 AM3/23/16
to web2py-users
Does it has a version similar to web2py welcome app with no user name? And I got the same error

Nico de Groot

unread,
Mar 23, 2016, 6:33:27 AM3/23/16
to web2py-users
Haven't tried yet, but you need to configure a little. From the preview site:

IMPORTANT NOTES:
Starter App is currently maintained on web2py current master branch
appconfig.ini is not included in the git repo (it's excluded by .gitignore) so you'll need to copy the file if you clone rather than download the repo
when you first install on localhost, you can access /initialize/adminuser to create initial admin user and auth_groups
models includes some sample tables for Dogs, Persons, and Dog Owners which you can easily delete

Ron Chatterjee

unread,
Mar 23, 2016, 6:51:42 AM3/23/16
to web2py-users
you calling me a dog? lol. jk. Get the point. Thanks

rajjm...@gmail.com

unread,
Mar 23, 2016, 7:13:05 AM3/23/16
to web2py-users
Is there a dashboard version of the starter app we can use?

Massimiliano

unread,
Mar 23, 2016, 7:41:21 AM3/23/16
to web2py-users
Just copy

appconfic.ini from welcome/private to starter/private

António Ramos

unread,
Mar 23, 2016, 7:47:37 AM3/23/16
to web...@googlegroups.com
I already copied appconfig.ini to private

but next error...

Imagem inline 1
then i changed auth above to just
auth=auth(db)

and now i could open the app but when i go to login or sign up i get another error

Imagem inline 2



Michael Beller

unread,
Mar 23, 2016, 8:13:18 AM3/23/16
to web2py-users
I just added the appconfig.ini to the repo since that will cause confusion.  It contained the item for host_names supported by the current web2py in trunk.

auth = Auth(db, host_names=myconf.get('host.name'))

Since I'm not sure what that is for, I just changed it back to:

auth = Auth(db)

in /models/db1.py

Update your appconfig.ini to include the host_names entry (the appconfig.ini in the repo on github contains the entry)
OR
Remove the host_names parameter from the call to Auth on line 58 in /models/db1.py

That should get your local copy working (and eliminate the confusion for future downloads or clones)

António Ramos

unread,
Mar 23, 2016, 1:07:47 PM3/23/16
to web...@googlegroups.com
i cannot log in or register...

António Ramos

unread,
Mar 23, 2016, 1:08:10 PM3/23/16
to web...@googlegroups.com
error in login/register
Imagem inline 1

Michael Beller

unread,
Mar 23, 2016, 1:15:23 PM3/23/16
to web2py-users
That may be a problem with an earlier version of web2py.  I'm testing now on trunk, i.e., the master branch of web2py.  I noticed this earlier but haven't been able to see what's changed in master vs. previous versions.  Anybody know?

What version of web2py are you using?

I should probably move Starter to the stable release.

António Ramos

unread,
Mar 23, 2016, 2:27:04 PM3/23/16
to web...@googlegroups.com
2.12.13

Literate Aspects

unread,
Mar 23, 2016, 2:34:40 PM3/23/16
to web2py-users
Hi Michael,

Thank YOU! for including me in this thread.  Wow, I now understand what your admin webapp is.

I am determined TODAY to create my own first Web2PY app, PLEASE, does anyone know of a "create your first Web2PY app in 1 hour" type of tutorial.  I am viewing the (11 hour) 5 set video tutorials generously created by Massimo, but would really like to get hands on.

PLEASE, anybody...

Jon

Willoughby

unread,
Mar 23, 2016, 3:25:50 PM3/23/16
to web2py-users
I have a 'Create Your First web2py App in 38 Minutes' book, but not the hour long version.
Sorry.

Rimantas Nedzinskas

unread,
Mar 23, 2016, 4:02:27 PM3/23/16
to web2py-users

Michael Beller

unread,
Mar 23, 2016, 4:19:27 PM3/23/16
to web2py-users
Hi Ramos,

I found the problem.

using appconfig for formstyle doesn't work in older versions (it appears that it doesn't recognize the underscore).

I hardcoded the formstyle in db1.py and updated the repo

You can refresh from the repo (there's been some other small enhancements) or in models/db1.py change this
response.formstyle = myconf.get('forms.formstyle')

to this
response.formstyle = 'bootstrap3_inline'

that should work in older web2py versions

Literate Aspects

unread,
Mar 23, 2016, 4:54:02 PM3/23/16
to web...@googlegroups.com
Interesting... Willoughby.

Sorry, I fail to see your "humor".

Literate Aspects

unread,
Mar 23, 2016, 5:09:34 PM3/23/16
to web2py-users
Hi Rimantas,

Thank you.  I humbly appreciate everything you and the other LOVERS OF CODING share.

With all respect to those who have shared tutorial data, the instruction DOES not exactly match the real time practice.
Can you help me with this?  I am going to attach screen shots.

Please note, where does the below go?  Do I replace all the text under def index(): removing the response.flash = T("Hello World") - NOTE, which is NOT what the book has - view screenshot of Chapter 3 and screen shot of Live App.

If you could answer this then I could move on, as the web2py keeps generating error tickets.



return "Hello from MyApp"

go?
Chapter 3.png
Live App.png

Literate Aspects

unread,
Mar 23, 2016, 5:13:30 PM3/23/16
to web...@googlegroups.com
Hi Rimantas,

Sorry, got it to work, just put the same text in front and it ran.

Thank you, sorry to waste your time.

Jon

Literate Aspects

unread,
Mar 23, 2016, 5:23:34 PM3/23/16
to web...@googlegroups.com
Hi Rimantas,

Please, what is the difference between:

def index(): return "Hello from MyApp"

def index(): return dict(message="Hello from MyApp")

I see the different RUN screen outputs, but do not have a definition of:

RETURN
RETURN DICT

to be able to determine the specific differences, is there somewhere that has a list of commands with definitions?

Any suggestions greatly appreciated.

Jon

ps.  collecting those golden nuggets of KNOWLEDGE !

Rimantas Nedzinskas

unread,
Mar 23, 2016, 5:55:52 PM3/23/16
to web2py-users
Jon, I see you are pushing new information into your brains too fast :)
Take a rest. Sleep well. I'm serious. Let your brain to digest. Then go back to the beginning of the book or/and review the beginning of the video about the basic concepts of the web2py framework.
Try to understand the workflow from the request to the response. Clarify how views are used and how templates works. Then examine the generic views (generic.html, generic.json, etc.). Try to create your own view. Play with different data types in the response. You'll get it.

A little hint: if you did not define your own view the generic view will be used. And if you take a look inside the generic.html file then you will find a helper function BEAUTIFY(). Read about it in the book.

Good night

Rimas

Literate Aspects

unread,
Mar 23, 2016, 6:01:24 PM3/23/16
to web2py-users
Hi Rimas,

I thank you for the kind thoughts, but I simply don't have that luxury.  I read and I listen to the video tutorials, IF they matched the current live app, then following the step by step instructions would be straight forward, but the live app does not match the instructions, so at each step, one has to FIGURE out an unknown.

Jon

Rimantas Nedzinskas

unread,
Mar 23, 2016, 6:26:51 PM3/23/16
to web...@googlegroups.com
This is what I tried to tell you. Blindly following the tutorials is not so easy if you don't have clear understanding of how things are related. Most tutorials could be outdated, different developers used slightly different approach, different configs, templates and so on. 
Anyway, I guess you found my hint to your question useful.

Rimas

--
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Md-OTq-hi-U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Dave S

unread,
Mar 23, 2016, 6:36:34 PM3/23/16
to web2py-users


On Wednesday, March 23, 2016 at 3:01:24 PM UTC-7, Literate Aspects wrote:
Hi Rimas,

I thank you for the kind thoughts, but I simply don't have that luxury.  I read and I listen to the video tutorials, IF they matched the current live app, then following the step by step instructions would be straight forward, but the live app does not match the instructions, so at each step, one has to FIGURE out an unknown.


The only difference I recognized in the screen shots was that the book had 1 more line in the header comment.  The code lines you showed seemed to match.  But recognize that the code included in the Welcome app (which is the code that gets used if you pressed the "Make new App" button on the Web2Py "console" page) can get changed every release; the book tends not to change as often.

Some of these changes are simplification, some are taking advantage of new features, and some are corrections.

Going back to one of your earlier questions:

def index(): return "Hello from MyApp"

differs from 


def index(): return dict(message="Hello from MyApp")

in a basic Python way ... the first returns a string, the second returns a dictionary object, where the key "message" has the value "Hello from MyApp:, which is a string.  The generic views that come with Web2Py know how to render a string.  They also know how to render values retrieved from a dictionary.  Just about everything else is a special case of those 2 basic capabilities.

The BEAUTIFY() helper Rimas mentioned is something that gets executed on the server (in rendering the views) to generate HTML that shows what's in the object given as it's argument.  If that argument is a dictionary like the above, it will render a short table showing the key ("message") and its value ("Hello From MyApp").

Chapter 2 covers some Python basics, and general Python tutorials and books are available elsewhere.  If you're totally new to programming, than you may want to spend some time on those.  If you're used to C or C# or Java, Chapter 2 may be enough to get you started.

Good luck!

/dps



Ron Chatterjee

unread,
Mar 23, 2016, 7:12:58 PM3/23/16
to web...@googlegroups.com
I copied the config file from private and changed this to db1.py.

auth = Auth(db, host_names=myconf.get('host.name'))

I still don't get the app running. Any suggestions?

web2py version running: 2.12.3

Michael Beller

unread,
Mar 23, 2016, 7:22:22 PM3/23/16
to web2py-users
I changed auth = Auth(db, host_names=myconf.get('host.name'))
to auth = Auth(db) for backwards compatibility (I think host_names will be introduced in the upcoming release)

That should fix that problem.

Are you having another problem?  I'm actually having a problem with the old pydal in old versions and can't find the problem - but it's working with current 2.14.1

Could you try using the current Version 2.14.1-beta+timestamp.2016.03.23.16.47.51 ?  That's what I developed against.

Would love to find the problem supporting old versions though!

Literate Aspects

unread,
Mar 23, 2016, 7:26:43 PM3/23/16
to web...@googlegroups.com
OK, getting into it, EXCELLENT!

Thank you for your reply!

Jon

Literate Aspects

unread,
Mar 23, 2016, 7:30:35 PM3/23/16
to web...@googlegroups.com
Thank you Dave S.

Massimo Di Pierro

unread,
Mar 23, 2016, 7:32:18 PM3/23/16
to web2py-users
You cannot do that. You have an app created with web2py 2.14.1 beta and run it with an older version of web2py. myconf.get is not defined.
We only offer backward compatibility, not forward compatibility.

Massimo

Ron Chatterjee

unread,
Mar 23, 2016, 8:02:51 PM3/23/16
to web2py-users
Got it. As always, thank you Massimo. 

I changed in db1.py

auth.define_tables(username=True, signature=True)

to 
auth.define_tables(username=False, signature=True)

But in  the log in it still ask me for user name. 

Also I get an error when I try to register.

pydal\helpers\classes.py", line 18, in __init__
return self.__dict__.__init__(*args, **kwargs)
TypeError: 'NoneType' object is not iterable

Michael Beller

unread,
Mar 23, 2016, 8:38:22 PM3/23/16
to web2py-users
Are you using 2.14.1 beta?

I would try to get it running without changes before making changes (unless you have a need to get it running on an old version of web2py).  As Massimo pointed out, it's not necessarily backward compatible but other than removing host_names (which I already did in the repo) I don't see why it wouldn't work on an older version (I also had to remove formstyle from appconfig to support an older version).

I just installed a clean version using 
into 2.14.1 beta (actually current master) and then accessed
to setup Admin user and auth_groups and everything worked fine.

I'm still getting an odd error on 2.13.x which I can't figure out but I'm content to move forward with just 2.14.1

Massimo Di Pierro

unread,
Mar 23, 2016, 10:22:32 PM3/23/16
to web2py-users
I am linking this from the new examples app. I assume you will be maintaining it. for a while. :-)

Michael Beller

unread,
Mar 24, 2016, 12:23:08 AM3/24/16
to web2py-users
I plan to! When ready, I'd like to try and apply these styles
to the new form.py and perhaps
to the new grid.py

Ron Chatterjee

unread,
Mar 24, 2016, 8:56:22 AM3/24/16
to web2py-users
I am looking at this link:

https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html. Is that widget/plugin that comes with that bootstrap? Michael, you familiar with that?

It has something call direct chat. 

rajjm...@gmail.com

unread,
Mar 24, 2016, 9:13:40 AM3/24/16
to web2py-users
This may be little preliminary but what you mean by "Admin user and auth_groups" setup and how? I don't recall anything to set up with the welcome app. It worked the first time straight out of the box.

Michael Beller

unread,
Mar 24, 2016, 10:34:04 AM3/24/16
to web...@googlegroups.com
Yes - the AdminLTE template/theme is based on Bootstrap and includes many front-end plugins/components (like Datatables.net, Full Calendar, etc.).  It includes layouts and widgets for displaying chat sessions, charts, tables, etc. all with a common theme and layout.

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

Michael Beller

unread,
Mar 24, 2016, 10:38:35 AM3/24/16
to web...@googlegroups.com
I commonly create a user (usually my email) and an Admin group and then add myself to the Admin group.  I have logic in the Starter app based on the Admin group.  I usually have other groups such as Operations and Customer Service (I tend to build enterprise 'line of business' apps).  Since I frequently clean out the database during initial development, I just created an initialization function that automatically adds an initial set of test users, groups, and memberships so I don't have to do it manually,   The Initialization function also calls a function that automatically populates tables with test data (using the Populate function) that is helpful for quick demos during prototyping and user demos.  You can modify the routines to meet your needs - it's just something I always end up creating so I put it in my scaffold app.

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

Ron Chatterjee

unread,
Mar 24, 2016, 11:20:29 AM3/24/16
to web...@googlegroups.com
Not sure its ready to be posted. I just downloaded the app and I don't see any initialization. My experience...it seems have some issues still (see the attached pic) . When I tried to register, I get this error:


Traceback (most recent call last):
 
File "…\web2py\gluon\restricted.py", line 227, in restricted
    exec ccode in environment
  File" …applications/starter/controllers/default.py", line 91, in <module>
 
File "…web2py\gluon\globals.py", line 412, in <lambda>
    self.
_caller = lambda f: f()
 
File …/starter/controllers/default.py", line 70, in user
    return dict(form=auth())
 
File "…web2py\gluon\tools.py", line 1923, in __call__
    return getattr(self, args[0])()
 
File "…\tools.py", line 3375, in register
    self.login_user(user)
 
File "…web2py\gluon\tools.py", line 2630, in login_user
    user = Row(user)
 
File "…\helpers\classes.py", line 18, in __init__


    return self.__dict__.__init__(*args, **kwargs)
TypeError: 'NoneType' object is not iterable


Using 2.13.4 (which has a flash bar that just never goes away. lol. I believe 2.14 its fixed.). 
starter.png

Michael Beller

unread,
Mar 24, 2016, 11:56:27 AM3/24/16
to web...@googlegroups.com
The appconfig in 2.13 has a problem with strings separated by comma's in the appconfig.ini file.  Starter app uses 2.14.1

You can either install 2.14.1 or just change ...

line 34 in initialize.py:
        for group in myconf.get('admin_user.auth_groups'):

could replace with
        for group in ['Admin', 'Customer Service', 'Operations']:

or just change the function to create the Admin group which is all that's needed.



On Thu, Mar 24, 2016 at 11:20 AM, Ron Chatterjee <achatte...@gmail.com> wrote:
Not sure its ready to be posted. I just downloaded the app and I don't see any initialization. My experience...it seems have some issues still (see the attached pic) . When I tried to register, I get this error:


Traceback (most recent call last):
 
File "…\web2py\gluon\restricted.py", line 227, in restricted
    exec ccode in environment
  File" …applications/starter/controllers/default.py", line 91, in <module>
 
File "…web2py\gluon\globals.py", line 412, in <lambda>
    self.
_caller = lambda f: f()
 
File …/starter/controllers/default.py", line 70, in user
    return dict(form=auth())
 
File "…web2py\gluon\tools.py", line 1923, in __call__
    return getattr(self, args[0])()
 
File "…\tools.py", line 3375, in register
    self.login_user(user)
 
File "…web2py\gluon\tools.py", line 2630, in login_user
    user = Row(user)
 
File "…\helpers\classes.py", line 18, in __init__
    return self.__dict__.__init__(*args, **kwargs)
TypeError: 'NoneType' object is not iterable


Using 2.13.4 (which has a flash bar rash that just don't go away). 

Ron Chatterjee

unread,
Mar 24, 2016, 3:03:41 PM3/24/16
to web2py-users
I am sorry, I was having some problem downloading the latest version so everything is good. Quick question Michael, how does someone change the profile picture? There is a avatar field?

Michael Beller

unread,
Mar 24, 2016, 3:33:00 PM3/24/16
to web2py-users
No Avatar field yet!  It's hardcoded in the template.  It should be easy to add a custom field to the auth_user table following these instructions:

Then you can upload an avatar using the user profile page.

I haven't done this with images but it should be straight forward (it's on my todo list!)

You can also designate a dedicated folder for the avatar uploads so they're not commingled with other upload files ...

Ron Chatterjee

unread,
Mar 24, 2016, 3:51:56 PM3/24/16
to web2py-users
Its all good. Just asked. 

António Ramos

unread,
Mar 25, 2016, 6:09:38 AM3/25/16
to web...@googlegroups.com
This starter is sooo cool.
Its was time we had something like this.



You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

Alessio Varalta

unread,
Mar 25, 2016, 12:39:53 PM3/25/16
to web2py-users
Is great! I think is a good choose to introduce a functionality that in admin console you can choose this as starter

Ron Chatterjee

unread,
Apr 25, 2016, 6:07:13 PM4/25/16
to web...@googlegroups.com
Have you tested this starter app on mobile? I asked because when I hover over "log in" from a 9 inch tablet or small phone, I see a blank white screen for log in till I start scrolling, I see the other menu one by one. 

Michael Beller

unread,
Apr 25, 2016, 7:27:14 PM4/25/16
to web...@googlegroups.com
Yes - thanks.  I knew about that bug, just fixed it.  The background and font were both white.  Can you check now?

On Mon, Apr 25, 2016 at 6:07 PM, Ron Chatterjee <achatte...@gmail.com> wrote:
Have you tested this starter app on mobile. When I hover over "log in" from a 9 inch tablet or small phone, I see a blank white screen for log in till I start scrolling, I see the other menu one by one. 

Antonio Salazar

unread,
Apr 27, 2016, 11:35:26 AM4/27/16
to web2py-users
The login menu dropdown also becomes white on white on small screen sizes.
Looks really nice on those screens, though.

Michael Beller

unread,
Apr 27, 2016, 1:07:01 PM4/27/16
to web...@googlegroups.com
It was fixed in the repo, I just updated the demo site - can you try again?
Reply all
Reply to author
Forward
0 new messages