Commit 9d51b80b authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

introduce Base.getOriginalDocument() that returns :

  * the original document for an asContext() result document.
  * self for a real document.
  * None for a temporary document.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39135 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9109425c
master allow_login_change allow_login_change_wip arnau arnau-RD-Components-erp5_trade arnau-RD-Components-erp5_trade-TODO-Interactor arnau-TM-Components-Migrate-PortalTransforms arnau-TM-Components-ModuleSecurityInfo arnau-TM-Components-PortalTransforms arnau-TM-FEC-output arnau-TM-isBuildable-with-multiple-BusinessLinks arnau-TM-jabber-client-desktop-notifications arnau-TM-newContent-temp_object arnau-TM-runUnitTest-clear-previous-execution-catalog arnau-TM-wkhtmltopdf arnau-kns arnau-kns-without-property-mapping arnau-merge arnau-poc arnau-real-time-inventory-accounting auto_extend_select_list autoflake backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog boc-interaction-drop bt5_config cache callable-jupyter-storage catalog_filter catalog_fulltext catalog_fulltext_old cedric cedriclen cedriclen-eos certificate_authority cherry-pick-304d7a28 cherry-pick-4a8e045d cleanJSByJSLint clean_up_upgrader cleanup_acquisition_base_category cloud_reliability_test cmf_upgrade_versions credential_update_action datetimefield deferred_listbox delivery_item_barcode douglas_forum dream_distributor dsn-phase3 enhance_scalability_testing eos-dev erp5-component erp5-forum erp5-imt erp5-messenger erp5-preference erp5-release erp5-slapos-upgrade erp5-util-testing erp5-vifib erp5-vifib-cleanup erp5_calendar erp5_catalog erp5_catalog_final erp5_corporate_identity erp5_free_subscription erp5_hal_json_style_fix_restricted_access_with_traverse erp5_payslip_migration erp5_workflow erp5testnode_max_timeout feat/assorted_bug_fixes feat/coding_style_form_naming feat/erp5_ide feat/inventory_api_group_by_time_interval_list feat/olapy feature/renderjs-ui-no-header fix/login_validate_check_consistency fix/support-request-app-empty fix/test_result_after_mep fix/workflow_method_security fix_system_processes_ownership for_testrunner_1 for_testrunner_2 for_testrunner_3 for_testrunner_4 gabriel gadget-json-value hotfix/rjs-formfields-padding improve_default_caching_policy_manager initsite interaction-drop isDeletable ivan jerome-bt-reference-doc jerome_graph_editor_renderjs jerome_user_preference_time_zone jexcel jio jm/form-action-guard js-ui kns lazy_simulation_causality lignan lingnan listbox_url macros_fix mame mame-bt5-cleanup mame-erp5_project-cleanup mame-naming-convention mame-naming-convention-list_method mame-test-stock-indexation mame-work master-erp5-test-result-scalability master-erp5-test-result-scalability-rebase master-test-fix-additionalbt5path mic_wind mmariani-inventory monitoring-graph mrp new-render-presentation no_longer_simulated_state officejs officejs_tutorial pere portal_callables portal_solver_process_security_configuration presentation publish_recursiveReindexObject rebased_mrp refactor/base_edit reindex_calendar_after_change_calendar_exception revert-38554dbe revert-6c89fe9b revert-84f81324 scalability-master scalability-master2 scalability-master2-rebase scalability-roque scalability-roque-2 scalability-run-command shop-box shop-box-rebase streaming_fix streaming_fix-0 syncml taskdistribution-xmlrpc-binary test_page testnode_software_link timezones tristan tristan-merge tristan-performance ttrm valentin_translation_fix view-aggregated-amounts vivekpab_renderjs_interfaces wenjie wenjie_branch wsgi wsgi-gevent wsgi_backport_setbody_lock wsgi_medusa_stream_fix yryr yryr-components-cp yryr-inventory-cache yryr-test yryr-with-components yusei 0.4.59.1 0.4.59 test-ui test-rjsacc test-rjs renderjs-test erp5.util-0.4.66 erp5.util-0.4.65 erp5.util-0.4.64 erp5.util-0.4.63 erp5.util-0.4.62 erp5.util-0.4.61 erp5.util-0.4.60 erp5.util-0.4.59.1 erp5.util-0.4.59 erp5.util-0.4.58 erp5.util-0.4.57 erp5.util-0.4.56 erp5.util-0.4.55 erp5.util-0.4.54 erp5.util-0.4.53 erp5.util-0.4.52 erp5.util-0.4.49 erp5.util-0.4.46 erp5.util-0.4.44 erp5.util-0.4.43 erp5.util-0.4.41 erp5.util-0.4.40 erp5.util-0.4.37 erp5.util-0.4.1 erp5.util-0.4 erp5.util-0.3 erp5.util-0.2 erp5.util-0.1
No related merge requests found
......@@ -2801,12 +2801,31 @@ class Base( CopyContainer,
for k in REQUEST.keys():
if k != 'SESSION':
setattr(context, k, REQUEST[k])
# Set the original document
kw['_original'] = self
# Define local properties
context.__dict__.update(kw)
return context
else:
return context.asContext(REQUEST=REQUEST, **kw)
security.declarePublic('getOriginalDocument')
def getOriginalDocument(self, context=None, REQUEST=None, **kw):
"""
This method returns:
* the original document for an asContext() result document.
* self for a real document.
* None for a temporary document.
"""
if not self.isTempObject():
return self
else:
original = getattr(self, '_original', None)
if original is not None:
return aq_inner(original)
else:
return None
security.declarePublic('isTempObject')
def isTempObject(self):
"""Return true if self is an instance of a temporary document class.
......
......@@ -1338,6 +1338,9 @@ class TestPropertySheet:
obj.setTitle('obj title')
copy = obj.asContext()
self.assertTrue(copy.isTempObject(), '%r is not a temp object' % (copy,))
self.assertEquals(obj, copy.getOriginalDocument())
self.assertEquals(obj.absolute_url(),
copy.getOriginalDocument().absolute_url())
copy.setTitle('copy title')
self.assertEquals('obj title', obj.getTitle())
self.assertEquals('copy title', copy.getTitle())
......@@ -1671,6 +1674,7 @@ class TestPropertySheet:
from Products.ERP5Type.Document import newTempPerson
o = newTempPerson(portal, 'temp_person_1')
self.assertTrue(o.isTempObject())
self.assertEquals(o.getOriginalDocument(), None)
# This should generate a workflow method.
self.assertEquals(o.getValidationState(), 'draft')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment