Posts

python - django user creation form required keyerror -

i made custom registration form, inherits usercreationform . however, when try submit, 1 of fields empty, keyerror on required. seems happen somewhere in django source code, i'm pretty sure comes because of custom clean method. form: class registrationform(usercreationform): """ edit user registration form add emailfield """ class meta: model = user fields = ('username', 'password1', 'password2') def __init__(self, *args, **kwargs): super(registrationform, self).__init__(*args, **kwargs) #add custom errormessages self.fields['username'].error_messages = { 'invalid': 'invalid username' } self.fields['password2'].label = "confirm password" #make sure username lowered , unique def clean_username(self): username = self.cleaned_data.get('username') try: u...

asp.net - I want to access controls of derive class from base class on onLoad() override in c# (Master page derive from one masterClass) -

i defined multiple master , has common functionality on form_load event. declare custommasterpage class derived system.web.ui.masterpage , put common functionality this. want override onpage_load() , want print controls of dervived class. suppose have 1 custommaster class class custommasterclass:system:web.ui.masterpage { override onload() { base(e) //i want use following child class controls(lblname) here print // lblname.text="" } } class child1:custommaster { //controls are.. //label:id=lblname; form_load() { lblname.text="test1 test1"; } } class child2:custommaster { //controls are.. //label:id=lblname; form_load() { lblname.text="test2 test2"; } } how that. please give me advice thanks in advance base classes don't know child classes. being said, can define base class having overridable methods derived class can use set s...

javascript - WebPack io.js generators support -

i use webpack compile server-side scripts contain harmony (es6) generators. keep them , not use kind of polyfills or transpilers. webpack complains missing loader. webpack support compile straight forward generator please? stack: io.js webpack koa framework this is fixed of webpack 1.12 it's using esprima 2 .

sql - PostgreSQL concurrent transaction issues -

i'm building crawler. multiple crawling workers access same postgresql database. sadly i'm encountering issues main transaction presented here: begin isolation level serializable; update webpages set locked = true url in ( select distinct on (source) url webpages ( last null or last < refreshfrequency ) , locked = false limit limit ) returning *; commit; url url (string) source domain name (string) last last time page crawled (date) locked boolean set indicate webpage being crawled (boolean) i tried 2 different transaction isolation levels: isolation level serializable , errors could not serialize access due concurrent update isolation level read committed , duplicate url s concurrent transactions due data being "frozen" time transaction fir...

swift - Universal class for Mac OS and iOS -

this question has answer here: how use appropriate color class current platform? 1 answer i want create class mac os- , ios-app. unfortunately, can't use nscolor ios , no uicolor mac os. actually have following code: #if os(ios) func myfunc(color: uicolor?) { self.myfuncx(color) } #elseif os(osx) func myfunc(color: nscolor?) { self.myfuncx(color) } #endif private func myfuncx(color: anyobject?) { #if os(ios) mycolor = color as! uicolor #elseif os(osx) mycolor = color as! nscolor #endif } is there better way? you should able use typealias color class, this: #if os(ios) typealias xcolor = uicolor #elseif os(osx) typealias xcolor = nscolor #endif func myfunc(color: xcolor?) { self.myfuncx(color) } the idea limit conditional compile type definition xcolor , , using type alia...

c# - Passing data between ThreadPool threads -

i have c# webserver have been profiling using stackoverflow miniprofiler. because it's not asp.net server, each request typically executed on own thread, rigged miniprofiler use threadstatic storage track of profilers of incoming request start finish. worked well. recently we've converted use async/await , means continuations after await typically don't come onto same thread , threadstatic storage no longer works. what's best way pass small piece of data between different threadpool threads in case? there existing synchronizationcontext implementations useful this? what's best way pass small piece of data between different threadpool threads in case? using logical call context via static callcontext class. exposes 2 methods: logicalsetdata , logicalgetdata . call context stored , marshaled via executioncontext , in charge of sync context, etc. using class has 2 restrictions: you're limited use of .net 4.5 , above logical c...

c# - The URL Specified () does not correspond to a valid directory. -

when trying run unit test error: test name: getmethodtest test fullname: quanser.codex.app.web.repository.unittests.documentscontrollertests.getmethodtest test source: c:\dev\engineering\mobile apps\software\codex\trunk\web\repository\unittests.repository\documentscontrollertests.cs : line 34 test outcome: failed test duration: 0:00:00 result message: url specified (' http://localhost:53364/ ') not correspond valid directory. tests configured run in asp.net in iis require valid directory exist url. url may invalid or may not point valid web application. this test case: [testmethod()] [hosttype("asp.net")] [urltotest("http://localhost:53364/")] public void getmethodtest() { // ... } i know there wrong line: [urltotest("http://localhost:53364/")] what should put url in attribute? note: need use these attributes testing rest api thanks those attributes testi...