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

Dx container site root #85

Merged
merged 43 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
33170ce
Make the DX factory work in a GS baseline import work.
jaroel Dec 1, 2017
9e036ea
Pass on attribute access to item access + log a bunch
jaroel Jun 23, 2018
e8b4924
Merge branch 'master' into dxcontainer-siteroot
jaroel Nov 1, 2018
1e5f346
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Feb 11, 2019
71796f6
Check __dict__ as getattr will use descriptors - ie FieldProperties
jaroel Feb 16, 2019
20fdb8a
Donn't warning about accessing items by attribute.
jaroel Mar 3, 2019
44523c9
Pass in knnown prefix
jaroel Mar 3, 2019
d341c71
fix up, look sharp
jaroel Mar 3, 2019
4877506
fu. We do need to delete the item first, or we'll get doublicate ids.
jaroel Mar 3, 2019
9a84510
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Apr 6, 2019
bde13fc
prevent some loop where getUtility(ISiteRoot) tiggers gettings the sc…
jaroel Apr 21, 2019
1cc678f
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Apr 21, 2019
48b0bc5
blergh
jaroel Apr 21, 2019
32b8912
kekekekekek
jaroel Apr 28, 2019
8fb4769
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Jun 21, 2019
123cb87
just use getUtility
jaroel Jun 22, 2019
b9233a9
special case Plone Site to we don't loop
jaroel Jun 22, 2019
488f9ca
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Oct 26, 2019
e6bd7fe
maybe you're gonna be that one that
jaroel Dec 10, 2019
9d40507
i won't know
jaroel Dec 11, 2019
bc1f107
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Dec 30, 2019
c23174c
don't think we need this
jaroel Dec 30, 2019
ef2e534
Special case for Plone Site in lookup_fti
jaroel Dec 30, 2019
f694a51
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Feb 24, 2020
6804318
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Mar 29, 2020
a1b975c
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel May 27, 2020
bded943
We no longer seem to be needing this
jaroel May 30, 2020
4c505b3
i'm an idiot.
jaroel Jun 14, 2020
8ca5a1d
Ignore 'utilities' in DX getattr
jaroel Jul 19, 2020
49d33b2
Revert "Ignore 'utilities' in DX getattr"
jaroel Jul 19, 2020
617111d
Don't allow shadowing items in the btree by attributes
jaroel Aug 22, 2020
66753b3
herf
jaroel Aug 22, 2020
ce62eaa
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Sep 26, 2020
ed3db7e
make py2 tests happy
jaroel Sep 26, 2020
e23b2d2
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Oct 4, 2020
8fd1f37
Merge remote-tracking branch 'origin/master' into dxcontainer-siteroot
jaroel Dec 9, 2020
4ca53eb
Try to come up with a prefix only when there is none
jaroel Dec 9, 2020
472d60c
Don't try to be smart?
jaroel Dec 12, 2020
a375f3c
Move changelog entry to news/85.bugfix
jaroel Dec 17, 2020
805c92a
Remove commented code
ale-rt Feb 10, 2021
35a12ab
Merge branch 'master' into dxcontainer-siteroot
mauritsvanrees Aug 18, 2021
d5a6896
Use queryUtility to get Plone Site dexterity FTI in portalTypeToSchem…
mauritsvanrees Aug 18, 2021
1fbd494
More info in news snippet.
mauritsvanrees Aug 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Bug fixes:


- Fixes test to work clean with zope.interface.
Interfaces are hashed based on just their name and module.
Interfaces are hashed based on just their name and module.
So every one of these local `IBlank` interfaces will hash the same way, and be treated the same for purposes of zope.interface's `_dependents`.
Thus in tests mock interfaces must not be used under the same name in the same module.
[jensens] (#135)
Expand Down
4 changes: 4 additions & 0 deletions news/85.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix ft._updateProperty so it doesn't break when receiving an empty value.
This happens when an DX FTI is part of a Generic Setup baseline import.
Update more code to work when the Plone Site is a dexterity item.
[jaroel]
6 changes: 5 additions & 1 deletion plone/dexterity/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from zope.security.interfaces import IPermission

import six
import warnings
import threading


Expand Down Expand Up @@ -766,7 +767,10 @@ def __getattr__(self, name):
pass

# Be specific about the implementation we use
return CMFOrderedBTreeFolderBase.__getattr__(self, name)
if self._tree is not None:
return CMFOrderedBTreeFolderBase.__getattr__(self, name)

raise AttributeError(name)

@security.protected(permissions.DeleteObjects)
def manage_delObjects(self, ids=None, REQUEST=None):
Expand Down
2 changes: 1 addition & 1 deletion plone/dexterity/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def description(self):
def __call__(self, *args, **kw):
fti = getUtility(IDexterityFTI, name=self.portal_type)

klass = resolveDottedName(fti.klass)
klass = resolveDottedName(fti.klass) if fti.klass else None
if klass is None or not callable(klass):
raise ValueError(
"Content class %s set for type %s is not valid"
Expand Down
8 changes: 5 additions & 3 deletions plone/dexterity/fti.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def __init__(self, *args, **kwargs):

# Set the content_meta_type from the klass

klass = utils.resolveDottedName(self.klass)
klass = utils.resolveDottedName(self.klass) if self.klass else None
if klass is not None:
self.content_meta_type = getattr(klass, "meta_type", None)

Expand Down Expand Up @@ -228,7 +228,7 @@ def Metatype(self):
if self.content_meta_type:
return self.content_meta_type
# BBB - this didn't use to be set
klass = utils.resolveDottedName(self.klass)
klass = utils.resolveDottedName(self.klass) if self.klass else None
if klass is not None:
self.content_meta_type = getattr(klass, "meta_type", None)
return self.content_meta_type
Expand Down Expand Up @@ -301,7 +301,9 @@ def _updateProperty(self, id, value):

# Update meta_type from klass
if id == "klass":
klass = utils.resolveDottedName(new_value)
klass = None
if new_value:
klass = utils.resolveDottedName(new_value)
if klass is not None:
self.content_meta_type = getattr(klass, "meta_type", None)

Expand Down
14 changes: 12 additions & 2 deletions plone/dexterity/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from zope.component import getAllUtilitiesRegisteredFor
from zope.component import getUtility
from zope.component import queryUtility
from zope.component.hooks import getSite
from zope.dottedname.resolve import resolve
from zope.globalrequest import getRequest
from zope.interface import alsoProvides
Expand Down Expand Up @@ -65,9 +66,11 @@ def lookup_fti(portal_type, cache=True):
if fti_cache is None:
fti_cache = dict()
setattr(request, FTI_CACHE_KEY, fti_cache)
fti = None
if portal_type in fti_cache:
fti = fti_cache[portal_type]
else:

if fti is None:
fti_cache[portal_type] = fti = queryUtility(
IDexterityFTI, name=portal_type
)
Expand Down Expand Up @@ -321,7 +324,14 @@ def split(self, s):
def portalTypeToSchemaName(portal_type, schema=u"", prefix=None, suffix=None):
"""Return a canonical interface name for a generated schema interface."""
if prefix is None:
prefix = "/".join(getUtility(ISiteRoot).getPhysicalPath())[1:]
siteroot = None
if portal_type == "Plone Site":
fti = queryUtility(IDexterityFTI, name=portal_type)
if fti is not None:
siteroot = fti.__parent__
if siteroot is None:
siteroot = getUtility(ISiteRoot)
prefix = "/".join(siteroot.getPhysicalPath())[1:]
if suffix:
prefix = "|".join([prefix, suffix])

Expand Down