Changeset 3106 for trunk


Ignore:
Timestamp:
11/10/10 17:48:38 (9 years ago)
Author:
jukka
Message:

Made some pages a bit more robust for old objects

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Collection.py

    r3094 r3106  
    222222        # (because there are only two)       
    223223        title_field=self.getField('title') 
    224         title, other = title_field.widget.process_form(self, title_field, form,validating=False) 
     224        try: 
     225            title, other = title_field.widget.process_form(self, title_field, form,validating=False) 
     226        except TypeError: 
     227            title, other = title_field.widget.process_form(self, title_field, form) 
     228 
    225229        self.setTitle(title) 
    226230        desc_field=self.getField('description') 
    227         desc, other = desc_field.widget.process_form(self, desc_field, form,validating=False) 
     231        try: 
     232            desc, other = desc_field.widget.process_form(self, desc_field, form,validating=False) 
     233        except TypeError: 
     234            desc, other = desc_field.widget.process_form(self, desc_field, form) 
    228235        self.setDescription(desc) 
    229236        # Delete & reorder items 
  • trunk/FieldsWidgets.py

    r3098 r3106  
    829829 
    830830    def textOnly(self, instance, **kwargs): 
    831         listofdicts= getattr(instance, 'cleaned_%s' % self.getName(), []) 
    832         if not listofdicts: 
    833             listofdicts=self.get(instance) 
    834         if listofdicts and isinstance(listofdicts, list): 
    835             return '\n'.join([x['text'] for x in listofdicts]) 
    836         return '' 
    837          
     831        chapters=self.get(instance) 
     832        if chapters and isinstance(chapters, list): 
     833            return '\n'.join([x['text'] for x in chapters]) 
     834        elif chapters: 
     835            return str(chapters)         
     836        else: 
     837            return '' 
    838838 
    839839    def mergeTranslationSource(self, instance, chapter_list): 
  • trunk/MaintenanceTool.py

    r3090 r3106  
    9595            if c%1000==0: 
    9696                print c 
    97  
    9897 
    9998    security.declareProtected(MANAGE_PORTAL, 'updateSchema') 
  • trunk/PresentationMaterial.py

    r3100 r3106  
    160160            dump= '\n'.join([x[0] for x in values if x[1]=='caption']) 
    161161        else: 
    162             dump= '\n'.join([x for x in values]) 
     162            dump= '\n'.join([x['text'] for x in values if x['text']]) 
    163163        if dump.isspace(): 
    164164            return '' 
  • trunk/skins/lemill/about_view.pt

    r3067 r3106  
    1111        <metal:body define-macro="body"> 
    1212        <div metal:use-macro="here/document_byline/macros/byline" /> 
    13         <tal:defines define="my_language python:context.Language(); lang_string python:test(my_language, 'language=%s&amp;' % my_language, ''); 
     13        <tal:defines define="my_language context/Language | python:''; lang_string python:test(my_language, 'language=%s&amp;' % my_language, ''); 
    1414        browse_base python:'%s/content/browse?%s' % (portal_url, lang_string);"> 
    1515        <p><label><tal:block i18n:domain="plone" i18n:translate="label_language">Language</tal:block>:</label> <br /> 
     
    1818        </a> 
    1919        </p> 
    20         <tal:def define="value context/getSubject_area"> 
     20        <tal:def define="value context/getSubject_area | nothing"> 
    2121          <p tal:condition="value"><label><tal:block i18n:translate="label_subject_area">Subject area</tal:block>:</label><br /> 
    2222          <metal:define define-macro="subject_area_view"> 
     
    2626          </metal:define></p> 
    2727        </tal:def> 
    28         <tal:def define="value context/getTarget_group"> 
     28        <tal:def define="value context/getTarget_group | nothing"> 
    2929        <p tal:condition="value"><label><tal:block i18n:translate="label_target_group">Target group</tal:block>:</label><br /> 
    3030          <metal:define define-macro="target_group_view"> 
     
    3434          </metal:define></p> 
    3535        </tal:def> 
    36         <p tal:define="tags context/getTags" tal:condition="tags"><label><tal:block i18n:translate="label_tags">Tags</tal:block>:</label> <br /> 
     36        <p tal:define="tags context/getTags | nothing" tal:condition="tags"><label><tal:block i18n:translate="label_tags">Tags</tal:block>:</label> <br /> 
    3737        <metal:fieldMacro use-macro="python:here.widget('tags',mode='view')"/> 
    3838        </p> 
  • trunk/skins/lemill/collections_list.pt

    r2780 r3106  
    1010    <body> 
    1111 
    12         <metal:main fill-slot="main" tal:define="collections python:context.getCollections(); 
     12        <metal:main fill-slot="main" tal:define="collections context/getCollections | python:[]; 
    1313            in_memberfolder context/getMemberFolder | python: False;"> 
    1414 
Note: See TracChangeset for help on using the changeset viewer.