Boost.Python和Python异常(Boost.Python and Python exceptions)
如何让boost.python代码知道python异常?
例如,
int test_for(){ for(;;){ } return 0; }
如果我将它导出到python,则不会在Ctrl-C上中断。 我认为其他例外情况不会这样。
这是一个玩具的例子。 我真正的问题是我有一个C函数可能需要几个小时来计算。 如果需要花费更多时间,我想打断它。 但我不想杀死python实例,在函数内部被调用。
提前致谢。
How can I make boost.python code python exceptions aware?
For example,
int test_for(){ for(;;){ } return 0; }
doesn't interrupt on Ctrl-C, if I export it to python. I think other exceptions won't work this way to.
This is a toy example. My real problem is that I have a C function that may take hours to compute. And I want to interrupt it, if it takes more that hour for example. But I don't want to kill python instance, within the function was called.
Thanks in advance.
原文:https://stackoverflow.com/questions/1008343
最满意答案
您不使用属性在视图中设置值 - 您可以通过model属性在控制器中设置值,并将该属性绑定到文本框。
在你的控制器中:
model.quotes = TempData["quote"];
在你看来:
@Html.TextAreaFor(model=>model.quotes)
You don't use attributes to set the value in the view - you set the value in the controller through the model property and bind that property to the text box.
In your controller:
model.quotes = TempData["quote"];
In your view:
@Html.TextAreaFor(model=>model.quotes)
相关问答
更多-
textarea html元素不支持value属性。 因此,您无法使用@Html.TextAreaFor设置其值。 所以你要做的就是: @model MvcApplication.Models.Model @{ if (1 > 2) // your logic here { Model.Description = "value1"; } else { Model.Description = "value2"; } } @H ...
-
这个怎么样: public static class FormHelpers { public static MvcHtmlString GetStreamFieldEditor( this HtmlHelper
html) { var model = html.ViewData.Model; if (model.fiFieldTypeID == 1) { return ht ... -
MVC3,Razor,Html.TextAreaFor():调整高度以适应内容(MVC3, Razor, Html.TextAreaFor(): adjust height to fit contents)[2023-08-28]
代码看起来很好。 一种可能的改进是将其外化为可重复使用的帮手,以避免污染视图: public static class TextAreaExtensions { public static IHtmlString TextAreaAutoSizeFor( this HtmlHelper htmlHelper, Expression > expression, ... -
尝试清除ModelState对象,即HTML助手从中读取值。 另请参阅我对Html.TextBoxFor的工作原理有何误解? 。 Try clearing the ModelState object, which is the HTML helpers read the value from. Also see What am I misunderstanding about how Html.TextBoxFor works?.
-
您的视图模型必须具有属性,而不是字段,才能与模型绑定一起正常工作。 所以改变public String quickSearch; public String quickSearch { get; set; } public String quickSearch { get; set; } public String quickSearch { get; set; } 。 另外,您应该使用标准命名约定并将该字段的名称更改为QuickSearch Your view model has to have Prop ...
-
您应该在将模型传递给视图之前在模型上设置文本。 对于TextBoxFor也是如此。 您不必使用HTML属性设置值。 请注意,textarea没有text或value属性,它在初始渲染时的值是开始和结束标记之间的HTML。 Found the answer, I was doing a silly mistake Now I replaced my Index method from this public ActionResult Index(Guid empId) { Vi ...
-
CKEditor设置数据,清除文本集后点击文本区域?(CKEditor set data, clicking on text area after clearing text set?)[2023-11-26]
可能这对你有用。 CKEDITOR.instances["email-body"].updateElement(); CKEDITOR.instances["email-body"].setData(''); May be this will work for you. CKEDITOR.instances["email-body"].updateElement(); CKEDITOR.instances["email-body"].setData(''); -
这是设置默认值的错误方法。 绑定输入的值由ModelState确定, ModelState本身由来自Request , ViewData / ViewBag和最终Model的值组成。 尽管将value属性明确地设置为某些内容,但Razor将使用它在ModelState中为该属性找到的任何内容来ModelState该值。 如果您想要一个默认值,那么您可以在属性本身上设置它: C#6 public int Users_Id { get; set; } = 1; C#上一个 private int? users ...
-
您不使用属性在视图中设置值 - 您可以通过model属性在控制器中设置值,并将该属性绑定到文本框。 在你的控制器中: model.quotes = TempData["quote"]; 在你看来: @Html.TextAreaFor(model=>model.quotes) You don't use attributes to set the value in the view - you set the value in the controller through the model proper ...
-
使用Html.TextAreaFor时如何更改字体和颜色?(How to change the font & color when using Html.TextAreaFor?)[2022-12-29]
<%= Html.TextAreaFor(m => m.Component.ApplicationDescription, new { cols = "40%", style = "color:red;" })%> 或者应用css风格: <%= Html.TextAreaFor(m => m.Component.ApplicationDescription, new { cols = "40%", @class = "foo" })%> 这看起来像这样: .foo { col ...