Article
· Jan 30, 2021 3m read

Making a blog using Python + IRIS Globals

Making a blog using Python + IRIS Globals

Since I started to use internet (late 90's), I always had a CMS (content management system) present to make easier post
any information in a blog, social media or even an enterprise page. And later years putting all my code into github I
used to document it on a markdown file. Observing how easy could be persisting data into Intersystems IRIS with the
Native API I decided to make this application and force myself to forget a little of SQL and stay open to key-value database
model.

picture

What is a blog?

It is the short name of WEB LOG, essentialy a platform that enabled a user to write posts and make then public on a page.

Markdown format?

Markdown is a markup language for creating formatted texts, is easier than HTML and popular in a lot of CMS platforms. e.g:

# Header 1
## Header 2
### Header 3

Will result in:

Header 1

Header 2

Header 3


Whats the advantage to make with IRIS?

Using the IRIS Globals to persist the data from each post each data consult take the advantage of the speed of
IRIS working as a key-value database. If you already have an Iris Instance working at your business, you will not need to
use another technology to make an application like this.

And Python?

Python is one of the most popular programming languages actually. Is a Turing Complete language, with a lot of open-source
libs that can make easy most of development challenges. To integrate python and Iris I have used the IRISNative API.

Database Model Key-Value

My engine works in a way that I cant imagine more simple than that. To persist each post I create a global "^blog", with the
subscript "post", and the next subscript is the post Id. In this global I put the content of the post and finish! Just this,
nothing of create table, index, etc...

^blog("post", "1") = "# post 1 content..."
^blog("post", "2") = "# post 2..."
^blog("post", "3") = "# post 3 markdown content..."

And to render the Markdown on HTML?

Now we can take advantage of the endless python ready to use open-source modules. My choice was the Dash library that easily
render markdown in only one line command =)

import dash_core_components as dcc
import dash
import irisnative

#creating a connection with an IRIS Instance
conn = irisnative.createConnection("host","port","namespace","username","password")
obj_iris = irisnative.createIris(conn)

#getting the content of one post with id 1
content = obj_iris.get("blog", "post", "1")

#creating the dash application
app = dash.Dash(__name__)

#rendering a markdown value
rendered_markdown_in_html = dcc.Markdown(content)

#showing on the page the rendender markdown
app.layout = html.Div([rendered_markdown_in_html])

And to show all posts?

Is possible to iterate over the subscripts of ^blog("post",) and use the same method above to print the rendered markdown
on a page. Have you ever modeled a database and make a form working faster and easier than this? Answer on comments here!

Ok, I dont want to build myself but I want to see working!

Easy! Click here and behold:

http://iris-multimodel-suite.eastus.cloudapp.azure.com/blog-post

Did you enjoy this article and application

This content explains part of my application at the Multimodel Contest. If you like, you can vote in my app: iris-multimodel-suite at
https://openexchange.intersystems.com/contest/current

Discussion (2)0
Log in or sign up to continue