#pocoo

/

      • Y0Gi
        well, there is actually very few AJAXy stuff going on and there is no public API. there are some endpoints/routes that deliver JSON instead of HTML, though.
      • then again, almost everything that listens on POST, PUT and DELETE basically is a REST API.
      • apart from the authentication being cookie-based maybe. but that stuff is orthogonal and can probably adjusted to accept header-based authentication as well.
      • in general, blueprints are ways to structure your app
      • some can provide HTML endpoints, others a REST API, or you can mix as you see fit.
      • you might want to think of a blueprint as a description of and functionality for a resource.
      • acmehendel
        Yes, I like this idea of blueprints. At least your explantion of it much better than the docs
      • Y0Gi
        so you can put all relevant models, (internal) service methods, view endpoints, HTML templates, static files etc. together that belong to a certain functionality, say, blog posts.
      • acmehendel
        although the flask docs are clearer than django docs which I found to be downright awful
      • Y0Gi
        then again, blueprints can be used differently, maybe only to add a few things like a plugin.
      • acmehendel
        Yes, thats the impression I was getting about blueprints reading through your code
      • like a plugin for the web app...
      • in which case the flask code can be written in such a way to serve as a web framework that accepts plugins
      • much like wordpress does with php
      • or whatever that php framework is used for wordpress
      • DLSteve
        oh wp is it's own mess.
      • acmehendel
        why hasnt anyone written a cleaner alternative in flask ? :p
      • DLSteve
        Super easy too.
      • Blog that is.
      • Y0Gi
        there are some edge cases, too. for example, it makes sense to create a blueprint for every forum/bbs "resource" like category, topic, and post. in a board-only app, this might work, but in my case I have a single "board" blueprint that has all view functions in a single file (views.py), but at least separate modules in a "models" sub-package. there is some discussion going on in the GitHub issue tracker for F
      • Not-b880
        [02pygments-main] 07tshatch pushed 035 commits to 03default [+2/-0/±4] 13https://bitbucket.org/birkenfeld/pygments-mai...
      • [02pygments-main] 07Corbin Simpson <cds@corbinsimpson.com>; 03ca94ffa - Add Monte lexer.
      • [02pygments-main] 07Corbin Simpson <cds@corbinsimpson.com>; 03c695440 - Add _ to number literals.
      • [02pygments-main] 07Tim Hatch <tim@timhatch.com>; 0388a41fc - Normalize quotes, add example file for Monte
      • Y0Gi
        lask if "nested" blueprints can be done, but I'm under the impression that this might do more harm than good ...
      • Not-b880
        [02pygments-main] 07Tim Hatch <tim@timhatch.com>; 0386d3946 - Update Monte lexer, improve test.
      • [02pygments-main] 07Tim Hatch <tim@timhatch.com>; 03810698d - Merged in MostAwesomeDude/pygments-main (pull request #592)
      • acmehendel
        yeah, nested blueprints sound very messy
      • and i think unnecessry
      • sounds like it would eventually turn in to a legacy code nightmare
      • Y0Gi
        the idea with that application for me is that I have a somewhat clear structure of components. and if I want to create "just" a forum, I can copy the tree, kick out all blueprints I don't want, and do some final cleanup.
      • acmehendel
        thats one of the things i hate about django, the multilayers to the code which I think is really just a coverup for legacy code that no one wants to maintain
      • Y0Gi
        even though the separation is quite good, there are some links between blueprints (mostly in - common - templates like a header with information about the current user) that violate it.
      • acmehendel
        i think one of the attractions for wordpress is how so many hosting services make it seem that wordpress is a 'self installing' app. anyone in IT with a half a brain who is honest knows thats not the case
      • Y0Gi
        as you might have seen, the application.py basically descides which blueprints are activated. so some are used for party apps, some for admin mode, and some have to be available in both.
      • acmehendel
        yes
      • ajw0100 has quit
      • Y0Gi
        once people can drop docker images on shared hosting like PHP files, things might change ;)
      • acmehendel
        thats seems to be why docker is so popular, to protect php's file level object permissions from everyone who uses it
      • Y0Gi
        heh
      • acmehendel
        there is a multi-threaded version of flask I think to write something in that would make for a fantastic web app framework that would be tough to beat
      • DLSteve
        I just use VMs.
      • nickjj
        i've been using docker for about 18 months
      • Y0Gi
        so, don't worry: finding out how to actually structure a Flask app for your use case is something that might take years, and you still might be unsure about it ;)
      • acmehendel
        forgot the name of it....I think multi-threaded may be the wrong label
      • DLSteve
        You can use something like gunicorn or uwsgi that is multi threaded.
      • acmehendel
        yeah, but the webapp itself would still remain single threaded
      • Y0Gi
        there is the Falcon framework that aims to be very fast and suitable for REST APIs. then again, I found it lacking in some departments and will wait a while before I take another look at it.
      • DLSteve
        right but the webserver spawns workers that handle requests. For long running tasks you would use something like Celery and a task broker.
      • acmehendel
        gunicorn would launch seperate flask apps which gives the appearance of a multi threaded web app when in reality its the manager thats 'multi threaded'
      • Y0Gi
        in case you're looking for more speed ;)
      • puhrez joined the channel
      • acmehendel
        yeah, but thats why that mutli-threaded version of flask is ideal, because it works in place of celery and all those other python things.
      • I think it is based on twisted.
      • not necessarily more speed...but the novelty :)
      • DLSteve
        asyncio is bult into Python 3.5.
      • acmehendel
        or maybe to put it better, to be prepared for growth from the start
      • :p
      • ah, right. I think twisted is not as accomodating for 3.5 yet
      • DLSteve
        Eh, I just throw hardware at my problems lol.
      • Better off using Java if you need speed.
      • acmehendel throws up a little
      • acmehendel
        at the thought of java
      • DLSteve
        It sucks, but it's fast when used correctly. There is a reason a good portion of Amazon and Googles infrastructure runs on Java.
      • acmehendel
        yeah, thats mostly to maintain legacy code
      • not because its better
      • DLSteve
        I also never found it that bad but my first languages were C/Objective-C
      • acmehendel
        mine was perl :p
      • DLSteve
        I have seen perl once. I was a 20 year old internal web application. Took one look and decided to rewrite it in Python lol.
      • *it was
      • acmehendel
        Y0Gi if its all the same to you, I'm going to use your code as a starting point for what i have in mind. If I think it might be remotely useful in any way I'll put what I have up on my github and let you know.
      • DLSteve
        Nothing aginst Perl, just didn't have time to decipher the syntax.
      • acmehendel
        the jump from perl to python is not that big a stretch. they share a lot of their underpinnings
      • in implementation and philosopohy
      • philosophy
      • however the biggest thorn in my side with python has been the 'batteries included'philosophy which is not necessarily the case, b) when it is implemented can be archaic to try to find and figure out.
      • DLSteve
        I had to rewrite the application anyway. The security on it was... interesting. and that is not a good thing when it is a web interface for most of the network switches in the company.
      • acmehendel
        yes, perl did have security issues, mainly because of its loose object oriented orientation.
      • in that case python is a better choice from that perspective. at least in my opinion
      • DLSteve
        Oh this was not Perls fault. It was things like having 24 hour sessions with no logout mechanism.
      • tachyondecay joined the channel
      • acmehendel
        Y0Gi how are you building the database? The database.py file is very small and I dont see anywhere else for anything related to building up the database
      • Y0Gi
        acmehendel: feel free to use my code, be it the actual code or the ideas, organization etc.
      • acmehendel
        hopefully I will write something that would you would feel comfortable and compelled to work on with me :)
      • Y0Gi
        if you can make something work with it or gain some insights, it was worth putting it on GitHub :)
      • DLSteve
        what is in the database.py?
      • Y0Gi
        this specific project already is a beast and has, as mentioned, some edges I'm not happy with. so actually providing a release schedule and a safe upgrade path might become a maintenance nightmare with all the flexibility I take for myself right now ;)
      • F2Knight joined the channel
      • `database.py` contains just the app wrapper provided by Flask-SQLAlchemy. it is initalized in `application.py` when the app has been created.
      • acmehendel
        i can imagine.
      • Y0Gi
        the actual models are in the various blueprints.
      • acmehendel
        still, the precision german engineering definitely shines through :p
      • tachyondecay
        Typically you create the actual database through external commands
      • acmehendel
        and I genuinely mean that
      • tachyondecay
        And if you're using SQLalchemy's declarative model, it builds the database for you from the models
      • Y0Gi
        I create all tables (or the new ones missing on some DB server) by spinning up a shell and issuing `db.create_all()`, that's it ;)
      • acmehendel
        oh right, the models.py
      • Y0Gi
        but no migration/Alembic stuff so far (hence: upgrade nightmare for anybody running that besides me)
      • qtaraki_ joined the channel
      • acmehendel: hahah, thanks.
      • tachyondecay
        Hehehe, I know what you mean
      • Migration is way too much trouble when your schema isn't stable
      • Y0Gi
        some other apps of mine provide some initdb/createdb command in manage.py via Flask-Script, but this one doesn't, I think.
      • acmehendel
        ok, so thats why no alembic
      • Y0Gi
        but then again, the initial bootstrapping and setup requires some work on the shell anyway (and for things that don't have an admin UI yet), so that's no biggie.
      • well, I'm not familiar with Alembic, but it seems impressive.
      • the main reason is I don't want to pollute the repo with migration files with are basically outdated the moment after I have run them :/
      • acmehendel
        from what I see alembic seems to handle migration
      • I cant say how well it does so though
      • Y0Gi
        but yeah, that's the non OSS-friendly part of the project ;)
      • I think it currently has 68 database tables.
      • oh wait, that's with custom stuff and tables of the tournament system that sill is in PHP, but is getting slowly absorbed.
      • acmehendel
        ah, ok so some of the stuff is still in php style tables
      • qtaraki_ has quit
      • zepolen joined the channel
      • Y0Gi
        ok, more like 45 tables.
      • nothing of that is in the open source project
      • but the internal fork contains wrappers around some of the tables as well as a new implementation with clean models and tables
      • puhrez has quit
      • as much as I'd like to port and clean and improve that PHP thing, it still managed to deal with thousands of local users and still provide decent response times while sporting some complex features. but ask me next year or so ;)
      • DLSteve
        Mine has like 5, but that is just for the user/permission system.
      • zepolen has quit
      • puhrez joined the channel
      • hobo has quit
      • acmehendel
        Sorry if you covered this already but is there a centralized or automated way you are setting env?
      • I see the config/env directory
      • manage.py
      • Not-b880
        [02pygments-main] 07tshatch pushed 033 commits to 03default [+2/-0/±2] 13https://bitbucket.org/birkenfeld/pygments-mai...
      • [02pygments-main] 07Mike Elson <mike.elson@gmail.com>; 034d4b45f - Added RNC lexer and sample file
      • [02pygments-main] 07Tim Hatch <tim@timhatch.com>; 03917220f - Fixes for rnc lexer
      • [02pygments-main] 07Tim Hatch <tim@timhatch.com>; 03319bc96 - Merge mjem/pygments-main (Pull Request #588)
      • DLSteve
        salt/ansible/fabric are good for deployment automation.
      • Y0Gi
        basically, ENV=<some name from config/env> manage.py runserver
      • acmehendel
        so with uwsgi, i wont need to launch wsgi using gunicorn? and I wouldnt need supervisor to launch gunicorn which launches wsgi? :p
      • Y0Gi
        the uwsgi config's relevant line basically is: `eval = import serve; application = serve.app`, with the venv being set as well
      • uwsgi is, for example, provided by nginx, so nginx is the supervisor
      • but gunicorn + supervisord should also work well
      • acmehendel
        I think I like this better, less stuff to maintain https://uwsgi-docs.readthedocs.io/en/latest/WSG...
      • Y0Gi
        after all, those WSGI servers want a WSGI-compatible application object, that's it.
      • tomkralidis joined the channel
      • acmehendel
        but how is uwsgi spawned though?
      • DLSteve
        I just use systemd for gunicorn and nginx >.>
      • acmehendel
        yeah, the thing for me though is I am running gunicorn in the venv
      • because the system wide python is not 3.5
      • DLSteve
        I am as well
      • acmehendel
        so I'm using supervisor to spawn gunicorn
      • Y0Gi
        acmehendel: systemd or some other init thing keeps nginx alive, and nginx provides uwsgi similar to how Apache HTTPd provides mod_python or mod_wsgi.
      • acmehendel
        but I would rather use uswgi
      • Y0Gi
        if you have a sysadmin that would keep things in shape for you, go with his decision ;)
      • acmehendel
        right, but how does this line work: uwsgi --socket 127.0.0.1:3031 --wsgi-file foobar.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191