[Python-africa] Reahl 3.2

Iwan Vosloo iwan at reahl.org
Thu Jun 16 05:44:00 EDT 2016


On 15/06/2016 18:07, Chukwudi Nwachukwu wrote:
>
>     From: Iwan Vosloo <iwan at reahl.org <mailto:iwan at reahl.org>>
>     Date: Tue, 14 Jun 2016 20:06:00 +0200
>
>     On 14/06/2016 10:10, Chukwudi Nwachukwu wrote:
>
>         I have seen it, well, I can only say that the GUI needs to be
>         worked on.
>
>     Not sure what you are referring to, since there's no GUI ?
>
>
> The widgets styling. Good day

Ah, yes, of course. I agree. That is exactly what this release is about! 
If you read the link in my original post you will get more info:

> We are slowly moving to base styling and layout on Bootstrap, and this 
> version is an experimental first step.
>
> You can find more details here: 
> http://www.reahl.org/docs/3.2/whatchanged.d.html

There's even more detail on: 
http://www.reahl.org/docs/3.2/tutorial/bootstrap/index.d.html

We're programmers, not web designers, so it makes sense for us to 
outsource that side of things to the bootstrap project (like many others 
are doing).

I posted about Reahl in this list because I want to encourage others in 
Africa to do the same: start their own projects and share their 
experiences about doing so with us on this list.

A project is not magically born big and powerful and easy-to-use and 
complete. It is a lot of hard work to get to your goal and it takes 
time. A project starts with a manageable small implementation and is 
added on to, over time, to become more mature and feature-full. As an 
example: In previous releases we were not that concerned with what 
things looked like (in fact, people were meant to supply their own 
styling just like they have to do using django/flask/etc: 
http://www.reahl.org/docs/3.2/tutorial/styling.d.html#styling ). It is 
only with this release that we can pay more attention to styling, with 
the addition of Bootstrap support.

I would love to see more software (especially open source software) 
being exported from Africa instead of being imported. Wouldn't that be 
something to be proud of? If we want that to happen though, we must 
realise that every project has to start somewhere and grow - and we'll 
only get there if we actually help each other along these journeys. 
(Help which includes thoughtful critique too!) That is what the Python 
community is all about.


That said, understanding the goals of a project sometimes takes effort. 
With Reahl, for example, you'd have work through the tutorial to get an 
idea for where Reahl is headed 
(http://www.reahl.org/docs/3.2/tutorial/index.d.html). (You may have to 
think differently about stuff you already know well.)

There is an endless and growing list of things a programmer needs to 
care about when using a traditional web framework. With Reahl, we're 
trying to build a foundation based on Python which hides all that stuff 
and just handles it for you without your even needing to be aware of it 
happening. Of course, we still have some way to go before we can claim 
to handle it all for you, but that is what we're aiming for.

Here are some examples (compare them with 
http://www.reahl.org/docs/3.2/tutorial/bootstrap/forms.d.html)

To deal with validation and form submission in django, for example, you 
do stuff like this many times in your project (from 
http://tutorial.djangogirls.org/en/django_forms/#saving-the-form):

def post_new(request):
     if request.method == "POST":
         form = PostForm(request.POST)
         if form.is_valid():
             post = form.save(commit=False)
             post.author = request.user
             post.published_date = timezone.now()
             post.save()
             return redirect('post_detail', pk=post.pk)
     else:
         form = PostForm()
     return render(request, 'blog/post_edit.html', {'form': form})


In contrast, with Reahl handling a POST vs a GET and checking that the 
form is valid are automatically dealt with (including validation). You 
just link your Button to the Action it should execute when clicked:

btn = form.add_child(Button(self, new_address.events.save))

To be fair, you also have to create an Action on the equivalent of your 
blog post object above, with something like:

     @exposed
     def events(self, events):
         events.save = Event(label='Save', action=Action(self.save))

Notice how there's no mention here of POST/GET/validation/committing or 
not etc.


Another example: if you want to use bootstrap with django, you have to 
do all kinds of things like:

  - Set up links to Bootstrap as explained at the start of: 
http://tutorial.djangogirls.org/en/css/
  - Know how and where to use bootstrap classes in your html, as shown 
with class=container here: 
http://tutorial.djangogirls.org/en/django_forms/#link-to-a-page-with-the-form 
(but for different widgets, you have to learn what to do in each case, 
for example: http://getbootstrap.com/components/#nav-tabs).

Even once you completed everything up to the end of 
http://tutorial.djangogirls.org/en/django_forms/, your form will STILL 
not be styled like a bootstrap form (Bootstrap forms look like this one: 
http://www.reahl.org/docs/3.2/_images/bootstrapform.png).

If you want that look, you will probably have to install, link in and 
then use something like this: 
https://django-bootstrap3.readthedocs.io/en/latest/ (unless you want to 
do it yourself).

In contrast, with Reahl, you literally only have to do something like 
this (for the form itself):

  from reahl.web.bootstrap.forms import FormLayout, TextInput

  my_form.use_layout(FormLayout())
  my_form.layout.add_input(TextInput(self, new_address.fields.name))
  my_form.layout.add_input(TextInput(self, 
new_address.fields.email_address))

.. and, (to be equivalent to the djangogirls example for the page 
layout), something like this:

  from reahl.web.bootstrap.grid import Container

  class MyCustomPage(HTML5Page):
     def __init__(self, view, bookmarks):
         super(MyCustomPage, self).__init__(view)
         self.use_layout(Container())


I know that we already have a lot of cool tools. Yet, we are imagining a 
future that is even better...

- Iwan


-- 
Reahl, the Python only web framework: http://www.reahl.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-africa/attachments/20160616/a8302bcf/attachment-0001.html>


More information about the Python-africa mailing list