IronPython を使用して ASP.NET MVC を試した人はいますか? 最近、多くの Python 開発を行ったので、潜在的な ASP.NET MVC プロジェクトに入るときに、この言語を引き続き使用できれば幸いです。
特に、LINQ などの .NET 機能を使用して Python の動的な側面を活用することに興味があり、これが可能かどうかを知りたいと思っています。特定の動的プログラミングに実行可能な他のルートは、C# 4.0 とそのdynamic
キーワードです。
考え、経験?
IronPython を使用して ASP.NET MVC を試した人はいますか? 最近、多くの Python 開発を行ったので、潜在的な ASP.NET MVC プロジェクトに入るときに、この言語を引き続き使用できれば幸いです。
特に、LINQ などの .NET 機能を使用して Python の動的な側面を活用することに興味があり、これが可能かどうかを知りたいと思っています。特定の動的プログラミングに実行可能な他のルートは、C# 4.0 とそのdynamic
キーワードです。
考え、経験?
はい、DLR チームからの MVC の例があります。
Sparkにも興味があるかもしれません。
ASP.NET MVC での IronPython の使用: http://www.codevoyeur.com/Articles/Tags/ironpython.aspx
このページには次の記事が含まれています。
私は現在これに取り組んでいます。すでに多くのことをサポートしています: https://github.com/simlic-systems/ironpython-aspnet-mvc
これに関する詳細情報:
aspnet
モジュールをインポートする
import aspnet
独自のコントローラーを作成できます
class HomeController(aspnet.Controller):
def index(self):
return self.view("~/Views/Home/Index.cshtml")
すべてのコントローラを自動的に登録できます
aspnet.Routing.register_all()
さまざまな http メソッドを使用できます
@aspnet.Filter.httpPost
def postSample(self):
return self.view("~/Views/Home/Index.cshtml")
それだけではありません。これは非常に短い例です
# ------------------------------------------------
# This is the root of any IronPython based
# AspNet MVC application.
# ------------------------------------------------
import aspnet
# Define "root" class of the MVC-System
class App(aspnet.Application):
# Start IronPython asp.net mvc application.
# Routes and other stuff can be registered here
def start(self):
# Register all routes
aspnet.Routing.register_all()
# Set layout
aspnet.Views.set_layout('~/Views/Shared/_Layout.cshtml')
# Load style bundle
bundle = aspnet.StyleBundle('~/Content/css')
bundle.include("~/Content/css/all.css")
aspnet.Bundles.add(bundle)
class HomeController(aspnet.Controller):
def index(self):
return self.view("~/Views/Home/Index.cshtml")
def page(self):
# Works also with default paths
return self.view()
def paramSample(self, id, id2 = 'default-value for id2'):
# Works also with default paths
model = SampleModel()
model.id = id
model.id2 = id2
return self.view("~/Views/Home/ParamSample.cshtml", model)
@aspnet.Filter.httpPost
def postSample(self):
return self.view("~/Views/Home/Index.cshtml")
class SampleModel:
id = 0
id2 = ''
class ProductController(aspnet.Controller):
def index(self):
return self.view("~/Views/Product/Index.cshtml")