[PY 3.6+] Trinity-py - A flask based CMS for Python 3.6+

Status
Not open for further replies.

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
View the origin of this project's development:

k8I15Gh.png


Objective of Trinity 3
The objective of Trinity 3 is to completely annihilate its predecessor, Trinity, in both performance and code practice.
Simply said, Trinity 3 aims to offer a completely automated way of setting up a live mysql website with python easily under 5 minutes, without the need of the end user having to install third party modules! Instead, Trinity 3 automatically installs required modules via pip, and automatically creates required database tables. Just fill out settings.py and you're allset.

Technologies and Modules used
All required modules will be automatically installed by Trinity 3. (unlike its predecessor)
  • Python 3.6.1 (General code base)
  • Flask (Web module for python)
  • PyMysql (Database module for python)
  • Passlib (Password encryption & decryption module for python)
  • Gevent (By default, trinity uses gevent as an wsgi. You can use any, though.)

What makes Trinity 3 shine
  • The ability to automatically install required modules
  • The ability to quickly render html templates
  • The ability to automatically create all database tables
  • The ability to run trinity on a custom port. (example )
  • Clean and easy mvc structuring.
  • Easy to further develop upon.
Common Questions
Q: How does trinity go about templating?
A: Trinity uses flask's built in jinja2 templating system. Docs:

Q: How are passwords encrypted and decrypted?
A: I decided to go with passlib, you can learn more about it:

Q: Does trinity work across multiple platforms?
A: Yes, python itself is very cross platform, but i made sure to code the cms to work on linux and windows in specific.

Q: Have you experienced any bugs, crashes or memory leaks yet?
A: I've been using this very cms on me for awhile, no problems so far.

Showcase

47500af47d254a2ba3ef4f04fa4b84ff.png

a6bb07f739974ae8b5bff748b1861c38.png

8c36a0e9d5eb4c3aa23806032e39f341.png

d60c4a17506e416f9ba636fcd1e00f1b.png

Thanks @Markshall for the barebone css template :p

Download
All of the code is hosted over at:
Report bugs if there's any, and i'll try to push a fix for it when i can.

Installation
  1. Download Python 3.6.1 over at
  2. Go into cmd, type "python" make sure it works otherwise you need to set it as a path variable (annoying)
  3. Configure build/settings.py
  4. Run python trinity_server.py, everything from there on is automated.
  5. Reboot Trinity after setup is complete (bug)
Cheers!

Updates have been pushed to:
 
Last edited:

LeChris

John 15:18
Sep 30, 2013
2,786
1,395
Ah, you released your personal portfolio :p

I remember playing on the admin panel with it in the past
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
Ah, you released your personal portfolio :p

I remember playing on the admin panel with it in the past
Yup yup, i must say this project ended up maturing pretty well.
Much more faster, modular and neater.

Throw back
M6xDylS.png


Now
3aaUNy1.png
 
Last edited:

TheRealMoonman

I eat babies
Sep 30, 2014
360
74
Probably one of the most unique development projects ive seen on devbest probably, even better. it actually got released lmao.
Fantastic job.
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
Probably one of the most unique development projects ive seen on devbest probably, even better. it actually got released lmao.
Fantastic job.
Thanks man!
There's more to come, I eventually wanna get around using python's open and write functions to edit html from a dedicated admin panel, but that's when i actually get the motivation to get back into the grind again, though.
 

TheRealMoonman

I eat babies
Sep 30, 2014
360
74
Thanks man!
There's more to come, I eventually wanna get around using python's open and write functions to edit html from a dedicated admin panel, but that's when i actually get the motivation to get back into the grind again, though.
I'm looking forward to seeing it, its definitely a very useful language, have you tried Django?
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
Quick Update
Setup is now 100% automated, the user no longer needs to edit build/settings.py, instead trinity will take the user through a process of data gathering then writing that data into the configuration file via python's open() function, when build/settings.py is not found.
3646cc7f50314e2693798122e11e8f5e.png

as always, the code's been updated over at .
 
Working on Trinity Admin
Started doing some work on trinity's admin panel today, mainly because i stumbled across this really great admin theme
4db3986c0e304e3583c27c0f02a8b561.png


Login model completely rewritten, removed nesting code and implemented more object oriented approaches.
5de24625aa674b89bfc013dcf3268d41.png


(login controller:)
b4db8b2eea69457393de10ccc74357ef.png


I've also re-written most of my core engine to support flask-socketio
777d4cbe5430420294d205bc76c65506.png

