Book Image

Hands-On Enterprise Application Development with Python

By : Saurabh Badhwar
Book Image

Hands-On Enterprise Application Development with Python

By: Saurabh Badhwar

Overview of this book

Dynamically typed languages like Python are continuously improving. With the addition of exciting new features and a wide selection of modern libraries and frameworks, Python has emerged as an ideal language for developing enterprise applications. Hands-On Enterprise Application Development with Python will show you how to build effective applications that are stable, secure, and easily scalable. The book is a detailed guide to building an end-to-end enterprise-grade application in Python. You will learn how to effectively implement Python features and design patterns that will positively impact your application lifecycle. The book also covers advanced concurrency techniques that will help you build a RESTful application with an optimized frontend. Given that security and stability are the foundation for an enterprise application, you’ll be trained on effective testing, performance analysis, and security practices, and understand how to embed them in your codebase during the initial phase. You’ll also be guided in how to move on from a monolithic architecture to one that is service oriented, leveraging microservices and serverless deployment techniques. By the end of the book, you will have become proficient at building efficient enterprise applications in Python.
Table of Contents (24 chapters)
Title Page
Copyright and Credits
About Packt
Contributors
Preface
Index

Preface

Python is a dynamically typed, interpreted language that facilitates the rapid building of applications in various areas of software development, including AI, desktop, and web applications.

With recent advancements in the Python ecosystem and the availability of a huge number of libraries that support high re-usability and enable the compilation of modular code, Python can be used to build applications that can solve an organization's problems. These applications can be developed in short timeframes and, if developed carefully, can allow them to be scaled in a manner that solves the needs of an organization.

Python version 3.7 brings with it several improvements and new features that make application development a breeze. Along with new features, improvements in the language's performance make it a good choice for building scalable, mission-critical applications powered by a choice of different runtimes based on the organization's needs.

Who this book is for

An enterprise application is a critical application that aims to solve the specific business needs of an organization. The requirements of an enterprise application differ greatly from those that are usually needed by an individual. These applications are supposed to provide high performance and scalability to enable the increasing everyday needs of an organization.

Keeping this in mind, this book is intended for developers who have an intermediate knowledge of coding in Python and are willing to dive deeper into building applications that can be scaled up, based on the needs of the organization. The book provides several examples that can be executed on Python 3.7 running on Linux-based distributions, but which also work on other operating systems.

To make the best use of this book, you must have a basic understanding of fundamental operating system concepts, such as process management and multithreading. Beyond this, a basic working knowledge of database systems may be beneficial, although not mandatory.

Developers who are familiar with the different aspects of building applications in Python can get to learn about the tools and techniques that can help them build scalable applications and provide them with an idea of the enterprise application development approach.

What this book covers

This book contains 16 chapters organized into roughly 4 parts: an introduction to Python in enterprises; the testing, performance, and security of enterprise applications; the shift toward microservices; and enterprise application integration.

The first part covers the utilization of Python in enterprise application development and deals with the various aspects related to building a performant and scalable application with Python. This first part consists of seven chapters.

Chapter 1, Using Python for Enterprise Application Development, introduces the capabilities of Python that make it a rich language when it comes to developing enterprise applications and provides information about the changes that have happened in the Python ecosystem and how they have helped in boosting the utilization of Python within the community. 

Chapter 2, Design Patterns – Making a Choice, explains the importance of design patterns in the development of applications and covers some of the commonly used design patterns in application development and how they can be implemented in Python. This chapter also provides guidance on how to choose which design patterns to use while developing the application.

Chapter 3, Building for Large-Scale Data Operations, covers how to build enterprise applications that can handle a large number of concurrent data operations while maintaining the consistency of data. This chapter takes a look at how the data models are developed to allow for scalability and performance and then goes on to provide information about how to make database operations efficient.

Chapter 4Dealing with Concurrency, introduces us to the different ways in which we can improve the ability of our application to deal with concurrent workloads. For this, the chapter introduces us to various techniques in Python related to the implementation of multiprocessing and multithreading and how we can use them to boost the concurrency-managing capability of the application.

 

Chapter 5Building for Large-Scale Request Handling, introduces us to the ways in which we can make our application scale well when it comes to a high number of concurrent users while keeping the response times adequate. We will also cover the different techniques related to maximizing the output from multithreading, utilizing asynchronous operations, and so on.

 Chapter 6Building BugZot, makes use of what we have learned in the preceding chapters to come up with an example application known as BugZot, which provides our dummy organization, Omega Corporation, with a bug tracking system. While building this application, we get to implement the techniques related to building efficient database models, implementing concurrency, and handling the uploading of large files.

