Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added empty option. Fixed a few conversion related bugs. added variou…

…s scripts to help run tests
  • Loading branch information...
commit 0475450a5ca018162d12d9c5de65fd668d41c6d5 1 parent 5c95ebd
Tim Parkin authored
View
10 CHANGELOG
@@ -2,6 +2,16 @@
Changlelog
==========
+
+0.6.1 (2009-01-17)
+----------------
+
+* Added the 'empty' attribute to allow empty values to come back as anything you like (normally they return None)
+* Reviewed the way conversion works and added extra tests.. picked up on a couple of edge cases
+
+BUG FIX: bugs in the conversion of none_option values
+
+
0.6 (2009-01-16)
----------------
View
9 docs-build/introduction.rst
@@ -251,11 +251,11 @@ You can see from the example that the main conversion process is done using ``st
def from_type(self, value, converter_options={}):
if value is None:
- return None
+ return ''
return str(value)
def to_type(self, value, converter_options={}):
- if value is None:
+ if value == '':
return None
value = value.strip()
try:
@@ -264,7 +264,7 @@ You can see from the example that the main conversion process is done using ``st
raise ConvertError("Not a valid number")
return value
-So we short circuit None values, strip the data and cast it to the right type and raise a conversion exception if it fails.
+So we short circuit None values [#f1]_, strip the data and cast it to the right type and raise a conversion exception if it fails.
The widget templates
--------------------
@@ -659,4 +659,7 @@ Other goals..
+.. rubric:: Footnotes
+
+.. [#f1] By default the formish widgets equate the empty string with None. This means if you put a default value of '' into a form, you will get None back. If you want to override this behaviour, set the ``empty`` widget attribute to something else (e.g. for a date field you might set the widget value to ``datetime.date.today()``
View
9 docs/html/_sources/introduction.txt
@@ -251,11 +251,11 @@ You can see from the example that the main conversion process is done using ``st
def from_type(self, value, converter_options={}):
if value is None:
- return None
+ return ''
return str(value)
def to_type(self, value, converter_options={}):
- if value is None:
+ if value == '':
return None
value = value.strip()
try:
@@ -264,7 +264,7 @@ You can see from the example that the main conversion process is done using ``st
raise ConvertError("Not a valid number")
return value
-So we short circuit None values, strip the data and cast it to the right type and raise a conversion exception if it fails.
+So we short circuit None values [#f1]_, strip the data and cast it to the right type and raise a conversion exception if it fails.
The widget templates
--------------------
@@ -659,4 +659,7 @@ Other goals..
+.. rubric:: Footnotes
+
+.. [#f1] By default the formish widgets equate the empty string with None. This means if you put a default value of '' into a form, you will get None back. If you want to override this behaviour, set the ``empty`` widget attribute to something else (e.g. for a date field you might set the widget value to ``datetime.date.today()``
View
13 docs/html/introduction.html
@@ -276,11 +276,11 @@
<span class="k">def</span> <span class="nf">from_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">converter_options</span><span class="o">=</span><span class="p">{}):</span>
<span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
- <span class="k">return</span> <span class="bp">None</span>
+ <span class="k">return</span> <span class="s">&#39;&#39;</span>
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">to_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">converter_options</span><span class="o">=</span><span class="p">{}):</span>
- <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+ <span class="k">if</span> <span class="n">value</span> <span class="o">==</span> <span class="s">&#39;&#39;</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">None</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="k">try</span><span class="p">:</span>
@@ -290,7 +290,7 @@
<span class="k">return</span> <span class="n">value</span>
</pre></div>
</div>
-<p>So we short circuit None values, strip the data and cast it to the right type and raise a conversion exception if it fails.</p>
+<p>So we short circuit None values <a class="footnote-reference" href="#f1" id="id2">[1]</a>, strip the data and cast it to the right type and raise a conversion exception if it fails.</p>
</div>
<div class="section" id="the-widget-templates">
<h2>The widget templates<a class="headerlink" href="#the-widget-templates" title="Permalink to this headline">¶</a></h2>
@@ -610,6 +610,13 @@
<p class="first admonition-title">Note</p>
<p class="last">Please send any feedback to <a class="reference external" href="mailto:developers&#37;&#52;&#48;ish&#46;io">developers<span>&#64;</span>ish<span>&#46;</span>io</a></p>
</div>
+<p class="rubric">Footnotes</p>
+<table class="docutils footnote" frame="void" id="f1" rules="none">
+<colgroup><col class="label" /><col /></colgroup>
+<tbody valign="top">
+<tr><td class="label"><a class="fn-backref" href="#id2">[1]</a></td><td>By default the formish widgets equate the empty string with None. This means if you put a default value of &#8216;&#8217; into a form, you will get None back. If you want to override this behaviour, set the <tt class="docutils literal"><span class="pre">empty</span></tt> widget attribute to something else (e.g. for a date field you might set the widget value to <tt class="docutils literal"><span class="pre">datetime.date.today()</span></tt></td></tr>
+</tbody>
+</table>
</div>
</div>
View
2  docs/html/searchindex.js
@@ -1 +1 @@
-Search.setIndex({desctypes:{"0":"method","1":"class"},terms:{represent:[2,7],all:[2,7,8,5],code:[2,7],partial:2,skeleton:1,whatev:5,messi:2,skip:[7,8],formencod:2,global:7,month:7,show_bug:7,prefix:[2,7],other_opt:[],abil:[2,3],follow:[2,7,8,5],disk:7,row:7,capitalis:7,typeerror:7,depend:8,readabl:5,friendli:2,send:[2,5],toscawidget:2,image_preview:2,decis:7,sens:2,isinst:[2,7],settl:7,"case":[2,3,7],sourc:[],fieldset:7,string:[2,7,8,5],straightforward:2,fals:7,util:[5,1],failur:[2,5],veri:2,join:[2,7],passs:5,tri:[2,7],four:2,form_head:2,magic:[2,3],"0x943da30":[],button:7,list:[2,7,8],upload:[2,0,7,4,3],iter:8,correct:[2,7,8],"try":[2,7,5],item:[2,7],datetupleconvert:2,vertic:2,div:[2,7,8,5],round:2,textareacustom:8,pleas:[2,7],impli:2,properti:[],selectchoic:7,eas:7,direct:[2,0],item_data:[],uuid4:[2,7],street:7,design:2,pass:[2,7,8,5],further:[8,5],myaddress:7,index:0,what:[2,0,8,7],"_field":[],appear:7,defin:[2,7,8],section:7,abl:8,weren:2,fileresourc:[2,4,1],access:[2,3,7],dateofbirth:7,version:[2,7,8],checkboxmultichoic:7,fieldlist:2,add_act:[],"new":[2,7],symmetr:[2,7],method:[2,7,8,5],metadata:[2,8],redirect:5,widget:[0,2,4,5,7,8,9],themselv:2,deriv:[0,8,7],displai:7,street1:8,gener:[2,3,7],street3:8,here:[2,7,5],behaviour:7,gettempdir:[2,7],pre_parse_request_data:2,error_dict:2,let:[2,7],address:[2,7,8,5],path:[2,3,7],cssname:[2,7,8],filehandlerminim:[2,3,7],legend:7,valu:[2,7,8],box:[2,7],convert:[2,7],survei:8,convers:[2,7],ahead:2,css_class:2,datetim:7,base:[2,3],behav:7,pick:[2,7],action:[2,0,8,5,7],extrem:2,typic:[7,5],commonli:[],ourselv:2,counti:8,overrid:[2,8],originalurl:2,extra:7,appli:[2,7,8],modul:[2,0,7,4,3],success_cal:[],sequencedefault:7,ask:[2,7],"boolean":7,myvalu:7,txt:7,get_other_opt:[],select:[2,7,8],quickstart:0,nest:[2,0,7],from:[2,0,8,5,7],describ:7,would:[2,7,8,5],get_unvalidated_data:[],two:[2,7],next:[2,7],websit:[2,3],few:[2,7],live:7,handler:[2,3,5,7],call:[2,7,8,5],asset:[2,1],recommend:2,msg:[2,7],dict:8,parkin:7,type:[0,1,2,4,7,8],until:2,reorder:2,more:[2,0,5,7],sort:[2,8],nouploadyet:2,peopl:8,relat:2,notic:7,convinc:2,warn:7,"__call__":[2,7],accept:[2,7],actual:[2,7],mozilla:7,hold:[2,7],realli:2,cach:[2,1],must:[2,7],middl:8,none:[2,3,5,1,7],word:[7,8],integertostringconvert:2,attr_nam:[],setup:7,work:[2,7,8],itself:7,obvious:[2,7,8],can:[0,1,2,5,7,8],learn:2,get_item_data:[],validat:7,dec:0,root:[2,0,5,7],fetch:5,def:[2,7,5],control:[2,7],request_data:2,termsandcondit:7,stream:[2,3],give:[2,7],process:[2,7],slightli:[0,7],registr:7,emiss:[0,8],indic:[0,7],minimum:[],default_url:[2,3,7],non_zero:7,serial:[],alwai:7,cours:2,multipl:[2,0,5,7],goal:2,friendlier:7,secur:7,"_post_domain":5,anoth:[2,7],charset:[2,7],length:7,snippet:2,concis:8,ish:[2,7],goodal:2,mimetyp:[2,3,7],answer:7,instead:[2,7],languag:[2,7,8],csv:[2,7],simpl:[0,1,2,5,7,8],css:[2,0,8,7],updat:7,map:[2,7],product:2,resourc:[2,3,5,1,7],overridden:[2,8],max:[],after:[2,7],diagram:2,befor:2,lxml:2,schematyp:[],mai:8,philosophi:2,data:[2,0,5,7],demonstr:[2,7],hoc:8,"short":[2,7],first_nam:[2,5],third:2,footer:[2,8],bind:[],folllow:8,explicit:2,element:[7,8],callback:2,combin:[2,7],block:7,allow:[2,7,8],enter:7,callabl:[2,7,8,5],order:[2,7],talk:[2,7],origin:[2,3,7],checkbox:7,help:7,atribut:[],over:[2,7],move:2,becaus:[2,7,8],whilst:7,through:[2,7],"_charset_":[2,7],myfil:[2,7],bunch:[7,8],write:[2,7],style:7,group:2,uuid:[2,7],fit:2,how:[2,7],fix:7,wierd:[],fdopen:[2,7],better:[7,8],complex:[0,7],presum:7,persist:2,comprehens:2,hidden:[2,7,8],main:[2,7,4],might:[7,8],easier:7,them:2,"return":[2,3,5,7],greater:2,thei:[2,7,8],handl:[2,7,4,5],auto:2,dai:7,"break":2,framework:[2,7],facilit:8,front:8,now:[2,7,8],discuss:[2,0,8],bigger:2,introduct:[2,0,7],choic:[2,7],term:7,name:[2,0,8,5,7],anyth:[2,0],level:[2,8],drake:2,separ:[2,7],easili:2,editor:7,each:[2,7,8,5],found:[],unicod:[2,8],difficult:[2,7],mean:[2,7],richtextarea:8,domain:5,weight:2,replac:[7,8],individu:2,hard:2,filehandl:[2,3,4,1,7],addact:5,checkboxmultichoicetre:[],datepart:[2,7],expect:2,year:7,our:[2,7,8,5],happen:7,extract:2,reduct:8,special:8,out:[2,7,8,5],variabl:2,shown:[2,7],formaccessor:[],space:2,goe:7,miss:7,content:[0,7],adapt:0,print:[2,7],got:[2,7],factori:[],proxi:[],insid:8,schema_item:2,differ:[2,7,8],free:8,standard:[2,3,8],reason:[2,8],"_post_email":5,mime:[2,1],dictionari:[2,7],put:[7,5],org:7,fancywidget:8,ometh:8,"0x940b4e0":[],repeat:7,basi:7,reusabl:2,titl:[2,7,8],couldn:2,fairli:2,argument:[2,7,8],could:[2,7,8,5],success:[2,5],keep:2,filter:[2,0,8],thing:[2,7,8],perhap:2,enforc:2,place:7,isn:[7,5],circuit:2,onto:7,assign:[2,5],first:[2,7,8],oper:8,softwar:2,major:7,perfectli:7,suffix:[2,7],directli:7,onc:7,independ:2,number:[2,7],field_input:2,yourself:2,date:[2,7],alreadi:2,done:2,wrapper:7,symmetri:2,blank:7,mimtyp:2,custom:[2,7,8],facil:2,fanci:2,size:7,given:[2,3,8,7],ian:2,attach:5,dayfirst:7,my_schema:2,top:[],form_act:2,system:2,messag:7,citi:8,converttostr:2,master:0,too:2,element_nam:[],get_fil:1,interfac:7,john:2,"final":[2,7],store:[2,3,7],schema:[2,0,8,7],back:[2,7,8,5],option:[2,7],especi:7,namespac:[],methodolog:2,copi:[7,5],form_field:2,specifi:7,"var":[],part:[2,7,8],pars:2,streetnumb:7,off:[7,5],than:[2,5],png:2,serv:[2,1],exposur:2,silli:8,keyword:8,spam_me_pleas:8,provid:[2,8,1],remov:[2,3,7],zero:7,structur:[2,0,8,5,7],get_none_opt:[],jqueri:[2,7],fileaccessor:[2,4,1],str:[2,8],were:2,minut:2,multipart:[2,7],pre:2,sai:2,fashion:2,nicer:8,sometim:7,mind:2,ani:[2,7,8],packag:[2,7],wai:[2,0,8,7],have:[2,7,8,5],tabl:0,need:[2,7,8,5],seem:2,tidi:2,store_fil:[2,3,7],probabl:[2,7],built:[2,7],equival:8,inform:7,formerror:[7,5],self:[2,7,5],maximum:[],note:[2,7,8],also:[2,7,8,5],discret:2,take:[2,7],formbox:5,urlfactori:[2,3,7],environ:7,form_metadata:2,noth:2,singl:[2,7,8],simplifi:5,allow_clear:[],sure:[7,8,5],thi:[0,1,2,3,5,7,8],test:[2,5],though:[2,7,8],object:[2,7,1],exclus:8,render:[2,7,8,5],thank:[2,5],plan:2,gettempprefix:[2,7],choos:7,segment:[2,1],"class":[0,1,2,5,7,8],lazili:[],don:[2,7],textarea:[2,7,8,5],url:[2,3,7],later:[2,7],cover:7,doe:[2,7],which:[2,7,8,5],declar:[7,8],clean:[7,5],databases:7,enctyp:[2,7],usual:[],dot:[2,7,8],wsgi:2,has_kei:2,show:[2,7,8,5],text:[2,7,8],serialis:7,syntax:8,field_label:[2,8],bring:2,action_url:2,session:7,radio:[],worri:2,hack:7,validatish:[2,0,7],find:[2,7,5],feedback:2,involv:2,current:2,onli:[2,7,8],checkedpassword:[],locat:[2,7,8],just:[2,7,8,5],explain:2,configur:[2,7],releas:7,state:7,should:[2,0,8,1,7],resubmit:7,suppos:8,get_mtim:[],get_field:7,folder:8,local:[2,8],hope:2,meant:2,get:[1,2,3,5,7,8],mung:2,stop:2,soon:2,cannot:[],somesort:2,formish:[0,1,2,3,4,5,6,7,8,9],utf:[2,7],requir:[2,7,1],fileno:[2,7],think:[2,8],bar:2,consist:[2,7,8],converter_opt:[2,7],ietf:7,templat:[2,0,8,5,7],yield:[],email:[2,7,5],rfc:7,twice:[],stuff:[7,8],integr:2,contain:[0,8,7],comma:7,mynam:7,where:[2,7],view:8,user:[2,7],geturlforfil:[],set:[2,7],aspect:[2,7],get_form:[2,5],hasn:7,light:2,sex:8,similarli:2,see:[2,7],assymetr:[],result:2,arg:2,fail:[2,7],close:[2,7],project:[2,8],extend:[2,7],correctli:2,hopefulli:2,databas:2,someth:[2,8],label:[2,7,8],"_domain_form":5,addremov:[],written:2,dynam:7,boundwidget:[],"import":[2,7],experi:2,approach:2,street2:8,attribut:[2,7,8],altern:8,signatur:7,imagemagick:1,kei:8,get_mimetyp:[2,3,1,7],numer:[],form_in_request:5,javascript:[2,7],flow:2,condit:7,tempfil:[2,3,7],job:2,succeed:2,len:[2,7],come:[2,7],popul:[],both:8,delimit:[2,7],request_method:7,howev:[2,7],against:[2,7,5],teplat:[],etc:[2,7,8,1],instanc:[2,7,8,5],"_templat":[2,8],basestr:[2,7],countri:[7,8],seri:7,whole:[7,8],col:[],comment:[2,8,5],convertish:[2,0],testish:7,simpli:8,point:[2,7,8],instanti:2,overview:7,fall_back_render:[],excess:2,from_fil:2,arriv:7,walk:8,header:[2,8],non:[2,7],param:[],"0xa65ca30":[],guid:2,file_exist:[],quit:[2,7,5],most:[2,7,8],becom:7,surnam:[2,7,8],second:7,fri:0,three:[2,7],been:[2,7,5],mark:7,compon:2,much:2,treat:8,interest:[2,0],basic:[2,7,1],"_email_form":5,addit:2,temporary_templ:8,wish:[2,7],spit:8,is_str:[2,7],imag:[2,7,1],search:0,last_nam:[2,5],togeth:[2,7],child:2,converterror:[2,7],rang:2,get_opt:[],sound:2,multi:[2,7],ident:8,collectionfieldswrapp:[],look:[2,7,8],raw:2,plain:2,mount:2,bill:2,dottedkei:8,cast:2,"while":2,abov:[2,7],error:[2,7,8,5],aid:7,vagu:2,observ:7,loop:[],subsect:[],parst:2,layer:2,pragmat:7,metada:[],file:[0,1,2,3,4,5,7],pre_rend:2,get_item_data_valu:[],henc:8,customis:[2,0,8],uselist:2,activ:[],"default":[2,7,8,4],templatedstr:[],set_item_data:[],mani:7,"__init__":[2,7],mako:2,collection_field:[],simpleschema:[2,5],develop:[2,0,8],welcom:0,open:8,suggest:8,make:[2,3,8,7],belong:[],same:[2,3,7],python:[2,3,7],redisplai:7,html:[2,7,8,5],is_integ:7,split:[7,8],automat:2,document:[0,5,7],radiochoic:[],complet:[2,0,7],week:2,finish:2,http:[2,7],expans:2,interrog:7,overriden:8,someon:2,resource_root:[2,3,7],hand:7,validato:2,capabl:2,moment:[2,7,8],rais:[2,7,5],temporari:[2,3,4,7],apllic:2,opinion:2,form_nam:5,implement:[2,7,1],expand:[2,7],appropri:7,least:[0,8],els:[2,0,7],"0x8f54a30":[],mention:2,firstli:7,entri:[],"_action":2,min:2,well:[2,7],spent:2,selectwithotherchoic:[],without:[2,7],thought:2,person:[2,8],bugzilla:7,exampl:[2,7,8,5],raise_except:[],endfor:2,endif:[2,8],notempti:[2,5],tempfilehandlerweb:[2,3,7],piec:2,left:[2,7],identifi:[2,3,7],birth:7,execut:2,camel:7,string_convert:2,invalid:[2,7],mystructur:2,behind:2,sequencecontrol:7,yet:[2,7],unto:2,previous:2,storefil:[],web:2,like:[2,0,8,7],jinja:2,easi:2,field:[2,0,8,4,7],had:2,except:[2,7,5],littl:[2,7],myschema:7,blog:2,add:[2,7,8],other:[2,7],notori:2,input:[2,7,8],tell:2,save:[2,7],match:2,build:[2,7,1],applic:[2,3,7],around:7,format:7,read:[7,8],big:[2,8],agnost:7,intuit:2,submodul:2,question5:8,question4:8,tempdir:[2,7],question1:8,full_request_data:[],question3:8,question2:8,starifi:[],bit:[2,8],password:[],recurs:7,mkstemp:[2,7],apart:2,insert:7,contains_error:[],paramet:2,specif:7,filenam:[2,3,1,7],whitespac:[],restish:[0,1,2,4,5,7],integ:[2,7],server:2,collect:2,necessari:7,either:2,output:[2,7,8],resiz:[2,1],page:[2,0,5,7],unabl:7,www:7,right:2,old:7,often:[2,7],creation:[7,8],some:[2,7,8],begin:7,certain:[],intern:2,contin:8,toctre:0,guess:[2,3],sommet:5,librari:[2,7],octet:[2,3],total:2,none_opt:7,confirm:[],avoid:2,normal:[],definit:2,thumbnail:[],subclass:8,substitut:8,inject:2,pattern:2,foo:2,complic:2,fieldstorag:[2,3,7],localhost:7,refer:7,cgi:7,core:[0,4],show_image_preview:2,run:7,power:7,step:[2,7,5],unsuccess:5,great:8,although:[2,8,5],schema_typ:2,immut:2,post:[2,7,5],between:2,sub:[7,8],about:[2,7],obj:[],coupl:2,constraint:2,"0xa098a30":[],firstnam:[2,7,8],formfieldswrapp:[],get_path_for_fil:[2,3,7],simul:7,produc:[2,7],conflat:2,get_url_for_fil:[2,3,7],pre_parse_request:2,associ:[],own:[2,7,8],within:[0,5,7],contriv:7,bound:[7,5],soo:8,isoformat:[2,7],down:[2,7],empti:7,strip:2,ensur:7,chang:[2,7],storag:[2,3,4,7],your:[2,0,8,7],inclus:[2,8],span:[2,7,8],couchishdb:2,val:[],area:7,nevow:2,support:[2,7],megabyt:2,transform:2,submit:[2,7,5],happi:2,avail:2,start:[2,7,5],trigger:7,objectwrapp:[],includ:[2,3,8,7],strong:[2,8],suit:2,forward:[2,0],submiss:[2,7],"function":[2,7,8,5],tempfilehandl:[2,3,7],repeatedli:2,form:[0,2,4,5,6,7,8],forc:2,tupl:[2,7],field_error:2,fileupload:[2,7],amongst:7,"__formish_form__":[2,7],walkthrough:[0,7],accor:7,hear:2,terms_and_condit:8,slighli:2,field_descript:2,line:2,inlin:8,"true":[2,7],longer:7,pull:[],succe:2,made:2,everythig:2,attr:7,refin:2,possibl:[2,7,8],whether:8,notat:7,myfield:7,sequenceofsequ:2,valueerror:[2,7],record:5,below:7,delete_fil:[2,3],otherwis:[2,7,5],problem:[2,8],emit:8,send_test_email:5,couchish:2,featur:2,creat:[2,0,5,7],"int":[2,7],retriev:[],dure:8,doesn:2,repres:[2,7],twist:2,rfc2388:7,clever:8,exist:[],langaug:2,request:[2,7,5],is_requir:7,postcod:8,check:[2,7,5],from_typ:2,fill:2,again:7,readi:2,successfulli:2,myformnam:7,valdatish:2,want:[2,3,8,7],hex:[2,7],todo:8,when:[2,7,8,5],detail:7,virtual:8,tim:7,valid:[2,0,5,7],lookup:8,futur:[0,8,7],form_foot:2,you:[0,2,3,5,7,8],webob:7,nice:8,node:2,"_type":8,personal_detail:8,star:[],preivew:2,tweak:8,sequenc:[2,0,8,7],why:2,introduc:[2,0],matt:[2,8],failure_cal:[],named_form:7,slice:[2,8],peak:2,to_typ:2,string_data:2,formal:2,reduc:8,sphinx:0,haven:2,phone:7,directori:[2,8],unselect:[],lot:[2,7,8],descript:[2,8],rule:2,ignor:2,schemaish:[2,0,8,5,7],time:[2,7,8],far:2,preview:[2,3],cssclass:[],check_email_domain:5},titles:["Welcome to Formish&#8217;s documentation!","formish.fileresource","Introducing Formish","formish.filehandler","Core formish Modules","Using Formish within Restish","formish.forms","A Formish Walkthrough","Future Developments.. For Discussion","formish.widgets"],modules:{"formish.filehandler":3,"formish.fileresource":1},descrefs:{"formish.filehandler.TempFileHandlerWeb":{get_url_for_file:[3,0]},"formish.filehandler":{TempFileHandler:[3,1],TempFileHandlerWeb:[3,1]},"formish.fileresource":{FileAccessor:[1,1],FileResource:[1,1]},"formish.fileresource.FileAccessor":{get_file:[1,0],get_mimetype:[1,0]},"formish.filehandler.TempFileHandler":{get_path_for_file:[3,0],delete_file:[3,0],store_file:[3,0],get_mimetype:[3,0]}},filenames:["index","formish.fileresource","introduction","formish.filehandler","modules","restish","formish.forms","walkthrough","future","formish.widgets"]})
+Search.setIndex({desctypes:{"0":"method","1":"class"},terms:{represent:[2,7],all:[2,7,8,5],code:[2,7],partial:2,skeleton:1,whatev:5,messi:2,skip:[7,8],formencod:2,global:7,month:7,show_bug:7,prefix:[2,7],other_opt:[],abil:[2,3],follow:[2,7,8,5],disk:7,row:7,footnot:2,capitalis:7,typeerror:7,depend:8,readabl:5,friendli:2,send:[2,5],toscawidget:2,image_preview:2,decis:7,sens:2,isinst:[2,7],settl:7,"case":[2,3,7],sourc:[],fieldset:7,string:[2,7,8,5],straightforward:2,fals:7,util:[5,1],failur:[2,5],veri:2,join:[2,7],passs:5,tri:[2,7],four:2,form_head:2,magic:[2,3],"0x943da30":[],button:7,list:[2,7,8],upload:[2,0,7,4,3],iter:8,correct:[2,7,8],"try":[2,7,5],item:[2,7],datetupleconvert:2,vertic:2,div:[2,7,8,5],round:2,textareacustom:8,pleas:[2,7],impli:2,properti:[],selectchoic:7,eas:7,direct:[2,0],item_data:[],uuid4:[2,7],street:7,design:2,pass:[2,7,8,5],further:[8,5],myaddress:7,index:0,what:[2,0,8,7],"_field":[],appear:7,defin:[2,7,8],section:7,abl:8,weren:2,fileresourc:[2,4,1],access:[2,3,7],dateofbirth:7,version:[2,7,8],checkboxmultichoic:7,fieldlist:2,add_act:[],"new":[2,7],symmetr:[2,7],method:[2,7,8,5],metadata:[2,8],redirect:5,widget:[0,2,4,5,7,8,9],themselv:2,deriv:[0,8,7],displai:7,street1:8,gener:[2,3,7],street3:8,here:[2,7,5],behaviour:[2,7],gettempdir:[2,7],pre_parse_request_data:2,error_dict:2,let:[2,7],address:[2,7,8,5],path:[2,3,7],cssname:[2,7,8],filehandlerminim:[2,3,7],legend:7,valu:[2,7,8],box:[2,7],convert:[2,7],survei:8,convers:[2,7],ahead:2,css_class:2,datetim:[2,7],base:[2,3],behav:7,pick:[2,7],action:[2,0,8,5,7],extrem:2,typic:[7,5],commonli:[],ourselv:2,counti:8,overrid:[2,8],originalurl:2,extra:7,appli:[2,7,8],modul:[2,0,7,4,3],success_cal:[],sequencedefault:7,ask:[2,7],"boolean":7,myvalu:7,txt:7,get_other_opt:[],select:[2,7,8],quickstart:0,nest:[2,0,7],from:[2,0,8,5,7],describ:7,would:[2,7,8,5],get_unvalidated_data:[],two:[2,7],todai:2,next:[2,7],websit:[2,3],few:[2,7],live:7,handler:[2,3,5,7],call:[2,7,8,5],asset:[2,1],recommend:2,msg:[2,7],dict:8,parkin:7,type:[0,1,2,4,7,8],until:2,reorder:2,more:[2,0,5,7],sort:[2,8],nouploadyet:2,peopl:8,relat:2,notic:7,convinc:2,warn:7,"__call__":[2,7],accept:[2,7],actual:[2,7],mozilla:7,hold:[2,7],realli:2,cach:[2,1],must:[2,7],middl:8,none:[2,3,5,1,7],word:[7,8],integertostringconvert:2,attr_nam:[],setup:7,work:[2,7,8],itself:7,obvious:[2,7,8],can:[0,1,2,5,7,8],learn:2,get_item_data:[],validat:7,dec:0,root:[2,0,5,7],fetch:5,def:[2,7,5],control:[2,7],request_data:2,termsandcondit:7,stream:[2,3],give:[2,7],process:[2,7],slightli:[0,7],registr:7,emiss:[0,8],indic:[0,7],minimum:[],default_url:[2,3,7],non_zero:7,serial:[],alwai:7,cours:2,multipl:[2,0,5,7],goal:2,friendlier:7,secur:7,"_post_domain":5,anoth:[2,7],charset:[2,7],length:7,snippet:2,concis:8,ish:[2,7],goodal:2,mimetyp:[2,3,7],answer:7,instead:[2,7],languag:[2,7,8],csv:[2,7],simpl:[0,1,2,5,7,8],css:[2,0,8,7],updat:7,map:[2,7],product:2,resourc:[2,3,5,1,7],overridden:[2,8],max:[],after:[2,7],diagram:2,befor:2,lxml:2,schematyp:[],mai:8,philosophi:2,data:[2,0,5,7],demonstr:[2,7],hoc:8,"short":[2,7],first_nam:[2,5],third:2,footer:[2,8],bind:[],folllow:8,explicit:2,element:[7,8],callback:2,"switch":[],combin:[2,7],block:7,allow:[2,7,8],enter:7,callabl:[2,7,8,5],order:[2,7],talk:[2,7],origin:[2,3,7],checkbox:7,help:7,atribut:[],over:[2,7],move:2,becaus:[2,7,8],whilst:7,through:[2,7],"_charset_":[2,7],myfil:[2,7],bunch:[7,8],write:[2,7],style:7,group:2,uuid:[2,7],fit:2,how:[2,7],fix:7,wierd:[],fdopen:[2,7],better:[7,8],complex:[0,7],presum:7,persist:2,comprehens:2,hidden:[2,7,8],main:[2,7,4],might:[2,7,8],easier:7,them:2,"return":[2,3,5,7],greater:2,thei:[2,7,8],handl:[2,7,4,5],auto:2,dai:7,"break":2,framework:[2,7],facilit:8,front:8,now:[2,7,8],discuss:[2,0,8],bigger:2,introduct:[2,0,7],choic:[2,7],term:7,name:[2,0,8,5,7],anyth:[2,0],level:[2,8],drake:2,separ:[2,7],easili:2,editor:7,each:[2,7,8,5],found:[],unicod:[2,8],difficult:[2,7],mean:[2,7],richtextarea:8,domain:5,weight:2,replac:[7,8],individu:2,hard:2,filehandl:[2,3,4,1,7],addact:5,checkboxmultichoicetre:[],datepart:[2,7],expect:2,year:7,our:[2,7,8,5],happen:7,extract:2,reduct:8,special:8,out:[2,7,8,5],variabl:2,shown:[2,7],formaccessor:[],space:2,goe:7,miss:7,content:[0,7],adapt:0,print:[2,7],got:[2,7],factori:[],proxi:[],insid:8,schema_item:2,differ:[2,7,8],free:8,standard:[2,3,8],reason:[2,8],"_post_email":5,mime:[2,1],dictionari:[2,7],put:[2,7,5],org:7,fancywidget:8,ometh:8,"0x940b4e0":[],basi:7,reusabl:2,titl:[2,7,8],couldn:2,fairli:2,argument:[2,7,8],could:[2,7,8,5],success:[2,5],keep:2,filter:[2,0,8],thing:[2,7,8],perhap:2,enforc:2,place:7,isn:[7,5],circuit:2,onto:7,assign:[2,5],first:[2,7,8],oper:8,softwar:2,major:7,perfectli:7,suffix:[2,7],directli:7,onc:7,independ:2,number:[2,7],field_input:2,yourself:2,date:[2,7],alreadi:2,done:2,wrapper:7,symmetri:2,blank:7,mimtyp:2,custom:[2,7,8],facil:2,fanci:2,size:7,given:[2,3,8,7],ian:2,attach:5,dayfirst:7,my_schema:2,top:[],form_act:2,system:2,messag:7,citi:8,converttostr:2,master:0,too:2,element_nam:[],get_fil:1,interfac:7,john:2,"final":[2,7],store:[2,3,7],schema:[2,0,8,7],back:[2,7,8,5],option:[2,7],especi:7,namespac:[],methodolog:2,copi:[7,5],form_field:2,specifi:7,"var":[],part:[2,7,8],pars:2,streetnumb:7,off:[7,5],personal_detail:8,than:[2,5],png:2,serv:[2,1],exposur:2,silli:8,keyword:8,spam_me_pleas:8,provid:[2,8,1],remov:[2,3,7],zero:7,structur:[2,0,8,5,7],get_none_opt:[],jqueri:[2,7],fileaccessor:[2,4,1],str:[2,8],were:2,minut:2,multipart:[2,7],pre:2,sai:2,fashion:2,nicer:8,sometim:7,mind:2,ani:[2,7,8],packag:[2,7],wai:[2,0,8,7],have:[2,7,8,5],tabl:0,need:[2,7,8,5],seem:2,tidi:2,store_fil:[2,3,7],probabl:[2,7],built:[2,7],equival:8,inform:7,formerror:[7,5],self:[2,7,5],maximum:[],note:[2,7,8],also:[2,7,8,5],discret:2,take:[2,7],formbox:5,urlfactori:[2,3,7],environ:7,form_metadata:2,noth:2,singl:[2,7,8],simplifi:5,allow_clear:[],sure:[7,8,5],thi:[0,1,2,3,5,7,8],test:[2,5],though:[2,7,8],object:[2,7,1],exclus:8,render:[2,7,8,5],thank:[2,5],plan:2,gettempprefix:[2,7],choos:7,segment:[2,1],"class":[0,1,2,5,7,8],lazili:[],don:[2,7],textarea:[2,7,8,5],url:[2,3,7],later:[2,7],cover:7,doe:[2,7],which:[2,7,8,5],declar:[7,8],clean:[7,5],databases:7,enctyp:[2,7],usual:[],dot:[2,7,8],wsgi:2,has_kei:2,show:[2,7,8,5],text:[2,7,8],serialis:7,syntax:8,field_label:[2,8],bring:2,action_url:2,session:7,radio:[],worri:2,hack:7,validatish:[2,0,7],find:[2,7,5],feedback:2,involv:2,current:2,onli:[2,7,8],checkedpassword:[],locat:[2,7,8],just:[2,7,8,5],explain:2,configur:[2,7],releas:7,state:7,should:[2,0,8,1,7],resubmit:7,suppos:8,get_mtim:[],get_field:7,folder:8,local:[2,8],hope:2,meant:2,get:[1,2,3,5,7,8],mung:2,stop:2,soon:2,cannot:[],somesort:2,formish:[0,1,2,3,4,5,6,7,8,9],utf:[2,7],requir:[2,7,1],fileno:[2,7],think:[2,8],bar:2,consist:[2,7,8],converter_opt:[2,7],ietf:7,templat:[2,0,8,5,7],yield:[],email:[2,7,5],rfc:7,twice:[],stuff:[7,8],integr:2,contain:[0,8,7],comma:7,mynam:7,where:[2,7],view:8,user:[2,7],geturlforfil:[],set:[2,7],aspect:[2,7],get_form:[2,5],hasn:7,light:2,sex:8,similarli:2,see:[2,7],assymetr:[],result:2,arg:2,fail:[2,7],close:[2,7],project:[2,8],extend:[2,7],correctli:2,hopefulli:2,databas:2,someth:[2,8],label:[2,7,8],"_domain_form":5,addremov:[],written:2,dynam:7,boundwidget:[],"import":[2,7],experi:2,approach:2,street2:8,attribut:[2,7,8],altern:8,signatur:7,imagemagick:1,kei:8,get_mimetyp:[2,3,1,7],numer:[],form_in_request:5,javascript:[2,7],flow:2,condit:7,tempfil:[2,3,7],job:2,succeed:2,len:[2,7],come:[2,7],popul:[],both:8,delimit:[2,7],request_method:7,howev:[2,7],against:[2,7,5],teplat:[],etc:[2,7,8,1],instanc:[2,7,8,5],"_templat":[2,8],equat:2,basestr:[2,7],countri:[7,8],seri:7,whole:[7,8],col:[],comment:[2,8,5],convertish:[2,0],testish:7,simpli:8,point:[2,7,8],instanti:2,overview:7,fall_back_render:[],excess:2,from_fil:2,arriv:7,walk:8,header:[2,8],non:[2,7],param:[],"0xa65ca30":[],guid:2,file_exist:[],quit:[2,7,5],most:[2,7,8],becom:7,surnam:[2,7,8],second:7,fri:0,three:[2,7],been:[2,7,5],mark:7,compon:2,much:2,treat:8,interest:[2,0],basic:[2,7,1],"_email_form":5,addit:2,temporary_templ:8,wish:[2,7],spit:8,is_str:[2,7],imag:[2,7,1],search:0,last_nam:[2,5],togeth:[2,7],child:2,converterror:[2,7],rang:2,get_opt:[],sound:2,multi:[2,7],ident:8,collectionfieldswrapp:[],look:[2,7,8],raw:2,plain:2,mount:2,bill:2,dottedkei:8,cast:2,"while":2,abov:[2,7],error:[2,7,8,5],aid:7,vagu:2,observ:7,loop:[],subsect:[],parst:2,layer:2,pragmat:7,metada:[],file:[0,1,2,3,4,5,7],pre_rend:2,get_item_data_valu:[],henc:8,customis:[2,0,8],uselist:2,activ:[],"default":[2,7,8,4],templatedstr:[],set_item_data:[],mani:7,"__init__":[2,7],mako:2,collection_field:[],simpleschema:[2,5],develop:[2,0,8],welcom:0,open:8,suggest:8,make:[2,3,8,7],belong:[],same:[2,3,7],python:[2,3,7],redisplai:7,html:[2,7,8,5],is_integ:7,split:[7,8],automat:2,document:[0,5,7],radiochoic:[],complet:[2,0,7],week:2,finish:2,http:[2,7],expans:2,interrog:7,overriden:8,someon:2,resource_root:[2,3,7],hand:7,validato:2,capabl:2,moment:[2,7,8],rais:[2,7,5],temporari:[2,3,4,7],apllic:2,opinion:2,form_nam:5,implement:[2,7,1],expand:[2,7],appropri:7,least:[0,8],els:[2,0,7],"0x8f54a30":[],mention:2,firstli:7,entri:[],"_action":2,min:2,well:[2,7],spent:2,selectwithotherchoic:[],without:[2,7],thought:2,person:[2,8],bugzilla:7,exampl:[2,7,8,5],raise_except:[],endfor:2,endif:[2,8],notempti:[2,5],tempfilehandlerweb:[2,3,7],piec:2,left:[2,7],identifi:[2,3,7],birth:7,execut:2,camel:7,string_convert:2,invalid:[2,7],mystructur:2,behind:2,sequencecontrol:7,yet:[2,7],unto:2,previous:2,storefil:[],web:2,like:[2,0,8,7],jinja:2,easi:2,field:[2,0,8,4,7],had:2,except:[2,7,5],littl:[2,7],myschema:7,blog:2,add:[2,7,8],other:[2,7],notori:2,input:[2,7,8],tell:2,save:[2,7],match:2,build:[2,7,1],applic:[2,3,7],around:7,format:7,read:[7,8],big:[2,8],agnost:7,intuit:2,submodul:2,question5:8,question4:8,tempdir:[2,7],question1:8,full_request_data:[],question3:8,question2:8,starifi:[],bit:[2,8],password:[],recurs:7,mkstemp:[2,7],apart:2,insert:7,contains_error:[],paramet:2,specif:7,filenam:[2,3,1,7],whitespac:[],restish:[0,1,2,4,5,7],integ:[2,7],server:2,collect:2,necessari:7,either:2,output:[2,7,8],resiz:[2,1],page:[2,0,5,7],unabl:7,www:7,right:2,old:7,often:[2,7],creation:[7,8],some:[2,7,8],begin:7,certain:[],intern:2,contin:8,toctre:0,guess:[2,3],sommet:5,librari:[2,7],octet:[2,3],total:2,none_opt:7,confirm:[],avoid:2,normal:[],definit:2,thumbnail:[],subclass:8,substitut:8,inject:2,pattern:2,foo:2,complic:2,fieldstorag:[2,3,7],localhost:7,refer:7,cgi:7,core:[0,4],show_image_preview:2,run:7,power:7,step:[2,7,5],unsuccess:5,great:8,although:[2,8,5],schema_typ:2,immut:2,post:[2,7,5],between:2,sub:[7,8],about:[2,7],obj:[],coupl:2,constraint:2,"0xa098a30":[],firstnam:[2,7,8],formfieldswrapp:[],get_path_for_fil:[2,3,7],simul:7,produc:[2,7],conflat:2,get_url_for_fil:[2,3,7],pre_parse_request:2,associ:[],own:[2,7,8],within:[0,5,7],contriv:7,bound:[7,5],soo:8,isoformat:[2,7],down:[2,7],empti:[2,7],strip:2,ensur:7,chang:[2,7],storag:[2,3,4,7],your:[2,0,8,7],inclus:[2,8],span:[2,7,8],couchishdb:2,val:[],area:7,nevow:2,support:[2,7],megabyt:2,transform:2,submit:[2,7,5],happi:2,avail:2,start:[2,7,5],trigger:7,objectwrapp:[],includ:[2,3,8,7],strong:[2,8],suit:2,forward:[2,0],submiss:[2,7],"function":[2,7,8,5],tempfilehandl:[2,3,7],repeatedli:2,form:[0,2,4,5,6,7,8],forc:2,tupl:[2,7],field_error:2,fileupload:[2,7],amongst:7,"__formish_form__":[2,7],walkthrough:[0,7],accor:7,hear:2,terms_and_condit:8,slighli:2,field_descript:2,line:2,inlin:8,"true":[2,7],longer:7,pull:[],succe:2,made:2,everythig:2,attr:7,refin:2,possibl:[2,7,8],whether:8,notat:7,myfield:7,sequenceofsequ:2,valueerror:[2,7],record:5,below:7,delete_fil:[2,3],otherwis:[2,7,5],problem:[2,8],emit:8,send_test_email:5,couchish:2,featur:2,creat:[2,0,5,7],"int":[2,7],retriev:[],dure:8,doesn:2,repres:[2,7],twist:2,rfc2388:7,clever:8,exist:[],langaug:2,request:[2,7,5],is_requir:7,postcod:8,check:[2,7,5],from_typ:2,fill:2,again:7,readi:2,successfulli:2,myformnam:7,valdatish:2,want:[2,3,8,7],hex:[2,7],todo:8,when:[2,7,8,5],detail:7,virtual:8,tim:7,valid:[2,0,5,7],lookup:8,futur:[0,8,7],form_foot:2,you:[0,2,3,5,7,8],webob:7,nice:8,node:2,"_type":8,repeat:7,star:[],preivew:2,tweak:8,sequenc:[2,0,8,7],why:2,introduc:[2,0],matt:[2,8],failure_cal:[],named_form:7,slice:[2,8],peak:2,to_typ:2,string_data:2,formal:2,reduc:8,sphinx:0,haven:2,phone:7,directori:[2,8],unselect:[],lot:[2,7,8],descript:[2,8],rule:2,ignor:2,schemaish:[2,0,8,5,7],time:[2,7,8],far:2,preview:[2,3],cssclass:[],check_email_domain:5},titles:["Welcome to Formish&#8217;s documentation!","formish.fileresource","Introducing Formish","formish.filehandler","Core formish Modules","Using Formish within Restish","formish.forms","A Formish Walkthrough","Future Developments.. For Discussion","formish.widgets"],modules:{"formish.filehandler":3,"formish.fileresource":1},descrefs:{"formish.filehandler.TempFileHandlerWeb":{get_url_for_file:[3,0]},"formish.filehandler":{TempFileHandler:[3,1],TempFileHandlerWeb:[3,1]},"formish.fileresource":{FileAccessor:[1,1],FileResource:[1,1]},"formish.fileresource.FileAccessor":{get_file:[1,0],get_mimetype:[1,0]},"formish.filehandler.TempFileHandler":{get_path_for_file:[3,0],delete_file:[3,0],store_file:[3,0],get_mimetype:[3,0]}},filenames:["index","formish.fileresource","introduction","formish.filehandler","modules","restish","formish.forms","walkthrough","future","formish.widgets"]})
View
1  formish.egg-info/SOURCES.txt
@@ -10,6 +10,7 @@ TODO
functests
nose.sh
release.sh
+run
setup.py
unittests
docs-build/Makefile
View
2  formish/templates/mako/formish/widgets/SelectChoice/widget.html
@@ -1,7 +1,7 @@
<%page args="field" />
<select id="${field.cssname}" name="${field.name}">
%if field.widget.none_option:
- <option value="${field.widget.get_none_option(field.attr)[0]}">${field.widget.none_option[1]}</option>
+ <option value="${field.widget.get_none_option_value(field.attr)}">${field.widget.none_option[1]}</option>
%endif
%for option in field.widget.get_options(field.attr):
<option value="${option[0]}" ${field.widget.selected(option,field.value[0], field.attr)|n}>${option[1]}</option>
View
15 formish/tests/testish/functest
@@ -1,2 +1,15 @@
# requires selenium
-nosetests testish/lib/test_func.py:TestTogether
+case "$1" in
+ one)
+ ./run nosetests testish/lib/test_func.py:TestSeparately.test_$2
+ --daemon \
+ --pid-file=$GITDIR/formish/formish/tests/testish/log/live.pid \
+ --log-file=$GITDIR/formish/formish/tests/testish/log/live.log \
+ $GITDIR/formish/formish/tests/testish/live.ini \
+ start
+ ;;
+ *)
+ ./run nosetests testish/lib/test_func.py:TestTogether
+ ;;
+esac
+
View
2  formish/tests/testish/run
@@ -4,6 +4,6 @@ import os, sys, subprocess
args = sys.argv[1:]
env = dict(os.environ)
-env['PYTHONPATH'] = '../../../../../git/restish:../../../../../git/schemaish:../../../../../git/formish:../../../../../git/secret:../../../../../git/notification:../../../../../git/pollen:../../../../../git/formishbuilder:../../../../../git/validatish:../../../../../git/convertish:../../../../../git/clevercss:../../../../../git/wsgiapptools'
+env['PYTHONPATH'] = '../../../../../git/restish:../../../../../git/schemaish:../../../../../git/formish:../../../../../git/validatish:../../../../../git/convertish'
subprocess.call(args, env=env)
View
1  formish/tests/testish/run.sh
@@ -1 +0,0 @@
-/home/tim/git/formish/formish/tests/testish/serve.sh run-dev
View
1  formish/tests/testish/serve.sh
@@ -56,7 +56,6 @@ case "$1" in
;;
run-dev)
./run /home/tim/py/bin/paster serve --reload \
- --log-file=$GITDIR/formish/formish/tests/testish/log/development.log \
$GITDIR/formish/formish/tests/testish/development.ini
;;
*)
View
114 formish/tests/testish/testish/lib/forms.py
@@ -84,6 +84,29 @@ def unittest_String(self):#{{{
self.assertIdHasValue(f, 'form-myStringField', '8')
self.assertRoundTrip(f, testdata)#}}}
+def StringDifferentEmpty(request):
+ """
+ Simple field but making an empty value equal the empty string (instead of None)
+ """
+ schema = schemaish.Structure()
+ schema.add('myStringField', schemaish.String())
+ form = formish.Form(schema, 'form')
+ form['myStringField'].widget = formish.Input(empty='')
+ return form
+
+def unittest_StringDifferentEmpty(self):#{{{
+ # Test None data
+ f = StringDifferentEmpty(None)
+ testdata = {'myStringField': ''}
+ f.defaults = testdata
+ self.assertIdHasValue(f, 'form-myStringField', '')
+ self.assertRoundTrip(f, testdata)
+ # Test sample data
+ f = String(None)
+ testdata = {'myStringField': '8'}
+ f.defaults = testdata
+ self.assertIdHasValue(f, 'form-myStringField', '8')
+ self.assertRoundTrip(f, testdata)#}}}
def Integer(request):
"""
@@ -140,6 +163,16 @@ def unittest_Integer(self):#{{{
self.assertIdHasValue(f, 'form-myIntegerField', '8')
self.assertRoundTrip(f, testdata)#}}}
+def IntegerNoneDefault(request):
+ """
+ An integer field defaulting to None
+ """
+ schema = schemaish.Structure()
+ schema.add('myIntegerField', schemaish.Integer())
+ form = formish.Form(schema, 'form')
+ form.defaults = {'myIntegerField':None}
+ return form
+
def Date(request):
"""
A simple form with a single integer field
@@ -179,6 +212,26 @@ def functest_Date(self):#{{{
return#}}}
+def DateDifferentEmpty(request):
+ """
+ A simple date field but with the empty value set to todays date
+ """
+ schema = schemaish.Structure()
+ schema.add('myDateField', schemaish.Date())
+ form = formish.Form(schema, 'form')
+ import datetime
+ form['myDateField'].widget = formish.Input(empty=datetime.date.today())
+ return form
+
+def unittest_DateDifferentEmpty(self):#{{{
+ # Test None data
+ f = DateDifferentEmpty(None)
+ testdata = {'myDateField': ''}
+ f.defaults = testdata
+ self.assertIdHasValue(f, 'form-myStringField', '')
+ expected = {'myDateField': datetime.date.today()}
+ self.assertRoundTrip(f, expected)
+
def Float(request):
"""
A simple form with a single integer field
@@ -841,6 +894,67 @@ def RadioChoiceNoneOption(request):
form['myRadio'].widget = formish.RadioChoice(options,none_option=(None, '--select--'))
return form
+def unittest_RadioChoiceNoneOption(self):#{{{
+ # Test no data
+ f = RadioChoiceNoneOption(None)
+ self.assertIdHasValue(f, 'form-myRadio-noneoption', '')
+ # Test None data
+ f = RadioChoiceNoneOption(None)
+ testdata = {'myRadio': None}
+ f.defaults = testdata
+ self.assertIdAttrHasNoValue(f, 'form-myRadio-noneoption','selected')
+ self.assertIdAttrHasNoValue(f, 'form-myRadio-0','selected')
+ self.assertIdAttrHasNoValue(f, 'form-myRadio-1','selected')
+ self.assertIdAttrHasNoValue(f, 'form-myRadio-2','selected')
+ self.assertRoundTrip(f, testdata)#}}}
+
+def functest_RadioChoiceNoneOption(self):#{{{
+ sel = self.selenium
+ sel.open("/RadioChoiceNoneOption")
+
+ sel.click("form-action-submit")
+ sel.wait_for_page_to_load("30000")
+ try: self.failUnless(sel.is_text_present("{'myRadio': None}"))
+ except AssertionError, e: self.verificationErrors.append(str(e))
+ sel.click("form-myRadio-noneoption")
+ sel.click("form-action-submit")
+ sel.wait_for_page_to_load("30000")
+ try: self.failUnless(sel.is_text_present("{'myRadio': None}"))
+ except AssertionError, e: self.verificationErrors.append(str(e))
+ sel.click("form-myRadio-0")
+ sel.click("form-action-submit")
+ sel.wait_for_page_to_load("30000")
+ try: self.failUnless(sel.is_text_present("{'myRadio': 1}"))
+ except AssertionError, e: self.verificationErrors.append(str(e))
+
+ return#}}}
+
+def RadioChoiceNoneOptionNoneDefault(request):
+ """
+ Setting a None Option on the select choice element - default value of None
+ """
+ schema = schemaish.Structure()
+ schema.add('myRadio', schemaish.Integer())
+ options = [(1,'a'),(2,'b'),(3,'c')]
+
+ form = formish.Form(schema, 'form')
+ form.defaults = {'myRadio':None}
+ form['myRadio'].widget = formish.RadioChoice(options,none_option=(None, '--select--'))
+ return form
+
+def RadioChoiceNoneOptionWithDefault(request):
+ """
+ Setting a None Option on the select choice element - default value of 1
+ """
+ schema = schemaish.Structure()
+ schema.add('myRadio', schemaish.Integer())
+ options = [(1,'a'),(2,'b'),(3,'c')]
+
+ form = formish.Form(schema, 'form')
+ form.defaults = {'myRadio':1}
+ form['myRadio'].widget = formish.RadioChoice(options,none_option=(None, '--select--'))
+ return form
+
def RadioChoiceCallableOptions(request):
"""
Passing in a callable list of options
View
9 formish/tests/testish/testish/lib/test_unittests.py
@@ -38,7 +38,16 @@ def assertIdHasValue(self, f, id, v):
soup = BeautifulSoup(f())
self.assertEquals(soup.find(id=id)['value'],v)
+ def assertIdAttrHasValue(self, f, id, attr, v):
+ soup = BeautifulSoup(f())
+ s = soup.find(id=id)
+ assert 'attr' in s
+ self.assertEquals(s['attr'],v)
+ def assertIdAttrHasNoValue(self, f, id, attr):
+ soup = BeautifulSoup(f())
+ s = soup.find(id=id)
+ assert 'attr' not in s
if __name__ == '__main__':
View
14 formish/tests/testish/testish/templates/root.html
@@ -12,6 +12,12 @@
links(ids)
%>
+<h3>Simple Fields with some options</h3>
+<%
+ids = ['StringDifferentEmpty','DateDifferentEmpty']
+links(ids)
+%>
+
<h3>File Fields</h3>
<%
ids = ['File']
@@ -24,6 +30,12 @@
links(ids)
%>
+<h3>Default Values</h3>
+<%
+ids = ['IntegerNoneDefault']
+links(ids)
+%>
+
<h3>Checkbox Widgets</h3>
<%
ids = ['Checkbox']
@@ -40,7 +52,7 @@
<h3>Select Widgets</h3>
<%
-ids = ['SelectChoice','SelectChoiceNoneOption','SelectChoiceCallableOptions','SelectWithOtherChoice','RadioChoice','RadioChoiceNoneOption','RadioChoiceCallableOptions']
+ids = ['SelectChoice','SelectChoiceNoneOption','SelectChoiceCallableOptions','SelectWithOtherChoice','RadioChoice','RadioChoiceNoneOption','RadioChoiceNoneOptionNoneDefault','RadioChoiceCallableOptions']
links(ids)
%>
View
2  formish/tests/testish/unittest
@@ -1 +1 @@
-nosetests testish/lib/test_unittests.py
+./run nosetests testish/lib/test_unittests.py -d
View
12 formish/tests/unittests/test_widget.py
@@ -28,8 +28,8 @@ def test_string_form(self):
form.defaults = request_data
htmlsoup = BeautifulSoup(form())
- assert htmlsoup.findAll(id='form_name-fieldOne-field')[0]['class'] == 'field string input'
- assert htmlsoup.findAll(id='form_name-fieldTwo-field')[0]['class'] == 'field string input'
+ assert htmlsoup.findAll(id='form_name-fieldOne-field')[0]['class'] == 'field form_name-fieldOne string input'
+ assert htmlsoup.findAll(id='form_name-fieldTwo-field')[0]['class'] == 'field form_name-fieldTwo string input'
assert htmlsoup.findAll(id='form_name-fieldOne')[0]['value'] == 'a'
assert htmlsoup.findAll(id='form_name-fieldTwo')[0]['value'] == 'b'
@@ -55,8 +55,8 @@ def test_integer_form(self):
form.defaults = expected_data
htmlsoup = BeautifulSoup(form())
- assert htmlsoup.findAll(id='form_name-fieldOne-field')[0]['class'] == 'field integer input'
- assert htmlsoup.findAll(id='form_name-fieldTwo-field')[0]['class'] == 'field integer input'
+ assert htmlsoup.findAll(id='form_name-fieldOne-field')[0]['class'] == 'field form_name-fieldOne integer input'
+ assert htmlsoup.findAll(id='form_name-fieldTwo-field')[0]['class'] == 'field form_name-fieldTwo integer input'
assert htmlsoup.findAll(id='form_name-fieldOne')[0]['value'] == '1'
assert htmlsoup.findAll(id='form_name-fieldTwo')[0]['value'] == '2'
@@ -83,7 +83,7 @@ def test_date_form(self):
form.defaults = expected_data
htmlsoup = BeautifulSoup(form())
- assert htmlsoup.findAll(id='form_name-a-field')[0]['class'] == 'field date input'
+ assert htmlsoup.findAll(id='form_name-a-field')[0]['class'] == 'field form_name-a date input'
assert htmlsoup.findAll(id='form_name-a')[0]['value'] == '1966-12-18'
def test_date_dateparts_form(self):
@@ -110,7 +110,7 @@ def test_date_dateparts_form(self):
form.defaults = expected_data
htmlsoup = BeautifulSoup(form())
- assert htmlsoup.findAll(id='form_name-a-field')[0]['class'] == 'field date dateparts'
+ assert htmlsoup.findAll(id='form_name-a-field')[0]['class'] == 'field form_name-a date dateparts'
assert htmlsoup.findAll(id='form_name-a')[0]['value'] == '18'
View
91 formish/widgets.py
@@ -26,6 +26,7 @@ def __init__(self, **k):
self.converter_options = k.get('converter_options', {})
self.css_class = k.get('css_class', None)
self.converttostring = True
+ self.empty = k.get('empty', None)
if not self.converter_options.has_key('delimiter'):
self.converter_options['delimiter'] = ','
@@ -36,9 +37,9 @@ def pre_render(self, schema_type, data):
format.If the data is None then we return an empty string. The sequence
is request data representation.
"""
- string_data = string_converter(schema_type).from_type(data)
- if string_data is None:
+ if data is None:
return ['']
+ string_data = string_converter(schema_type).from_type(data)
return [string_data]
@@ -55,7 +56,10 @@ def convert(self, schema_type, request_data):
after the form has been submitted, the request data is converted into
to the schema type.
"""
- return string_converter(schema_type).to_type(request_data[0])
+ string_data = request_data[0]
+ if string_data == '':
+ return self.empty
+ return string_converter(schema_type).to_type(string_data)
def __repr__(self):
return '<widget "%s">'% (self._template)
@@ -83,12 +87,11 @@ def convert(self, schema_type, request_data):
"""
Default to stripping whitespace
"""
+ string_data = request_data[0]
if self.strip is True:
- string_data = request_data[0].strip()
- else:
- string_data = request_data[0]
- if not string_data:
- string_data = None
+ string_data = string_data.strip()
+ if string_data == '':
+ return self.empty
return string_converter(schema_type).to_type(string_data)
@@ -132,13 +135,11 @@ def convert(self, schema_type, request_data):
confirm = request_data['confirm'][0]
if self.strip is True:
password = password.strip()
- if not password:
- password = None
confirm = confirm.strip()
- if not confirm:
- confirm = None
if password != confirm:
raise ConvertError('Password did not match')
+ if password == '':
+ return self.empty
return string_converter(schema_type).to_type(password)
@@ -213,12 +214,11 @@ def convert(self, schema_type, request_data):
We're using the converter options to allow processing sequence data
using the csv module
"""
+ string_data = request_data[0]
if self.strip is True:
- string_data = request_data[0].strip()
- else:
- string_data = request_data[0]
- if not string_data:
- string_data = None
+ string_data = string_data.strip()
+ if string_data == '':
+ return self.empty
return string_converter(schema_type).to_type(string_data,
converter_options=self.converter_options)
@@ -277,7 +277,7 @@ def convert(self, schema_type, request_data):
if year or month or day:
date_parts = (year, month, day)
else:
- date_parts = None
+ return self.empty
return datetuple_converter(schema_type).to_type(date_parts)
@@ -375,17 +375,17 @@ class SelectChoice(Widget):
none_option = ('', '- choose -')
- def __init__(self, options, none_option=UNSET, css_class=None):
+ def __init__(self, options, **k):
"""
:arg options: either a list of values ``[value,]`` where value is used for the label or a list of tuples of the form ``[(value, label),]``
:arg none_option: a tuple of ``(value, label)`` to use as the unselected option
:arg css_class: a css class to apply to the field
"""
- Widget.__init__(self)
- self.css_class = css_class
- self.options = _normalise_options(options)
+ none_option = k.pop('none_option', UNSET)
if none_option is not UNSET:
self.none_option = none_option
+ Widget.__init__(self, **k)
+ self.options = _normalise_options(options)
def selected(self, option, value, schema_type):
"""
@@ -420,17 +420,14 @@ class SelectWithOtherChoice(SelectChoice):
"""
_template = 'SelectWithOtherChoice'
- none_option = ('', '- choose -')
other_option = ('...', 'Other ...')
- def __init__(self, options, none_option=UNSET, other_option=UNSET, css_class=None):
- Widget.__init__(self)
- self.css_class = css_class
- self.options = _normalise_options(options)
- if none_option is not UNSET:
- self.none_option = none_option
+ def __init__(self, options, **k):
+ other_option = k.pop('other_option', UNSET)
if other_option is not UNSET:
self.other_option = other_option
+ self.strip = k.pop('strip',True)
+ SelectChoice.__init__(self, options, **k)
def pre_render(self, schema_type, data):
"""
@@ -445,12 +442,18 @@ def convert(self, schema_type, request_data):
"""
Check to see if we need to use the 'other' value
"""
- if request_data['select'][0] == '...':
- value = request_data['other'][0]
+ select = request_data['select'][0]
+ other = request_data['other'][0]
+ if self.strip:
+ other = other.strip()
+ if select == '...':
+ value = other
else:
- value = request_data['select'][0]
+ if other != '':
+ raise ConvertError('You entered text in the box but had not selected "%s" in the drop down. We have now selected it for you. please check and resubmit'%self.other_option[1])
+ value = select
if value == '':
- return None
+ return self.empty
return string_converter(schema_type).to_type(value)
def get_other_option(self, schema_type):
@@ -479,20 +482,27 @@ class RadioChoice(Widget):
none_option = ('', '- choose -')
- def __init__(self, options, none_option=UNSET, css_class=None):
- Widget.__init__(self)
- self.css_class = css_class
- self.options = _normalise_options(options)
+ def __init__(self, options, **k):
+ none_option = k.pop('none_option', UNSET)
if none_option is not UNSET:
self.none_option = none_option
+ Widget.__init__(self, **k)
+ self.options = _normalise_options(options)
def convert(self, schema_type, request_data):
"""
If we don't have a choice, set a blank value
"""
+
if not request_data:
- request_data = ['']
- return super(RadioChoice, self).convert(schema_type, request_data)
+ string_data = ''
+ else:
+ string_data = request_data[0]
+
+ if string_data == '':
+ return self.empty
+
+ return super(RadioChoice, self).convert(schema_type, string_data)
def selected(self, option, value, schema_type):
"""
@@ -507,8 +517,9 @@ def get_none_option_value(self, schema_type):
"""
Get the default option (the 'unselected' option)
"""
- return string_converter(schema_type).from_type(
+ none_val = string_converter(schema_type).from_type(
self.none_option[0])
+ return none_val
class CheckboxMultiChoice(Widget):
"""
View
9 run
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+import os, sys, subprocess
+
+args = sys.argv[1:]
+env = dict(os.environ)
+env['PYTHONPATH'] = '.:../schemaish:../validatish:../convertish'
+subprocess.call(args, env=env)
+
View
2  setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os, glob
-version = '0.7dev'
+version = '0.6.1'
setup(name='formish',
version=version,
View
2  unittests
@@ -1,2 +1,2 @@
-nosetests formish/tests/unittests
+./run nosetests formish/tests/unittests -d
cd formish/tests/testish && ./unittest && cd ../../../
Please sign in to comment.
Something went wrong with that request. Please try again.