Giter Club home page Giter Club logo

ion-web's Introduction

Ion

Introduction

Ion is an MVC Web Framework meant to be simple and easy to use. No fancy admins or heavyweight architectures.

A simple server infrastructure and a combo of ORM and Template that adds spice to the same old MVC stuff.

Tools

Ion uses VERY proven tools in order to achieve this. It's based on the very stable and mature CherryPy server. What this means is that Ion supports (as does CherryPy) multiple requests at the same time (multi-threaded), WSGI, Plugins and much more.

In the Object-Relational Mapping front, Ion is very well served by Canonical's Storm ORM. Canonical has done a great job in keeping what should be simple, simple. Still you have a LOT of firepower at your fingertips with Storm. Just reading it's tutorial should be enough to start coding. If you don't like Storm, feel free to use any other ORM you like. We won't try to force any tools on you (except cherrypy maybe, lol).

As for the template, I'll admit to being a little selfish. The teams in the company I work for are already VERY used to Django Templates, thus it made a lot of sense for me to use Jinja2, which is a templating engine that looks and feels a lot like Django's. It's REALLY simple to change the templating engine if you'd like to use something else.

Why use Ion?

Why yet another Web Framework?

We also added some cool stuff of our own. Ion features a VERY simple yet featureful controller. This means that you have Routes, Authentication, Event Bus and a lot more at your disposal, any time you need those.

So we'll just start hacking our first controller and template and...

WAIT ONE MINUTE RIGHT THERE! No tests??? What the hell do you think you are doing, sir?

Ok, ok. Calm down, jeez! I'll write the test first. I was going to do it anyway! yeah, right!

Let's write a test for our action. Let's start with a unit (unwired) test:

#I'll use Fudge to mock stuff since I'm doing that in Ion's codebase

render_template = Fake(callable=True).with_args('some_action.html', some="args").returns('Hello World args')

@with_patched_object(controllers.IndexController, "render_template", custom_render_template)
@with_fakes
def test_some_action():
    ctrl = TestController()
    result = ctrl.some_action()

    assert result == "Hello World args"

I'll write a functional (wired) test now, just in case you get nervous:

#retrieving root_dir and config files skipped for brevity
def test_index_controller_index_action():
    server = Server(root_dir)

    server.start('tests/functional/config.ini', non_block=True)

    while not server.status == ServerStatus.Started:
        time.sleep(0.5)

    controller = IndexController()
    controller.server = server
    controller.context = server.context

    content = controller.some_action()

    assert "Hello World args" in content

Do you think I can write the controller code now? Ok, thank you! Here it goes:

class TestController(Controller):
    @route("/something")
    def some_action(self):
        return self.render_template("some_action.html", some="args")

This very simple controller creates a route at http://localhost:8082/something that renders a template called some_action.html with the "some" parameter with value of "args". This means we can use the "some" variable in our template as seen here:

<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <p>Hello World {{ some }}</p>
    </body>
</html>

This template will render "Hello World args" as the result of the template processing.

For more info, check the included docs with the project, using the command:

make doc

ion-web's People

Contributors

cerberus-zz avatar heynemann avatar andrewsmedina avatar jcfigueiredo avatar ricobl avatar

Stargazers

Paul Dude avatar James Michael DuPont avatar Hans Roman avatar Philippe Ombredanne avatar  avatar David Sullivan avatar Kevin Ernest Long avatar Victor Pantoja avatar Gustavo Barbosa avatar Taurus Olson avatar  avatar  avatar  avatar  avatar Luiz Boaretto avatar

Watchers

 avatar Gabriel Falcão avatar  avatar  avatar Gustavo Barbosa avatar James Cloos avatar  avatar

ion-web's Issues

pip install ion fails with ModuleNotFoundError: No module named 'bus'

Python version: Python 3.9.16 (main, May 29 2023, 00:00:00)
PIP version: pip 24.0

Output:

$ pip install Ion
Collecting Ion
  Using cached Ion-0.6.4.tar.gz (16 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      Traceback (most recent call last):
        File "/venv/lib64/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/venv/lib64/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/venv/lib64/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-squwh34m/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-squwh34m/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-squwh34m/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-squwh34m/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 18, in <module>
        File "/tmp/pip-install-_85hxk1f/ion_38568a5ae5bf4ae583cbdc55b9b3d2e1/ion/__init__.py", line 23, in <module>
          from bus import *
      ModuleNotFoundError: No module named 'bus'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.