Chapter 7Building Optimized Frontends, takes us through the importance of building application frontends that are responsive and light on resources. This chapter covers various techniques related to the optimization of web-based frontends and how to provide an experience that keeps the user engaged with the application.

With this, we enter the second part of the book, which consists of three chapters aimed at improving the delivery aspects of the application.

Chapter 8Writing Testable Code, focuses on the points related to the importance of writing code that can be tested easily and how it helps in delivering applications that are stable and robust when deployed in production. This chapter introduces us to a Python-based testing framework that can be used to write unit tests and integration tests and also covers the aspects of automated testing of the code.

Chapter 9Profiling Application for Performance, introduces us to the tools and techniques that we, as developers, can use to build performance profiling into the core of the application to understand the performance implications of running the applications and allow us to uncover bottlenecks in production.

Chapter 10Securing Your Applications, covers the different attack vectors that are used by attackers to compromise enterprise data security and then helps us to understand the basics of how we can avoid introducing vulnerabilities into our applications.

The third part of the book includes the following chapters that cover the architecture of application development.

 

Chapter 11Taking the Microservices Approach, takes us on a journey of developing applications based on microservice architecture. In this chapter, we will take a look at what exactly microservice architecture is and the advantages it provides. We will then move on to understanding the different components that power microservice architecture and conclude by building a small application based on microservice principles.

Chapter 12Testing and Tracing in Microservices, goes into how the move to microservices has changed the way we approach application testing, which now comprises the interaction of several small services instead of large components. We take a look at additional steps that might be required in making sure the applications work in the manner they are expected to, before we dive into another concept that allows us to trace the flow of the request in our application as it passes through different services.

Chapter 13Going Serverless, introduces us to yet another method of building our applications where we, as developers, do not need to care about where the application will run and how it will scale. In this chapter, we will learn about how we can divide our application into functions that can run without our supervision and execute based on a set of events.

Chapter 14Deploying to the Cloud, introduces us to the different cloud deployment strategies and how they can help us while also providing us with guidance about which type of cloud deployment to choose, based on the requirements of the organization.

The fourth and final part of the book includes the following chapters, which introduce us to the need to integrate different applications inside the enterprise.

Chapter 15Enterprise Application Integration and their Patterns, takes us through an introduction to why enterprise application integration is necessary and how it was achieved in days gone by, before diving into the concepts of using middleware and an enterprise service bus. This chapter concludes with a discussion of various EAI patterns that are in use.

Chapter 16Microservices and Enterprise Application Integration, takes us through the differences that the move toward microservices has introduced to the EAI landscape. In this chapter, we will take a look at how the modern concepts of microservices have changed how application integration was achieved in the past and how we can plan ahead for integrating different applications in this modern age. 

To get the most out of this book

Other than being familiar with programming in general, no particular specialist knowledge is expected in order to be able to take advantage of this book.

Odoo is built using Python, so it is a good idea to have a sound knowledge of the language. We also choose to run Odoo in an Ubuntu host (a popular cloud hosting option) and will do some work on the command line, so some familiarity will be beneficial.

To get the most out of this book, we recommend that you find complementary readings on the Python programming language, Ubuntu/Debian Linux operating system, and the PostgreSQL database.

Although we will run Odoo in an Ubuntu host, we will also provide guidance on how to set up our development environment in a Windows system with the help of VirtualBox. Of course, working from an Ubuntu/Debian system is also a possibility.

All the required software is freely available, and instructions on where to find it will be given.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Enterprise-Application-Development-with-Python. We also have other code bundles from our rich catalog of books and videos available athttps://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Beyond these three packages, the reader will also require the sqlalchemy package, which provides the ORM we will be using throughout the chapter, and psycopg2, which provides postgres database bindings to allow sqlalchemy to connect to postgres."

A block of code is set as follows:

username = request.args.get('username')
email = request.args.get('email')
password = request.args.get('password')
user_record = User(username=username, email=email, password=password)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

username = request.args.get('username')
email = request.args.get('email')
password = request.args.get('password')
user_record = User(username=username, email=email, password=password)

Any command-line input or output is written as follows:

mkdir ch3 && cd ch3
virtualenv --python=python3 .
source bin/activate
pip install sqlalchemy psycopg2

Bold: Indicates a new term, an important word, or words that you see on screen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "In the web client, access the Apps top menu and select the Update Apps List menu option."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit authors.packt.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.