54c44f73cbec4576b4b3e2fa2c252e9a.png


Updates aren't pushed yet, but will be pushed by the end of this week when it's all stable
 
Conclusion for the night
Off for the night, the general layout of the admin theme is now finished with some inspiration from @HighlySkilledHabbo's .
It actually turned out to be a nice mix, here's a before and after:
before:
4db3986c0e304e3583c27c0f02a8b561.png


after:
189d1adeb7814469803c867877d42db3.png


3e05e79762db43b48a381e477d3389d1.png

7dde2a41986c492bb1d3028678c5dac7.png

ee212eaf69174105a2ab358cc9775a8e.png

that's all for now, more to come this weekend.
 

Marcel

You're the guy who stole my car
Jul 17, 2015
466
208
this made me nut, seems like you've become extremely professional whilst i was gone, good job!
 
this made me nut, seems like you've become extremely professional whilst i was gone, good job!
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
this made me nut, seems like you've become extremely professional whilst i was gone, good job!
Thanks! Yeah i've been trying to become more pro with python, my goal is to master it, learn all the correct practices, then move on to another language and grind it for awhile like i did with python.
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Thanks! Yeah i've been trying to become more pro with python, my goal is to master it, learn all the correct practices, then move on to another language and grind it for awhile like i did with python.
That's the thing with programming languages though, you never can fully master it. That's what makes it great.

You're making great progress.
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
Nightly Update
I've completely rewritten the database connector into an object oriented class, and added the option to ping mysql every x seconds because i found that sometimes if i left the console server online for 2 days+ it'd say "mysql sever has gone away".
I'm not too worried about it though because you'll most likely put trinity into a virtual env if you're making your site live on a webhost, but you can still keep it open on a vps like a habbo emulator for example, if you want.
b4fba5c82326446da08f6e87802033b8.png

(validate_connection() and keep_connection_alive() are kept outside the handler because of how Trinity's core is designed)

Code:
import time
import pymysql
from build import settings
import threading


# KeepAlive: [True | False]
# Pings MySQL every x seconds
KeepAlive = dict(
    Enabled=True,
    Duration=60
)


class _Handler:
    # Create database instance
    def __init__(self):
        try:
            self.conn = pymysql.connect(
                settings.mysql['db_host'],
                settings.mysql['db_user'],
                settings.mysql['db_pass'],
                settings.mysql['db_name']
            )
        except Exception as error:
            self.throw_connection_failed_error(str(error))

    def throw_connection_failed_error(self, error):
        print(' [NOTICE] Database connection failed: {}').format(error)
        exit()


def validate_connection():
    if _Handler().conn.open is False:
        print(' [NOTICE] Database connection failed.')
    else:
        print(' * Database connected successfully!')


def keep_connection_alive():
    while True:
        time.sleep(KeepAlive['Duration'])
        try:
            _Handler().conn.ping()
            print(' * KeepAlive -> Pinged MySQL')
        except(Exception, pymysql.OperationalError):
            print(' [NOTICE] Database connection died, reconnecting..')
            _Handler()
_Handler()

if KeepAlive['Enabled'] is True:
    t = threading.Thread(target=keep_connection_alive)
    t.start()

instance = _Handler().conn.cursor()
_Handler().conn.autocommit(True)

I'm not gonna put it on github untill i've finished some other things, that's all for now.

 
Started more work on the admin panel today, currently working on the configuration section.
5a0fc2ca1ef9486a9aa8bf55c69c30db.png

0fe424bf816e45138f6f90854ea073ba.png

8dac99a6629c49e6a3145f159ff7bc0c.png

2dffd0bcfe7547c3864ea77f25079d1c.png

 
All progress has been updated on
  • All error filters, done
  • Rewritten database connector
  • Admin dashboard
  • Multiple template support
  • SocketIO integration
  • Rewritten core
  • Config file generator

a58ca98b3422465683390a8065f15f44.png

12504e8c85ce4d0db14fdbe50d4c488a.png

d8f48e5c5287478eaa198f31aea04390.png


570e5afcf9cf47b8a0a6b2b5c5486932.png
 

Ubbel

New Member
Nov 15, 2016
3
1
Oh, this looks pretty good man, the Code os cleaner and the design is good
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
Oh, this looks pretty good man, the Code os cleaner and the design is good
Cheers man, i recently re-wrote it with pep8 standards
Updated at:

Old branch is still available
kObv7ZESR0mOaC0UcLya2Q.png
 
Status
Not open for further replies.

Users who are viewing this thread

Top