[1] | 1 | ## Controller Python Script "qseo_properties_edit" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind state=state |
---|
| 7 | ##bind subpath=traverse_subpath |
---|
| 8 | ##title=Update SEO Properties |
---|
| 9 | ##parameters=title=None,description=None,keywords=None,html_comment=None,robots=None,distribution=None,title_override=0,description_override=0,keywords_override=0,html_comment_override=0,robots_override=0,distribution_override=0 |
---|
| 10 | |
---|
| 11 | def setProperty(context, property, value, type='string'): |
---|
| 12 | if context.hasProperty(property): |
---|
| 13 | context.manage_changeProperties({property: value}) |
---|
| 14 | else: |
---|
| 15 | context.manage_addProperty(property, value, type) |
---|
| 16 | |
---|
| 17 | setProperty(context, 'qSEO_title', title) |
---|
| 18 | setProperty(context, 'qSEO_description', description) |
---|
| 19 | setProperty(context, 'qSEO_keywords', keywords, 'lines') |
---|
| 20 | setProperty(context, 'qSEO_html_comment', html_comment) |
---|
| 21 | setProperty(context, 'qSEO_robots', robots) |
---|
| 22 | setProperty(context, 'qSEO_distribution', distribution) |
---|
| 23 | |
---|
| 24 | delete_list = [] |
---|
| 25 | if not title_override: delete_list.append('qSEO_title') |
---|
| 26 | if not description_override: delete_list.append('qSEO_description') |
---|
| 27 | if not keywords_override: delete_list.append('qSEO_keywords') |
---|
| 28 | if not html_comment_override: delete_list.append('qSEO_html_comment') |
---|
| 29 | if not robots_override: delete_list.append('qSEO_robots') |
---|
| 30 | if not distribution_override: delete_list.append('qSEO_distribution') |
---|
| 31 | |
---|
| 32 | if delete_list: context.manage_delProperties(delete_list) |
---|
| 33 | |
---|
| 34 | return state.set(context=context, portal_status_message='Content SEO properties have been saved.') |
---|