Search Results

Search found 7702 results on 309 pages for 'django validation'.

Page 154/309 | < Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >

  • Non blocking IO call from Django controller from a Windows service

    - by Anders
    Hi all, I have a CherryPy server with a Django application running as a Windows service, inside a controller I need to make a call to wmic, the problem is, so far I have only been able to implement a blocking operation. Does anyone have any recommendation for a non blocking operation so, at least more then one person at a time can access this controller and extract information from wmic? Thanks in advance, Anders

    Read the article

  • Python directory list returned to Django template

    - by Shu
    Total Python newb here. I have a images directory and I need to return the names and urls of those files to a django template that I can loop through for links. I know it will be the server path, but I can modify it via JS. I've tried os.walk, but I keep getting empty results.

    Read the article

  • How to take advantage of subprocess within Django? - Django

    - by RadiantHex
    Hi folks, I'm currently using os.popen() but have been recommended to use subprocess.popen() instead. Any ideas on how I can integrate this? It would be cool and fun to have a Python shell accessible on a Django app. But I reckon that it might be a bit complex to implement. I guess I would have to retrieve the subprocess, as a new request comes in. Any ideas?

    Read the article

  • Object validator - is this good design?

    - by neo2862
    I'm working on a project where the API methods I write have to return different "views" of domain objects, like this: namespace View.Product { public class SearchResult : View { public string Name { get; set; } public decimal Price { get; set; } } public class Profile : View { public string Name { get; set; } public decimal Price { get; set; } [UseValidationRuleset("FreeText")] public string Description { get; set; } [SuppressValidation] public string Comment { get; set; } } } These are also the arguments of setter methods in the API which have to be validated before storing them in the DB. I wrote an object validator that lets the user define validation rulesets in an XML file and checks if an object conforms to those rules: [Validatable] public class View { [SuppressValidation] public ValidationError[] ValidationErrors { get { return Validator.Validate(this); } } } public static class Validator { private static Dictionary<string, Ruleset> Rulesets; static Validator() { // read rulesets from xml } public static ValidationError[] Validate(object obj) { // check if obj is decorated with ValidatableAttribute // if not, return an empty array (successful validation) // iterate over the properties of obj // - if the property is decorated with SuppressValidationAttribute, // continue // - if it is decorated with UseValidationRulesetAttribute, // use the ruleset specified to call // Validate(object value, string rulesetName, string FieldName) // - otherwise, get the name of the property using reflection and // use that as the ruleset name } private static List<ValidationError> Validate(object obj, string fieldName, string rulesetName) { // check if the ruleset exists, if not, throw exception // call the ruleset's Validate method and return the results } } public class Ruleset { public Type Type { get; set; } public Rule[] Rules { get; set; } public List<ValidationError> Validate(object property, string propertyName) { // check if property is of type Type // if not, throw exception // iterate over the Rules and call their Validate methods // return a list of their return values } } public abstract class Rule { public Type Type { get; protected set; } public abstract ValidationError Validate(object value, string propertyName); } public class StringRegexRule : Rule { public string Regex { get; set; } public StringRegexRule() { Type = typeof(string); } public override ValidationError Validate(object value, string propertyName) { // see if Regex matches value and return // null or a ValidationError } } Phew... Thanks for reading all of this. I've already implemented it and it works nicely, and I'm planning to extend it to validate the contents of IEnumerable fields and other fields that are Validatable. What I'm particularly concerned about is that if no ruleset is specified, the validator tries to use the name of the property as the ruleset name. (If you don't want that behavior, you can use [SuppressValidation].) This makes the code much less cluttered (no need to use [UseValidationRuleset("something")] on every single property) but it somehow doesn't feel right. I can't decide if it's awful or awesome. What do you think? Any suggestions on the other parts of this design are welcome too. I'm not very experienced and I'm grateful for any help. Also, is "Validatable" a good name? To me, it sounds pretty weird but I'm not a native English speaker.

    Read the article

  • Amazon EC2 Ami recommendations for free tier?

    - by Console
    Amazon web services recently introduced a free tier, where you basically get free stuff to try out AWS and run tiny sites and projects. Basically it's free as long as you remain below a certain limit of bandwidth, disk storage etc. Since going over the limits can quickly become quite expensive (for a hobbyist) I would like some recommendations or suggestions about which AMI's I can run on the free tier, for the purpose of trying out Ruby on Rails and/or Django.

    Read the article

  • We are moving to two servers from one server due to performance issues. How do we monitor the value of this change?

    - by MikeN
    We are moving to two servers from one server due to performance issues. We are moving our MySQL DB to its own dedicated server and will keep the original machine as the front end machine running nginx/apache (Django backend.) How do we monitor the value of this change? It is possible our whole site could actually get slower since the MySQL queries will be going out over a secure remote connection instead of locally?

    Read the article

  • Configuring varnish and django (apache/modwsgi)

    - by Hedde
    I am trying to work out why my application keeps hitting the database while I have setup varnish infront of apache. I think I am missing some vital configuration, any tips are welcome This is my curl result: HTTP/1.1 200 OK Server: Apache/2.2.16 (Debian) Content-Language: en-us Vary: Accept,Accept-Encoding,Accept-Language,Cookie Cache-Control: s-maxage=60, no-transform, max-age=60 Content-Type: application/json; charset=utf-8 Date: Sat, 15 Sep 2012 08:19:17 GMT Connection: keep-alive My varnishlog: 13 BackendClose - apache 13 BackendOpen b apache 127.0.0.1 47665 127.0.0.1 8000 13 TxRequest b GET 13 TxURL b /api/v1/events/?format=json 13 TxProtocol b HTTP/1.1 13 TxHeader b User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3 13 TxHeader b Host: foobar.com 13 TxHeader b Accept: */* 13 TxHeader b X-Forwarded-For: 92.64.200.145 13 TxHeader b X-Varnish: 979305817 13 TxHeader b Accept-Encoding: gzip 13 RxProtocol b HTTP/1.1 13 RxStatus b 200 13 RxResponse b OK 13 RxHeader b Date: Sat, 15 Sep 2012 08:21:28 GMT 13 RxHeader b Server: Apache/2.2.16 (Debian) 13 RxHeader b Content-Language: en-us 13 RxHeader b Content-Encoding: gzip 13 RxHeader b Vary: Accept,Accept-Encoding,Accept-Language,Cookie 13 RxHeader b Cache-Control: s-maxage=60, no-transform, max-age=60 13 RxHeader b Content-Length: 6399 13 RxHeader b Content-Type: application/json; charset=utf-8 13 Fetch_Body b 4(length) cls 0 mklen 1 13 Length b 6399 13 BackendReuse b apache 11 SessionOpen c 92.64.200.145 53236 :80 11 ReqStart c 92.64.200.145 53236 979305817 11 RxRequest c HEAD 11 RxURL c /api/v1/events/?format=json 11 RxProtocol c HTTP/1.1 11 RxHeader c User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3 11 RxHeader c Host: foobar.com 11 RxHeader c Accept: */* 11 VCL_call c recv lookup 11 VCL_call c hash 11 Hash c /api/v1/events/?format=json 11 Hash c foobar.com 11 VCL_return c hash 11 VCL_call c miss fetch 11 Backend c 13 apache apache 11 TTL c 979305817 RFC 60 -1 -1 1347697289 0 1347697288 0 60 11 VCL_call c fetch deliver 11 ObjProtocol c HTTP/1.1 11 ObjResponse c OK 11 ObjHeader c Date: Sat, 15 Sep 2012 08:21:28 GMT 11 ObjHeader c Server: Apache/2.2.16 (Debian) 11 ObjHeader c Content-Language: en-us 11 ObjHeader c Content-Encoding: gzip 11 ObjHeader c Vary: Accept,Accept-Encoding,Accept-Language,Cookie 11 ObjHeader c Cache-Control: s-maxage=60, no-transform, max-age=60 11 ObjHeader c Content-Type: application/json; charset=utf-8 11 Gzip c u F - 6399 69865 80 80 51128 11 VCL_call c deliver deliver 11 TxProtocol c HTTP/1.1 11 TxStatus c 200 11 TxResponse c OK 11 TxHeader c Server: Apache/2.2.16 (Debian) 11 TxHeader c Content-Language: en-us 11 TxHeader c Vary: Accept,Accept-Encoding,Accept-Language,Cookie 11 TxHeader c Cache-Control: s-maxage=60, no-transform, max-age=60 11 TxHeader c Content-Type: application/json; charset=utf-8 11 TxHeader c Date: Sat, 15 Sep 2012 08:21:29 GMT 11 TxHeader c Connection: keep-alive 11 Length c 0 11 ReqEnd c 979305817 1347697288.292612076 1347697289.456128597 0.000086784 1.163468122 0.000048399

    Read the article

  • How to create a WHM/cPanel account, without creating a new sub-domain?

    - by Cyclops
    I have a basic VPS (full root access), with WHM/cPanel, and am learning the ropes. I'm trying to create a new account for an existing domain (mysite.com), and so far WHM won't let me - it either wants a sub-domain or fake domain, but won't allow two accounts for one domain. In the beginning, there was only the root account, and it wouldn't let me login to cPanel - a quick chat with tech support, and I am informed that I need to create a second account, which I did. So now I have an account, call it ns1me, for domain mysite.com. Now I want to create a django account. I go through the same process, but WHM won't allow me to use mysite.com as the domain for django. The docs recommend a sub-domain, so I fill the box in with django.mysite.com. I then realize that has actually created a sub-domain - going to django.mysite.com shows me its home directory, along with helpful information about what version of Apache, Python, and other mods its running (thanks, Apache). I really don't want a sub-domain, so that's out. Another chat with tech support, and they recommend a fake domain name, as it won't create anything. Sure enough, using a domain of djangomysite.com works, and WHM allows me to create a django account. But of course, I can't send email to [email protected] (where I could to [email protected]). What I want, is to be able to create a second account, associated with mysite.com (so I can run cPanel logged in as django, send email to [email protected], etc) - without creating a whole new sub-domain, or fake domain.

    Read the article

  • ASP.NET MVC - ValidationMessageFor

    - by Murat
    Hi, I have asked this question on asp.net forums (http://forums.asp.net/t/1545006.aspx) but i had no valid answer therefore i'll try this here as well. I was working on migrating MVC1 app to MVC2 today and i have come across a problem while changing the ValidationMessage to ValidationMessageFor implementation. The below is the selectlist in my View <%=Html.DropDownListFor(model => model.SecurityQuestions[0].Question, "Some Security question", new { @class = "form_element_select" })%> The below code works fine and i can see the validation message came from modelstate. <%= Html.ValidationMessage("SecurityQuestions_0__Question")%> but this one does not work: <%= Html.ValidationMessageFor(model => model.SecurityQuestions[0].Question)%> SecurityQuestions is a generic list in my model public List<SecurityQuestion> SecurityQuestions { get; set; } Is this somewhat a bug in "ValidationMessageFor" or am i missing something here?

    Read the article

  • ASP.NET: Dynamically enable or disable RequiredFieldValidator based on value of DropDownList

    - by Jeremy
    I have an ASP.NET form with three text inputs, one each for "Work Phone", "Home Phone" and "Cell Phone". Each of these text inputs has a RequiredFieldValidator associated with it. I also have a DropDownList where the user can select the preferred phone type. I want to only require the field that is selected in the DropDownList. For example, if the user selects "Work Phone" from the DropDownList, I want to disable the RequiredFieldValidator for "Home Phone" and "Cell Phone", thereby only making the "Work Phone" field required. I have a method that enables and disables these validators based on the value of the DropDownList, but I cannot figure out when to call it. I want this method to run before the validation takes place on the page. How would I do that? Let me know if you need any more information. Thanks.

    Read the article

  • C# WinForms ErrorProvider Control

    - by Barry
    Hi Does anyone know if there is a way to get a list of controls that have the ErrorProvider icon active. ie. any controls that failed validation. I'm trying to avoid looping all controls in the form. I'd like to display some sort of message indicating how many errors there are on the form. As my form contains tabs I'm trying to make it apparent to the user that errors may exist on inactive tabs and they need to check all tabs. Thanks Barry

    Read the article

  • Hibernate: Found: float, expected: double precision

    - by Frederic Morin
    I have a problem with the mapping of Oracle Float double precision datatype to Java Double datatype. The hibernate schema validator seems to fail when the Java Double datatype is used. org.hibernate.HibernateException: Wrong column type in DB.TABLE for column amount. Found: float, expected: double precision The only way to avoid this is to disable schema validation and hope the schema is in sync with the app about to run. I must fix this before it goes out to production. App's evironment: - Grails 1.2.1 - Hibernate-core 3.3.1.GA - Oracle 10g

    Read the article

  • How to handle Booleans/CheckBoxes in ASP.NET MVC 2 with DataAnnotations?

    - by asp_net
    I've got a view model like this: public class SignUpViewModel { [Required(ErrorMessage = "Bitte lesen und akzeptieren Sie die AGB.")] [DisplayName("Ich habe die AGB gelesen und akzeptiere diese.")] public bool AgreesWithTerms { get; set; } } The view markup code: <%= Html.CheckBoxFor(m => m.AgreesWithTerms) %> <%= Html.LabelFor(m => m.AgreesWithTerms)%> The result: No validation is executed. That's okay so far because bool is a value type and never null. But even if I make AgreesWithTerms nullable it won't work because the compiler shouts "Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions." So, what's the correct way to handle this?

    Read the article

  • ASP.NET MVC2 - Does Html.EnableClientValidation() work on the nested data model?

    - by warmcold
    I have seen the client side validation examples and videos on internet by using Html.EnableClientValidation(). But all target on the simple data model. Does the Html.EnableClientValidation() work on the nested data model like below? public class Person { public Name Name { get; set; } public string Gender { get; set; } } public class Name { public string First { get; set; } public string Last { get; set; } }

    Read the article

  • Model Not Valid Even With No [Required] Attribute

    - by griegs
    I have a model which is validating as False even though I have no validation rules attached to it what so ever. So this is my model; public class QuickQuote { public Enumerations.AUSTRALIA_STATES state { get; set; } public Enumerations.FAMILY_TYPE familyType { get; set; } public Enumerations.CoverLevel hospitalCover { get; set; } public Enumerations.CoverLevel extrasCover { get; set; } public Enumerations.YesNo pregnancy { get; set; } } And in my controller I have; [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(IndexFormViewModel fvm) { if (!ModelState.IsValid) return View(fvm); The problem is that unless I put a value into each field it's validating as false even though it shouldn't care. Can anyone see what the problem is here?

    Read the article

  • How to : required validator based on user role ASP.Net MVC 3

    - by user70909
    Hi, i have a form where i have the field "Real Cost" i want to customize its appearance and wither it should be validated based on user role. to be more clear is say the client want to show his field in the form or details page and also make it editable for users in Roles "Senior Sales, Manager" but not other roles, so can anyone please guide me of the best way ? should i write custom required validation based on user in role, and if so can you please provide the right implementation of it? some may tell me create custom model for this, but i think it would be hassle plus the Roles will be dynamic so it is not predefined set of roles. i hope i was clear enough

    Read the article

  • Using DataAnnotations with Entity Framework

    - by dcompiled
    I have used the Entity Framework with VS2010 to create a simple person class with properties, firstName, lastName, and email. If I want to attach DataAnnotations like as is done in this blog post I have a small problem because my person class is dynamically generated. I could edit the dynamically generated code directly but any time I have to update my model all my validation code would get wiped out. First instinct was to create a partial class and try to attach annotations but it complains that I'm trying to redefine the property. I'm not sure if you can make property declarations in C# like function declarations in C++. If you could that might be the answer. Here's a snippet of what I tried: namespace PersonWeb.Models { public partial class Person { [RegularExpression(@"(\w|\.)+@(\w|\.)+", ErrorMessage = "Email is invalid")] public string Email { get; set; } /* ERROR: The type 'Person' already contains a definition for 'Email' */ } }

    Read the article

  • null values from listbox, are not evaluated in the model binding of ASP.NET-MVC

    - by Jorge
    The model validation doesn't evaluates the attributes linked to listbox values if you don't select at least one of them. This way is not possible to do a model evaluation using DataAnnotations in order to inform required values. The controller: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using TestValidation.Models; namespace TestValidation.Controllers { [HandleError] public class HomeController : Controller { private SelectList list = new SelectList(new List<string>() { "Sao Paulo", "Toronto", "New York", "Vancouver" }); public ActionResult Index() { ViewData["ModelState"] = "NOT EVAL"; ViewData["ItemsList"] = list; return View(); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(MyEntity entity) { if (ModelState.IsValid) { ViewData["ModelState"] = "VALID"; } else { ViewData["ModelState"] = "NOT VALID!!!"; } ViewData["ItemsList"] = list; return View(); } public ActionResult About() { return View(); } } } The View: <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TestValidation.Models.MyEntity>" %> <asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server"> Home Page </asp:Content> <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> <h2> Validation Test</h2> <p> <% using (Html.BeginForm()) {%> <fieldset> <p> ModelState: <%= Html.Encode((string)ViewData["ModelState"])%> </p> <p> <label for="Name"> Name:</label> <%= Html.TextBoxFor(m => m.Name)%> <%= Html.ValidationMessageFor(m => m.Name)%> </p> <p> <label for="ItemFromList"> Items (list):</label> <%= Html.ListBoxFor(m => m.ItemFromList, ViewData["ItemsList"] as SelectList)%> <%= Html.ValidationMessageFor(m => m.ItemFromList)%> </p> <p> <label for="ItemFromCombo"> Items (combo):</label> <%= Html.DropDownListFor(m => m.ItemFromCombo, ViewData["ItemsList"] as SelectList)%> <%= Html.ValidationMessageFor(m => m.ItemFromCombo)%> </p> <p> <input type="submit" value="Submit" /> </p> </fieldset> <% } %> </asp:Content> The Model: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; namespace TestValidation.Models { public class MyEntity_Validate : ValidationAttribute { public MyEntity_Validate() { this.ErrorMessage = "Validated!. Is <> Toronto"; } public override bool IsValid(object value) { return ((string)value == "Toronto"); } } public class MyEntity { [Required] public string Name { get; set; } [MyEntity_Validate] public string ItemFromList { get; set; } [MyEntity_Validate] public string ItemFromCombo { get; set; } } } Any help would be very much appreciated. Thank you.

    Read the article

  • [WPF C#]Get UserControl or VisualTree in DataValidation of TextBlock

    - by dalind
    Hy, I have a validator set on the text property of a textblock. For a correct validation I would need the parent usercontrol of the textblock, but the only things I have in the validator are the value object (a string) and the culture (doesn't help either). Does anyone know a way to get certain usercontrols in a class/a method where I have no access to any kind of visual or control of my application. The problem could be solve if I could give the validator the usercontrol or the textblock as parameters, but I didn't find a way to do so.. Thank you very much for your answers. Greets

    Read the article

  • Change JS alert to DOM error message div

    - by Jason
    I need to convert my error messaging to a positioned div (hidden initially) instead of the standard js alert. I realize I need to push the alert message to the DOM, but I'm new to javascript. Any help would be appreciated. Additionally, I need to do it without a confirm (so error message removes on field focus) if(el != null) { switch(el.name) { case "firstName": //First Name Field Validation, Return false if field is empty if( f.firstName.value == "" ) { alert( bnadd_msg_002 ); if ((typeof TeaLeaf != "undefined") && (typeof TeaLeaf.Client != "undefined") && (typeof TeaLeaf.Client.tlAddEvent != "undefined") ) { var nVO = { ErrorMessage : bnadd_msg_002} var subtype="CustomErrorMsg"; TeaLeaf.Event.tlAddCustomEvent(subtype, nVO); } return false; } break;

    Read the article

  • Is preg_match safe enaught in input satinization?

    - by DaNieL
    Im building a new web-app, LAMP environment... im wondering if preg_match can be trusted for user's input validation (+ prepared stmt, of course) for all the text-based fields (aka not html fields; phone, name, surname, etc..). For example, for a classic 'email field', if i check the input like: $email_pattern = "/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)" . "|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}" . "|[0-9]{1,3})(\]?)$/"; $email = $_POST['email']; if(preg_match($email_pattern, $email)){ //go on, prepare stmt, execute, etc... }else{ //email not valid! do nothing except warn the user } can i sleep easy against the sql/xxs injection? I write the regexp to be the more restrictive as they can.

    Read the article

< Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >