Commit 60e8992e authored by Jérome Perrin's avatar Jérome Perrin

ERP5: "quick and dirty" type annotations

parent 18e165d6
...@@ -1752,6 +1752,7 @@ class Base( CopyContainer, ...@@ -1752,6 +1752,7 @@ class Base( CopyContainer,
security.declarePublic('getPortalObject') security.declarePublic('getPortalObject')
def getPortalObject(self): def getPortalObject(self):
# type: () -> IPortalObject
""" """
Returns the portal object Returns the portal object
""" """
...@@ -3527,3 +3528,9 @@ class TempBase(Base): ...@@ -3527,3 +3528,9 @@ class TempBase(Base):
# allow_class(TempBase) in ERP5Type/Document/__init__.py will trample our # allow_class(TempBase) in ERP5Type/Document/__init__.py will trample our
# ClassSecurityInfo with one that doesn't declare our public methods # ClassSecurityInfo with one that doesn't declare our public methods
InitializeClass(TempBase) InitializeClass(TempBase)
try:
from erp5.portal_type import IPortalObject
except ImportError:
pass
...@@ -51,6 +51,11 @@ from Products.ERP5Type import Permissions ...@@ -51,6 +51,11 @@ from Products.ERP5Type import Permissions
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type.Accessor import Base as BaseAccessor from Products.ERP5Type.Accessor import Base as BaseAccessor
try:
from typing import List
except ImportError:
pass
try: try:
from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
except ImportError: except ImportError:
...@@ -117,6 +122,7 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -117,6 +122,7 @@ class FolderMixIn(ExtensionClass.Base):
security.declarePublic('newContent') security.declarePublic('newContent')
def newContent(self, id=None, portal_type=None, id_group=None, def newContent(self, id=None, portal_type=None, id_group=None,
default=None, method=None, container=None, temp_object=0, **kw): default=None, method=None, container=None, temp_object=0, **kw):
# type: (...) -> Folder
"""Creates a new content. """Creates a new content.
This method is public, since TypeInformation.constructInstance will perform This method is public, since TypeInformation.constructInstance will perform
the security check. the security check.
...@@ -333,6 +339,7 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -333,6 +339,7 @@ class FolderMixIn(ExtensionClass.Base):
# Get the content # Get the content
security.declareProtected(Permissions.AccessContentsInformation, 'searchFolder') security.declareProtected(Permissions.AccessContentsInformation, 'searchFolder')
def searchFolder(self, **kw): def searchFolder(self, **kw):
# type: (str) -> List[Folder]
""" """
Search the content of a folder by calling Search the content of a folder by calling
the portal_catalog. the portal_catalog.
...@@ -1516,6 +1523,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn): ...@@ -1516,6 +1523,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
def objectValues(self, spec=None, meta_type=None, portal_type=None, def objectValues(self, spec=None, meta_type=None, portal_type=None,
sort_on=None, sort_order=None, checked_permission=None, sort_on=None, sort_order=None, checked_permission=None,
**kw): **kw):
# type: () -> List[Folder]
# Returns list of objects contained in this folder. # Returns list of objects contained in this folder.
# (no docstring to prevent publishing) # (no docstring to prevent publishing)
if meta_type is not None: if meta_type is not None:
...@@ -1548,6 +1556,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn): ...@@ -1548,6 +1556,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'contentValues' ) 'contentValues' )
def contentValues(self, *args, **kw): def contentValues(self, *args, **kw):
# type: () -> List[Folder]
# Returns a list of documents contained in this folder. # Returns a list of documents contained in this folder.
# ( no docstring to prevent publishing ) # ( no docstring to prevent publishing )
portal_type_id_list = self._getTypesTool().listContentTypes() portal_type_id_list = self._getTypesTool().listContentTypes()
......
...@@ -208,6 +208,13 @@ def _parse_args(self, *args, **kw): ...@@ -208,6 +208,13 @@ def _parse_args(self, *args, **kw):
_parse_args._original = DateTime._original_parse_args _parse_args._original = DateTime._original_parse_args
DateTime._parse_args = _parse_args DateTime._parse_args = _parse_args
try:
from erp5.portal_type import ERP5Site as erp5_portal_type_ERP5Site
except ImportError:
pass
class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
"""Mixin class for ERP5 based tests. """Mixin class for ERP5 based tests.
""" """
...@@ -769,6 +776,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin): ...@@ -769,6 +776,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
return portal_name + '_' + m.hexdigest() return portal_name + '_' + m.hexdigest()
def getPortal(self): def getPortal(self):
# type: () -> erp5_portal_type_ERP5Site
"""Returns the portal object, i.e. the "fixture root". """Returns the portal object, i.e. the "fixture root".
It also does some initialization, as if the portal was accessed for the It also does some initialization, as if the portal was accessed for the
......
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