Tag Archives: Python

Python utility for managing a cluster of database servers

I’m still working on some code to manage replication on a cluster of Banana Pi MySQL servers. It’s coming on quite well. I’ve got to a point where I can

  • demote a master,
  • promote another master,
  • add servers to the cluster,
  • copy the database to another server.

I’ve published the code on Github at https://github.com/Pyplate/db-cluster-utils.  There’s information on how to use DB Cluster Utils on my Banana Pi site at http://banoffeepiserver.com/mysql/python-database-cluster-management-utility/.

I was contacted earlier today by the owner of tinyonestore.com, asking if I would mind if they linked to my site from their site. I guess they wanted to check that they weren’t going to swamp my site with traffic, but that hasn’t been a problem so far. Looks like they have some interesting products like the Radxa Rock Pro.


A new version of Pyplate CMS is now available

It’s a long time since I posted here. I’ve been working on Pyplate, my Python CMS. Over the last few months I’ve made a lot of changes to the UI. Most site administration tasks can now be done via the Pyplate UI.

I’ve modified Pyplate to use the WSGI server interface instead of CGI. With CGI, the Python interpreter has to be loaded everytime a script is executed. Using WSGI means that a Python interpreter is kept in memory between requests. When a script needs to be executed it can run immediately because the interpreter has already been loaded. This has no effect on page load times of static pages, but dynamic pages are served much more quickly. The difference is huge.

There are different implementations of WSGI for different servers. In order to use WSGI with Apache, libapache2-mod-wsgi must be installed. This ensures that a python interpreter is loaded into each Apache thread. The downside of this is that each thread takes up more memory.

With Nginx, people often use set up a uWSGI server.  Nginx must be configured to pass requests for scripted pages to the uWSGI server. The uWSGI server executes a script, and returns the result to Nginx, which then passes the page back to the user who requested it.

I’ve also implemented a very simple webserver based on the WSGI class in the Python library. This server can handles static pages. If a requested file can’t be found, the server hands the request to Pyplate.  Pyplate generates the page, and returns it to the server.

The Python server is not very fast. It’s slower than Apache, and enabling page caching doesn’t make much difference. On the upside, it is very easy to set up.

I’ve added some security patches to Pyplate. A security token is embedded in each form generated by Pyplate. When a user clicks on the submit button, the security token is sent to the server with the POST request, and validated. I’ve also made some changes to the cookie code to make it harder to steal user’s cookies.

User information is now stored more securely. A salt is used to encrypt each user’s password, and a different salt is generated for each user.

I think Pyplate has come a very long way. It’s now a much more complete, more usable CMS. It’s still pretty simple, and small enough to run quickly.

What’s next? I’m working on a site built on a Banana Pi cluster. I’m building it using Pyplate, and it’s going to be based on my Raspberry Pi site. I may add a few more articles to my Raspberry Pi site, but eventually I plan to get back to working on Pyplate.



Beta testing continues…

I announced the start of Pyplate beta testing on the Raspberry Pi forum.

I’ve had a little feedback already, and so far it’s been mostly positive. There was an issue with some scripts that didn’t have the right permissions, but I’ve fixed that now.

I’ve also posted an article on my Raspberry Pi site about installing Pyplate on a Pi.

I’ve set up an installation script for my CMS

I’ve written an installation script to make it easier for people to download and install my CMS. The script generates a temporary password, so I’ve also added a page in the admin area to set a new admin username and password. At the moment it’s only possible to store credentials for one user. In future versions I’ll add support for multiple users, and instead of storing the credentials in a text file, I’ll store them in the database.

I’ve been working on setting up a forum so that people can ask questions about the software. I installed MyBB with SQLite, but it doesn’t work very smoothly. I’ve looked for information on the MyBB forum, and it seems that it doesn’t work well with SQLite. Aparently it’s because PHP doesn’t work well with SQLite. So I need to reinstall MyBB with MySQL.

Currently posts need to be written in raw HTML. I’ve experimented with Tiny MCE, a Javascript editor that’s used in other CMSs like WordPress. Using the demo version I had problems with escaping HTML characters, so I need to figure out how to fix that.

After that, I need to Work out some licensing stuff. GPL, MIT or BSD? There are other licenses, but these are the main contenders.

Finally I need to update the settings in my reverse proxy so that I can get my new site on line. Then I can begin beta testing my CMS.

Progress with my Python CMS

I’m in the process of setting up a web site dedicated to myPython CMS.  I’ve setup the software (Apache 2.4.6, SQLite and my CMS) , built a theme, and I’ve written several pages describing how the CMS works. Every CMS needs a forum where users can ask questions, so I’ve also installed myBB and set up a forum.

The site isn’t ready to go live yet. I need to write some how-to documents, and a few pages explaining how to set up the CMS and use its admin area. I also need to do a fair amount of work on the CMS before it’s ready for release.

It may be several months bfore I can release a beta version, and two/three months after that until I can release a completed version of the CMS. This is a big problem because it will be months before I make any money from my new site. I’m probably going to need to use a crowd funding campaign to raise money so that I can continue to develop this software.

Screenshots of my web UI

These screen shots are of the back end of my CMS:

Status page

Status page

List posts

List posts

Add a page

Add a page

Add a category

Add a category

Site settings

Site settings

Change the theme

Change the theme

This UI is still in development, so some debug messages are visible in some of these screen shots.


Support for different layouts added to my CMS

I’ve spent the last few days working on the CMS that powers my Raspberry Pi site.  I’ve fixed some bugs in the XML handling code, so now I don’t have to edit the XML files manually when I add new pages.

I’ve also developed a simple API that allows me to call a Python function to print the sidebar and other page furniture.   I’ve changed the layout a bit, so I hope everyone likes the changes.

I’ve implemented a system for defining layouts like this:

<div id="container">
<div id="midpage">
</div><!-- midpage -->
</div><!-- end_container -->
<script src="/js/jquery-1.7.2.min.js"></script>
<script src="/js/lightbox.min.js"></script>

The API that I developed is used to fill in the parts of the layout in curly brackets.

Most of the site settings can now be edited from within the CMS’s backend, although there’s still a lot of UI development work ahead of me.

I’m hoping to release a beta version of my CMS early in the new year.