Skip to content

Commit

Permalink
Merge pull request #49 from plone/plonezope4
Browse files Browse the repository at this point in the history
fix parent lookup, test setup
  • Loading branch information
davisagli authored Feb 1, 2017
2 parents 0d5a0c7 + cfa6d80 commit 4add166
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Bug fixes:
instead of Products.Five.testbrowser
[davisagli]

- Fix test setup for Zope 4.
[davisagli]

- Use __parent__ instead of aq_parent.
[davisagli]


2.0.13 (2017-01-01)
-------------------
Expand Down
7 changes: 3 additions & 4 deletions plone/schemaeditor/browser/field/edit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_inner
from Acquisition import aq_parent
from plone.autoform.form import AutoExtensibleForm
from plone.schemaeditor import _
from plone.schemaeditor import interfaces
Expand Down Expand Up @@ -123,7 +122,7 @@ def _schema(self):

@lazy_property
def additionalSchemata(self):
schema_context = self.context.aq_parent
schema_context = self.context.__parent__
return [v for k, v in getAdapters((schema_context, self.field),
interfaces.IFieldEditorExtender)]

Expand Down Expand Up @@ -165,14 +164,14 @@ def handleSave(self, action):
IStatusMessage(self.request).addStatusMessage(
self.noChangesMessage, type='info')

notify(SchemaModifiedEvent(self.context.aq_parent))
notify(SchemaModifiedEvent(self.context.__parent__))

@button.buttonAndHandler(_(u'Cancel'), name='cancel')
def handleCancel(self, action):
self.redirectToParent()

def redirectToParent(self):
parent = aq_parent(aq_inner(self.context))
parent = aq_inner(self.context).__parent__
url = parent.absolute_url()
if hasattr(parent, 'schemaEditorView') and parent.schemaEditorView:
url += '/@@' + parent.schemaEditorView
Expand Down
2 changes: 1 addition & 1 deletion plone/schemaeditor/browser/field/fieldset.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ def change(self, fieldset_index):
schema.moveField(field_name, new_position)

notifyContainerModified(self.schema)
notify(SchemaModifiedEvent(self.aq_parent.aq_parent))
notify(SchemaModifiedEvent(self.__parent__.__parent__))
4 changes: 2 additions & 2 deletions plone/schemaeditor/browser/field/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def move(self, pos, fieldset_index):
schema.moveField(fieldname, new_absolute_position)

notifyContainerModified(self.schema)
notify(SchemaModifiedEvent(self.aq_parent.aq_parent))
notify(SchemaModifiedEvent(self.__parent__.__parent__))

def delete(self):
"""
Expand All @@ -54,5 +54,5 @@ def delete(self):
schema = IEditableSchema(self.schema)
schema.removeField(self.field.getName())
notify(ObjectRemovedEvent(self.field, self.schema))
notify(FieldRemovedEvent(self.aq_parent.aq_parent, self.field))
notify(FieldRemovedEvent(self.__parent__.__parent__, self.field))
self.request.response.setHeader('Content-Type', 'application/json')
8 changes: 7 additions & 1 deletion plone/schemaeditor/tests/browser_testing.zcml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:zcml="http://namespaces.zope.org/zcml">

<!-- only load PageTemplates zcml in Zope 4 -->
<configure zcml:condition="installed Products.PageTemplates.engine">
<include package="Products.PageTemplates" />
</configure>

<include package="Products.GenericSetup" file="meta.zcml" />
<include package="Products.Five" file="meta.zcml" />
Expand Down

1 comment on commit 4add166

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davisagli Jenkins CI reporting about code analysis
See the full report here: http://jenkins.plone.org/job/package-plone.schemaeditor/21/violations

plone/schemaeditor/utils.py:73:12: P002 found "hasattr", consider replacing it
plone/schemaeditor/utils.py:84:16: P002 found "hasattr", consider replacing it
plone/schemaeditor/tests/tests.py:14:1: I003 isort expected 1 blank line in imports, found 0
plone/schemaeditor/browser/field/edit.py:176:12: P002 found "hasattr", consider replacing it
plone/schemaeditor/browser/schema/add_fieldset.py:46:15: Q000 Remove bad quotes.
plone/schemaeditor/browser/schema/listing.py:55:16: P002 found "hasattr", consider replacing it

Follow these instructions to reproduce it locally.

Please sign in to comment.