Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better dexterity content type skeleton #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

kagesenshi
Copy link
Contributor

Changes:

  • I've got rid of the custom content type class usage as it is more flexible to use dexterity.Item/dexterity.Container directly. The original reason i created the custom content class usage back in collective.dexteritypaste (which later become zopeskel.dexterity) was mainly due to I had some Archetype assumption that content class is needed, but after doing several projects on dexterity, i discovered that this is unnecessary. Furthermore, not using custom content class gives the benefit of easier refactoring as the zodb content object is not coupled to the custom content class
  • I replaced the SampleView with a default view based on dexterity.DisplayForm and plone.app.dexterity item default view. This makes it easier to immediately customize the default view of the content type. dexterity.DisplayForm also provides a way to easily render existing widgets.
  • the buildout is now updated to extend the test buildout from collective/buildout. that way it will always use the latest plone4 release buildout.

@cewing
Copy link
Member

cewing commented Oct 25, 2012

@smcmahon, do you have any opinions on this one? Could you take some time and review this in the next couple of days?

@cewing
Copy link
Member

cewing commented Oct 25, 2012

@kagesenshi would you mind adding some notes to the changelog for this? That would be most helpful.

@davisagli
Copy link
Member

Actually I think it's better to generate a custom content type class, because then you have it if you decide your type needs some custom logic in the future. If it is an Item or Container you would need to write a migration to convert the existing content items before that would be possible.

@kagesenshi
Copy link
Contributor Author

@davisagli , my approach for custom logic for that would be to create an adapter on the content interface .. custom logic is implemented on the adapter instead on the content .. this imo, is more flexible and clean ..

of course, different people have different approach .. probably this need discussion :)

@davisagli
Copy link
Member

Sure, that's always preferable. But sometimes you want to customize how field values are get/set or override a method that Plone or Zope expect to find on the content class.

@kagesenshi
Copy link
Contributor Author

for extending existing content types with fields with custom setter/getter , one can implement as / move the fields to a dexterity behavior adapter ..

@cewing
Copy link
Member

cewing commented Oct 25, 2012

templer templates should be examples of the way we want to teach newcomers to work. I think it's important for us to set as few traps as possible for them. Given that, which of these two approaches results in the least pain for the developer down the road? Is that a question that can be answered clearly?

@kagesenshi
Copy link
Contributor Author

the dexterity manual does not cover the use of custom class , it only suggest to use either dexterity.Item or dexterity.Container .. http://plone.org/products/dexterity/documentation/manual/developer-manual/schema-driven-types/referencemanual-all-pages ..

a setup thats more consistent with the manual is easier for newcomers to follow imo ..

…ity.content.{Container, Item}. Use plone.dexterity.content as its more consistent with the dexterity manual.
@cewing
Copy link
Member

cewing commented Oct 25, 2012

I agree that using classes is not covered by the manual, and I agree that keeping documentation and templer templates in line is a very good idea. However, in this case, I think it might be a deficiency in the documentation. I've run into a number of times when having a custom class has been very helpful. @davisagli, can you weigh in again here? Perhaps opening this to wider discussion on the plone developers list would be of value?

@davisagli
Copy link
Member

I haven't personally reached a conclusion as to which is better.

@petri
Copy link
Member

petri commented Dec 12, 2012

@cewing, can you share some cases when a custom class has been helpful? I think that would help us understand the relative benefits and pitfalls. Having said that, I am not sure either way is 'better'. Perhaps it's just that when complexity, reuse requirements and rate of change go up, the adapter-based, custom-class-less approach will pay off more?

In any case, I would like to ask that the 'other' approach be documented as well in the generated code. Perhaps generate both, but just comment out either one. So people would at least be presented the fact that one can work with or without custom content classes (regardless of which approach is used in the generated code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants