Book Image

Python 3 Web Development Beginner's Guide

By : Michel Anders
Book Image

Python 3 Web Development Beginner's Guide

By: Michel Anders

Overview of this book

<p>Building your own Python web applications provides you with the opportunity to have great functionality, with no restrictions. However, creating web applications with Python is not straightforward. Coupled with learning a new skill of developing web applications, you would normally have to learn how to work with a framework as well.</p> <p><em>Python 3 Web Development Beginner's Guide</em> shows you how to independently build your own web application that is easy to use, performs smoothly, and is themed to your taste – all without having to learn another web framework.</p> <p>Web development can take time and is often fiddly to get right. This book will show you how to design and implement a complex program from start to finish. Each chapter looks at a different type of web application, meaning that you will learn about a wide variety of features and how to add them to your custom web application. You will also learn to implement jQuery into your web application to give it extra functionality. By using the right combination of a wide range of tools, you can have a fully functional, complex web application up and running in no time.</p>
Table of Contents (19 chapters)
Python 3 Web Development Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – implementing access control


This scenario is implemented in access1.py:

Note

Note: In the code distributed with this chapter and the following one, the logon class is not only initialized with an admin user (with admin as a password) but with the following three name/password combinations: eve/eve, john/john, and mike/mike.

If your run this application and point your browser to http://localhost:8080, you are presented with a list of accounts. If you have logged in as either john or mike—both sales persons—you can only alter the accounts owned by each of them. If however, you log in as eve, the sales manager, you can alter the information in all accounts.

What just happened?

The application is simple enough and follows a familiar pattern. The relevant definitions are shown here:

Chapter9/access1.py

from permissions1 import isallowed

class Entity(AbstractEntity):
	database = db
	
	def update(self,**kw):
		if isallowed('update', self, logon.checkauth(),
						self.getUser(...