<s> from . import convs , widgets , fields <EOL> from iktomi . utils . i18n import N_ <EOL> class PasswordConv ( convs . Char ) : <EOL> error_mismatch = N_ ( '<STR_LIT>' ) <EOL> error_required = N_ ( '<STR_LIT>' ) <EOL> def from_python ( self , value ) : <EOL> return dict ( [ ( field . name , None ) for field in self . field . fields ] ) <EOL> def get_initial ( self ) : <EOL> return '<STR_LIT>' <EOL> def to_python ( self , value ) : <EOL> etalon = value [ list ( value ) [ <NUM_LIT:0> ] ] <EOL> for field in self . field . fields : <EOL> self . assert_ ( value [ field . name ] == etalon , <EOL> self . error_mismatch ) <EOL> if self . required : <EOL> self . assert_ ( etalon not in ( None , '<STR_LIT>' ) , self . error_required ) <EOL> elif etalon in ( None , '<STR_LIT>' ) : <EOL> return None <EOL> return etalon <EOL> def PasswordSet ( name = '<STR_LIT:password>' , <EOL> min_length = <NUM_LIT:3> , max_length = <NUM_LIT:200> , required = False , <EOL> password_label = None , confirm_label = '<STR_LIT>' , filters = ( ) , <EOL> ** kwargs ) : <EOL> char = convs . Char ( convs . length ( min_length , max_length ) , * filters , <EOL> ** dict ( required = required ) ) <EOL> items = ( ( '<STR_LIT>' , password_label ) , ( '<STR_LIT>' , confirm_label ) ) <EOL> kwargs [ '<STR_LIT>' ] = [ fields . Field ( subfieldname , <EOL> conv = char , <EOL> label = label , <EOL> widget = widgets . PasswordInput ) <EOL> for subfieldname , label in items ] <EOL> kwargs . setdefault ( '<STR_LIT>' , PasswordConv ( required = required ) ) <EOL> kwargs . setdefault ( '<STR_LIT>' , widgets . FieldSetWidget ( <EOL> template = '<STR_LIT>' ) ) <EOL> return fields . FieldSet ( name , get_initial = lambda : '<STR_LIT>' , ** kwargs ) </s>
