Python Web Framework most like ASP.NET MVC 3
Asked Answered
L

1

7

As much as I enjoy building on ASP.NET MVC, it's time to move off Windows.

I'd like to switch to something Python-based with the least amount of pain.

Without discussing the merits of or reasons for switching, which Python web framework is most similar to ASP.NET MVC 3 in terms of architecture?

Architectural Examples

I'm talking about the flow, not the language.

Typical .NET Route

routes.MapRoute( // maps requests at /Product/ to ProductController
    "Products", // Route name
    "Product/{action}/{id}", // URL with parameters
    new { controller = "Product", action = "Index", id = UrlParameter.Optional }
        // Parameter defaults
);

Typical .NET controller

public class ProductController
{
    public ActionResult Index(IndexInputModel inputModel)
    {
        // do something with inputModel ...
        var viewModel = new ProductIndexViewModel()
        {
            Products = productList;
        }
        return View("~/Views/Product/Index.cshtml", viewModel);
    }
    // ...
}

Typical ~/Views/Product/Index.cshtml .NET Razor View

@model ProductIndexViewModel

<h2>Products</h2>
@foreach (var product in Model.Products)
{
    <h3>@product.Title</h3>
    <p>@product.Description</p>
    <span class="price">@product.Price</span>
}
Liquidate answered 12/2, 2012 at 21:57 Comment(3)
why not ruby? most people, like rob conery, etc moved from asp.net to ruby on railsCown
@ShawnMclean, what kind of questions are those? Why not ruby (coz Rob Conery does it)? Why not PHP (coz Facebook does it)? Why not Java (coz google does it)? Why not XXX (where you could put anything you like in the place of XXX, coz YYY does it)? I mean Stack Overflow is not some discussion board. It's a programming related Q & A site where people should be asking specific questions.Vote
@DarinDimitrov its a suggestive question. Now calm down, not because the guy is trying to find something outside of windows you have to flip out like that. :(Cown
P
2

Django has some similarities. But python is not strongly typed as .Net, so I think you are going to see quite a bit of differences, no matter which framework you end up with.

Paradies answered 12/2, 2012 at 22:17 Comment(4)
Django is the gorilla in the room. I do like the strong-typing aspect of .NET, but let's look past that. Are there any other frameworks to consider?Liquidate
Actually Python is strongly typedGermanism
.. though typically what us strong-type lovers are looking for is static typing. That is, the ability to know at compile-time (and in a good IDE, as we type the code) whether we are making a bonehead mistake in what we attempt to pass as a parameter. Good News: Python 3 function annotations can be used by an IDE (e.g. PyCharm), to declare types. python.org/dev/peps/pep-3107 Finally, the best of both worlds! (Or so I hear .. working in an environment that hasn't yet switched from 2.7)Amanda
#6319314 talks about PyCharm and declaring types. It turns out that for Python 2, PyCharm can extract type info from traditional (""") python doc comments.Amanda

© 2022 - 2024 — McMap. All rights reserved.