nwo
stringlengths
6
76
sha
stringlengths
40
40
path
stringlengths
5
118
language
stringclasses
1 value
identifier
stringlengths
1
89
parameters
stringlengths
2
5.4k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
51.1k
docstring
stringlengths
1
17.6k
docstring_summary
stringlengths
0
7.02k
docstring_tokens
sequence
function
stringlengths
30
51.1k
function_tokens
sequence
url
stringlengths
85
218
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Application.py
python
get_products
()
return products
Return a list of tuples in the form: [(priority, dir_name, index, base_dir), ...] for each Product directory found, sort before returning
Return a list of tuples in the form: [(priority, dir_name, index, base_dir), ...] for each Product directory found, sort before returning
[ "Return", "a", "list", "of", "tuples", "in", "the", "form", ":", "[", "(", "priority", "dir_name", "index", "base_dir", ")", "...", "]", "for", "each", "Product", "directory", "found", "sort", "before", "returning" ]
def get_products(): """ Return a list of tuples in the form: [(priority, dir_name, index, base_dir), ...] for each Product directory found, sort before returning """ products = [] i = 0 for product_dir in Products.__path__: product_names = os.listdir(product_dir) for product_name in product_names: if _is_package(product_dir, product_name): # i is used as sort ordering in case a conflict exists # between Product names. Products will be found as # per the ordering of Products.__path__ products.append((0, product_name, i, product_dir)) i = i + 1 products.sort() return products
[ "def", "get_products", "(", ")", ":", "products", "=", "[", "]", "i", "=", "0", "for", "product_dir", "in", "Products", ".", "__path__", ":", "product_names", "=", "os", ".", "listdir", "(", "product_dir", ")", "for", "product_name", "in", "product_names", ":", "if", "_is_package", "(", "product_dir", ",", "product_name", ")", ":", "# i is used as sort ordering in case a conflict exists", "# between Product names. Products will be found as", "# per the ordering of Products.__path__", "products", ".", "append", "(", "(", "0", ",", "product_name", ",", "i", ",", "product_dir", ")", ")", "i", "=", "i", "+", "1", "products", ".", "sort", "(", ")", "return", "products" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Application.py#L363-L379
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Application.py
python
install_package
(app, module, init_func, raise_exc=None)
Installs a Python package like a product.
Installs a Python package like a product.
[ "Installs", "a", "Python", "package", "like", "a", "product", "." ]
def install_package(app, module, init_func, raise_exc=None): """Installs a Python package like a product.""" name = module.__name__ product = FactoryDispatcher.Product(name) product.package_name = name if init_func is not None: newContext = ProductContext(product, app, module) init_func(newContext) package_initialized(module, init_func)
[ "def", "install_package", "(", "app", ",", "module", ",", "init_func", ",", "raise_exc", "=", "None", ")", ":", "name", "=", "module", ".", "__name__", "product", "=", "FactoryDispatcher", ".", "Product", "(", "name", ")", "product", ".", "package_name", "=", "name", "if", "init_func", "is", "not", "None", ":", "newContext", "=", "ProductContext", "(", "product", ",", "app", ",", "module", ")", "init_func", "(", "newContext", ")", "package_initialized", "(", "module", ",", "init_func", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Application.py#L448-L458
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Folder.py
python
manage_addFolder
( self, id, title='', createPublic=0, createUserF=0, REQUEST=None )
Add a new Folder object with id *id*.
Add a new Folder object with id *id*.
[ "Add", "a", "new", "Folder", "object", "with", "id", "*", "id", "*", "." ]
def manage_addFolder( self, id, title='', createPublic=0, createUserF=0, REQUEST=None ): """Add a new Folder object with id *id*. """ ob = Folder(id) ob.title = title self._setObject(id, ob) ob = self._getOb(id) if REQUEST is not None: return self.manage_main(self, REQUEST)
[ "def", "manage_addFolder", "(", "self", ",", "id", ",", "title", "=", "''", ",", "createPublic", "=", "0", ",", "createUserF", "=", "0", ",", "REQUEST", "=", "None", ")", ":", "ob", "=", "Folder", "(", "id", ")", "ob", ".", "title", "=", "title", "self", ".", "_setObject", "(", "id", ",", "ob", ")", "ob", "=", "self", ".", "_getOb", "(", "id", ")", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage_main", "(", "self", ",", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Folder.py#L35-L50
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/OrderedFolder.py
python
manage_addOrderedFolder
(self, id, title='', createPublic=0, createUserF=0, REQUEST=None)
Add a new ordered Folder object with id *id*.
Add a new ordered Folder object with id *id*.
[ "Add", "a", "new", "ordered", "Folder", "object", "with", "id", "*", "id", "*", "." ]
def manage_addOrderedFolder(self, id, title='', createPublic=0, createUserF=0, REQUEST=None): """Add a new ordered Folder object with id *id*. """ ob = OrderedFolder(id) ob.title = title self._setObject(id, ob) ob = self._getOb(id) if REQUEST: return self.manage_main(self, REQUEST)
[ "def", "manage_addOrderedFolder", "(", "self", ",", "id", ",", "title", "=", "''", ",", "createPublic", "=", "0", ",", "createUserF", "=", "0", ",", "REQUEST", "=", "None", ")", ":", "ob", "=", "OrderedFolder", "(", "id", ")", "ob", ".", "title", "=", "title", "self", ".", "_setObject", "(", "id", ",", "ob", ")", "ob", "=", "self", ".", "_getOb", "(", "id", ")", "if", "REQUEST", ":", "return", "self", ".", "manage_main", "(", "self", ",", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/OrderedFolder.py#L26-L35
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_role
(self, role_to_manage, permissions=[], REQUEST=None)
Change the permissions given to the given role.
Change the permissions given to the given role.
[ "Change", "the", "permissions", "given", "to", "the", "given", "role", "." ]
def manage_role(self, role_to_manage, permissions=[], REQUEST=None): """Change the permissions given to the given role. """ BaseRoleManager.manage_role( self, role_to_manage, permissions=permissions) if REQUEST is not None: return self.manage_access(REQUEST)
[ "def", "manage_role", "(", "self", ",", "role_to_manage", ",", "permissions", "=", "[", "]", ",", "REQUEST", "=", "None", ")", ":", "BaseRoleManager", ".", "manage_role", "(", "self", ",", "role_to_manage", ",", "permissions", "=", "permissions", ")", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage_access", "(", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L51-L57
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_acquiredPermissions
(self, permissions=[], REQUEST=None)
Change the permissions that acquire.
Change the permissions that acquire.
[ "Change", "the", "permissions", "that", "acquire", "." ]
def manage_acquiredPermissions(self, permissions=[], REQUEST=None): """Change the permissions that acquire. """ BaseRoleManager.manage_acquiredPermissions( self, permissions=permissions) if REQUEST is not None: return self.manage_access(REQUEST)
[ "def", "manage_acquiredPermissions", "(", "self", ",", "permissions", "=", "[", "]", ",", "REQUEST", "=", "None", ")", ":", "BaseRoleManager", ".", "manage_acquiredPermissions", "(", "self", ",", "permissions", "=", "permissions", ")", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage_access", "(", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L68-L74
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_permission
( self, permission_to_manage, roles=[], acquire=0, REQUEST=None )
Change the settings for the given permission. If optional arg acquire is true, then the roles for the permission are acquired, in addition to the ones specified, otherwise the permissions are restricted to only the designated roles.
Change the settings for the given permission.
[ "Change", "the", "settings", "for", "the", "given", "permission", "." ]
def manage_permission( self, permission_to_manage, roles=[], acquire=0, REQUEST=None ): """Change the settings for the given permission. If optional arg acquire is true, then the roles for the permission are acquired, in addition to the ones specified, otherwise the permissions are restricted to only the designated roles. """ BaseRoleManager.manage_permission( self, permission_to_manage, roles=roles, acquire=acquire) if REQUEST is not None: return self.manage_access(REQUEST)
[ "def", "manage_permission", "(", "self", ",", "permission_to_manage", ",", "roles", "=", "[", "]", ",", "acquire", "=", "0", ",", "REQUEST", "=", "None", ")", ":", "BaseRoleManager", ".", "manage_permission", "(", "self", ",", "permission_to_manage", ",", "roles", "=", "roles", ",", "acquire", "=", "acquire", ")", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage_access", "(", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L85-L101
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_access
(self, REQUEST, **kw)
return self._normal_manage_access(**kw)
Return an interface for making permissions settings.
Return an interface for making permissions settings.
[ "Return", "an", "interface", "for", "making", "permissions", "settings", "." ]
def manage_access(self, REQUEST, **kw): """Return an interface for making permissions settings.""" return self._normal_manage_access(**kw)
[ "def", "manage_access", "(", "self", ",", "REQUEST", ",", "*", "*", "kw", ")", ":", "return", "self", ".", "_normal_manage_access", "(", "*", "*", "kw", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L110-L112
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_changePermissions
(self, REQUEST)
Change all permissions settings, called by management screen.
Change all permissions settings, called by management screen.
[ "Change", "all", "permissions", "settings", "called", "by", "management", "screen", "." ]
def manage_changePermissions(self, REQUEST): """Change all permissions settings, called by management screen.""" valid_roles = self.valid_roles() have = REQUEST.__contains__ permissions = self.ac_inherited_permissions(1) fails = [] for ip in range(len(permissions)): permission_name = permissions[ip][0] permission_hash = _string_hash(permission_name) roles = [] for role in valid_roles: role_name = role role_hash = _string_hash(role_name) if have(f"permission_{permission_hash}role_{role_hash}"): roles.append(role) name, value = permissions[ip][:2] try: p = Permission(name, value, self) if not have('acquire_%s' % permission_hash): roles = tuple(roles) p.setRoles(roles) except Exception: fails.append(name) if fails: raise BadRequest('Some permissions had errors: ' + html.escape(', '.join(fails), True)) if REQUEST is not None: return self.manage_access(REQUEST)
[ "def", "manage_changePermissions", "(", "self", ",", "REQUEST", ")", ":", "valid_roles", "=", "self", ".", "valid_roles", "(", ")", "have", "=", "REQUEST", ".", "__contains__", "permissions", "=", "self", ".", "ac_inherited_permissions", "(", "1", ")", "fails", "=", "[", "]", "for", "ip", "in", "range", "(", "len", "(", "permissions", ")", ")", ":", "permission_name", "=", "permissions", "[", "ip", "]", "[", "0", "]", "permission_hash", "=", "_string_hash", "(", "permission_name", ")", "roles", "=", "[", "]", "for", "role", "in", "valid_roles", ":", "role_name", "=", "role", "role_hash", "=", "_string_hash", "(", "role_name", ")", "if", "have", "(", "f\"permission_{permission_hash}role_{role_hash}\"", ")", ":", "roles", ".", "append", "(", "role", ")", "name", ",", "value", "=", "permissions", "[", "ip", "]", "[", ":", "2", "]", "try", ":", "p", "=", "Permission", "(", "name", ",", "value", ",", "self", ")", "if", "not", "have", "(", "'acquire_%s'", "%", "permission_hash", ")", ":", "roles", "=", "tuple", "(", "roles", ")", "p", ".", "setRoles", "(", "roles", ")", "except", "Exception", ":", "fails", ".", "append", "(", "name", ")", "if", "fails", ":", "raise", "BadRequest", "(", "'Some permissions had errors: '", "+", "html", ".", "escape", "(", "', '", ".", "join", "(", "fails", ")", ",", "True", ")", ")", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage_access", "(", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L116-L144
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_addLocalRoles
(self, userid, roles, REQUEST=None)
Set local roles for a user.
Set local roles for a user.
[ "Set", "local", "roles", "for", "a", "user", "." ]
def manage_addLocalRoles(self, userid, roles, REQUEST=None): """Set local roles for a user.""" BaseRoleManager.manage_addLocalRoles(self, userid, roles) if REQUEST is not None: stat = 'Your changes have been saved.' return self.manage_listLocalRoles(self, REQUEST, stat=stat)
[ "def", "manage_addLocalRoles", "(", "self", ",", "userid", ",", "roles", ",", "REQUEST", "=", "None", ")", ":", "BaseRoleManager", ".", "manage_addLocalRoles", "(", "self", ",", "userid", ",", "roles", ")", "if", "REQUEST", "is", "not", "None", ":", "stat", "=", "'Your changes have been saved.'", "return", "self", ".", "manage_listLocalRoles", "(", "self", ",", "REQUEST", ",", "stat", "=", "stat", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L162-L167
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_setLocalRoles
(self, userid, roles=[], REQUEST=None)
Set local roles for a user.
Set local roles for a user.
[ "Set", "local", "roles", "for", "a", "user", "." ]
def manage_setLocalRoles(self, userid, roles=[], REQUEST=None): """Set local roles for a user.""" if roles: BaseRoleManager.manage_setLocalRoles(self, userid, roles) else: return self.manage_delLocalRoles((userid,), REQUEST) if REQUEST is not None: stat = 'Your changes have been saved.' return self.manage_listLocalRoles(self, REQUEST, stat=stat)
[ "def", "manage_setLocalRoles", "(", "self", ",", "userid", ",", "roles", "=", "[", "]", ",", "REQUEST", "=", "None", ")", ":", "if", "roles", ":", "BaseRoleManager", ".", "manage_setLocalRoles", "(", "self", ",", "userid", ",", "roles", ")", "else", ":", "return", "self", ".", "manage_delLocalRoles", "(", "(", "userid", ",", ")", ",", "REQUEST", ")", "if", "REQUEST", "is", "not", "None", ":", "stat", "=", "'Your changes have been saved.'", "return", "self", ".", "manage_listLocalRoles", "(", "self", ",", "REQUEST", ",", "stat", "=", "stat", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L171-L179
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_delLocalRoles
(self, userids, REQUEST=None)
Remove all local roles for a user.
Remove all local roles for a user.
[ "Remove", "all", "local", "roles", "for", "a", "user", "." ]
def manage_delLocalRoles(self, userids, REQUEST=None): """Remove all local roles for a user.""" BaseRoleManager.manage_delLocalRoles(self, userids) if REQUEST is not None: stat = 'Your changes have been saved.' return self.manage_listLocalRoles(self, REQUEST, stat=stat)
[ "def", "manage_delLocalRoles", "(", "self", ",", "userids", ",", "REQUEST", "=", "None", ")", ":", "BaseRoleManager", ".", "manage_delLocalRoles", "(", "self", ",", "userids", ")", "if", "REQUEST", "is", "not", "None", ":", "stat", "=", "'Your changes have been saved.'", "return", "self", ".", "manage_listLocalRoles", "(", "self", ",", "REQUEST", ",", "stat", "=", "stat", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L183-L188
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/role.py
python
RoleManager.manage_defined_roles
(self, submit=None, REQUEST=None)
return self.manage_access(REQUEST)
Called by management screen.
Called by management screen.
[ "Called", "by", "management", "screen", "." ]
def manage_defined_roles(self, submit=None, REQUEST=None): """Called by management screen.""" if submit == 'Add Role': role = reqattr(REQUEST, 'role').strip() return self._addRole(role, REQUEST) if submit == 'Delete Role': roles = reqattr(REQUEST, 'roles') return self._delRoles(roles, REQUEST) return self.manage_access(REQUEST)
[ "def", "manage_defined_roles", "(", "self", ",", "submit", "=", "None", ",", "REQUEST", "=", "None", ")", ":", "if", "submit", "==", "'Add Role'", ":", "role", "=", "reqattr", "(", "REQUEST", ",", "'role'", ")", ".", "strip", "(", ")", "return", "self", ".", "_addRole", "(", "role", ",", "REQUEST", ")", "if", "submit", "==", "'Delete Role'", ":", "roles", "=", "reqattr", "(", "REQUEST", ",", "'roles'", ")", "return", "self", ".", "_delRoles", "(", "roles", ",", "REQUEST", ")", "return", "self", ".", "manage_access", "(", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/role.py#L191-L201
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/userfolder.py
python
BasicUserFolder.userFolderAddUser
(self, name, password, roles, domains, REQUEST=None, **kw)
API method for creating a new user object. Note that not all user folder implementations support dynamic creation of user objects.
API method for creating a new user object. Note that not all user folder implementations support dynamic creation of user objects.
[ "API", "method", "for", "creating", "a", "new", "user", "object", ".", "Note", "that", "not", "all", "user", "folder", "implementations", "support", "dynamic", "creation", "of", "user", "objects", "." ]
def userFolderAddUser(self, name, password, roles, domains, REQUEST=None, **kw): """API method for creating a new user object. Note that not all user folder implementations support dynamic creation of user objects.""" if hasattr(self, '_doAddUser'): return self._doAddUser(name, password, roles, domains, **kw) raise NotImplementedError
[ "def", "userFolderAddUser", "(", "self", ",", "name", ",", "password", ",", "roles", ",", "domains", ",", "REQUEST", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "hasattr", "(", "self", ",", "'_doAddUser'", ")", ":", "return", "self", ".", "_doAddUser", "(", "name", ",", "password", ",", "roles", ",", "domains", ",", "*", "*", "kw", ")", "raise", "NotImplementedError" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/userfolder.py#L58-L65
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/userfolder.py
python
BasicUserFolder.userFolderEditUser
( self, name, password, roles, domains, REQUEST=None, **kw )
API method for changing user object attributes. Note that not all user folder implementations support changing of user object attributes.
API method for changing user object attributes. Note that not all user folder implementations support changing of user object attributes.
[ "API", "method", "for", "changing", "user", "object", "attributes", ".", "Note", "that", "not", "all", "user", "folder", "implementations", "support", "changing", "of", "user", "object", "attributes", "." ]
def userFolderEditUser( self, name, password, roles, domains, REQUEST=None, **kw ): """API method for changing user object attributes. Note that not all user folder implementations support changing of user object attributes.""" if hasattr(self, '_doChangeUser'): return self._doChangeUser(name, password, roles, domains, **kw) raise NotImplementedError
[ "def", "userFolderEditUser", "(", "self", ",", "name", ",", "password", ",", "roles", ",", "domains", ",", "REQUEST", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "hasattr", "(", "self", ",", "'_doChangeUser'", ")", ":", "return", "self", ".", "_doChangeUser", "(", "name", ",", "password", ",", "roles", ",", "domains", ",", "*", "*", "kw", ")", "raise", "NotImplementedError" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/userfolder.py#L69-L83
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/userfolder.py
python
BasicUserFolder.userFolderDelUsers
(self, names, REQUEST=None)
API method for deleting one or more user objects. Note that not all user folder implementations support deletion of user objects.
API method for deleting one or more user objects. Note that not all user folder implementations support deletion of user objects.
[ "API", "method", "for", "deleting", "one", "or", "more", "user", "objects", ".", "Note", "that", "not", "all", "user", "folder", "implementations", "support", "deletion", "of", "user", "objects", "." ]
def userFolderDelUsers(self, names, REQUEST=None): """API method for deleting one or more user objects. Note that not all user folder implementations support deletion of user objects.""" if hasattr(self, '_doDelUsers'): return self._doDelUsers(names) raise NotImplementedError
[ "def", "userFolderDelUsers", "(", "self", ",", "names", ",", "REQUEST", "=", "None", ")", ":", "if", "hasattr", "(", "self", ",", "'_doDelUsers'", ")", ":", "return", "self", ".", "_doDelUsers", "(", "names", ")", "raise", "NotImplementedError" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/userfolder.py#L87-L92
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/userfolder.py
python
BasicUserFolder.manage_setUserFolderProperties
( self, encrypt_passwords=0, update_passwords=0, maxlistusers=DEFAULTMAXLISTUSERS, REQUEST=None )
Sets the properties of the user folder.
Sets the properties of the user folder.
[ "Sets", "the", "properties", "of", "the", "user", "folder", "." ]
def manage_setUserFolderProperties( self, encrypt_passwords=0, update_passwords=0, maxlistusers=DEFAULTMAXLISTUSERS, REQUEST=None ): """ Sets the properties of the user folder. """ self.encrypt_passwords = not not encrypt_passwords try: self.maxlistusers = int(maxlistusers) except ValueError: self.maxlistusers = DEFAULTMAXLISTUSERS if encrypt_passwords and update_passwords: changed = 0 for u in self.getUsers(): pw = u._getPassword() if not self._isPasswordEncrypted(pw): pw = self._encryptPassword(pw) self._doChangeUser(u.getId(), pw, u.getRoles(), u.getDomains()) changed = changed + 1 if REQUEST is not None: if not changed: msg = 'All passwords already encrypted.' else: msg = 'Encrypted %d password(s).' % changed return self.manage_userFolderProperties( REQUEST, manage_tabs_message=msg) else: return changed else: if REQUEST is not None: return self.manage_userFolderProperties( REQUEST, manage_tabs_message='Saved changes.')
[ "def", "manage_setUserFolderProperties", "(", "self", ",", "encrypt_passwords", "=", "0", ",", "update_passwords", "=", "0", ",", "maxlistusers", "=", "DEFAULTMAXLISTUSERS", ",", "REQUEST", "=", "None", ")", ":", "self", ".", "encrypt_passwords", "=", "not", "not", "encrypt_passwords", "try", ":", "self", ".", "maxlistusers", "=", "int", "(", "maxlistusers", ")", "except", "ValueError", ":", "self", ".", "maxlistusers", "=", "DEFAULTMAXLISTUSERS", "if", "encrypt_passwords", "and", "update_passwords", ":", "changed", "=", "0", "for", "u", "in", "self", ".", "getUsers", "(", ")", ":", "pw", "=", "u", ".", "_getPassword", "(", ")", "if", "not", "self", ".", "_isPasswordEncrypted", "(", "pw", ")", ":", "pw", "=", "self", ".", "_encryptPassword", "(", "pw", ")", "self", ".", "_doChangeUser", "(", "u", ".", "getId", "(", ")", ",", "pw", ",", "u", ".", "getRoles", "(", ")", ",", "u", ".", "getDomains", "(", ")", ")", "changed", "=", "changed", "+", "1", "if", "REQUEST", "is", "not", "None", ":", "if", "not", "changed", ":", "msg", "=", "'All passwords already encrypted.'", "else", ":", "msg", "=", "'Encrypted %d password(s).'", "%", "changed", "return", "self", ".", "manage_userFolderProperties", "(", "REQUEST", ",", "manage_tabs_message", "=", "msg", ")", "else", ":", "return", "changed", "else", ":", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage_userFolderProperties", "(", "REQUEST", ",", "manage_tabs_message", "=", "'Saved changes.'", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/userfolder.py#L119-L155
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/userfolder.py
python
BasicUserFolder.manage_users
(self, submit=None, REQUEST=None, RESPONSE=None)
return self._mainUser(self, REQUEST)
This method handles operations on users for the web based forms of the ZMI. Application code (code that is outside of the forms that implement the UI of a user folder) are encouraged to use manage_std_addUser
This method handles operations on users for the web based forms of the ZMI. Application code (code that is outside of the forms that implement the UI of a user folder) are encouraged to use manage_std_addUser
[ "This", "method", "handles", "operations", "on", "users", "for", "the", "web", "based", "forms", "of", "the", "ZMI", ".", "Application", "code", "(", "code", "that", "is", "outside", "of", "the", "forms", "that", "implement", "the", "UI", "of", "a", "user", "folder", ")", "are", "encouraged", "to", "use", "manage_std_addUser" ]
def manage_users(self, submit=None, REQUEST=None, RESPONSE=None): """This method handles operations on users for the web based forms of the ZMI. Application code (code that is outside of the forms that implement the UI of a user folder) are encouraged to use manage_std_addUser""" if submit == 'Add...': return self._add_User(self, REQUEST) if submit == 'Edit': try: user = self.getUser(reqattr(REQUEST, 'name')) except Exception: raise BadRequest('The specified user does not exist') return self._editUser(self, REQUEST, user=user, password=user.__) if submit == 'Add': name = reqattr(REQUEST, 'name') password = reqattr(REQUEST, 'password') confirm = reqattr(REQUEST, 'confirm') roles = reqattr(REQUEST, 'roles') domains = reqattr(REQUEST, 'domains') return self._addUser(name, password, confirm, roles, domains, REQUEST) if submit == 'Change': name = reqattr(REQUEST, 'name') password = reqattr(REQUEST, 'password') confirm = reqattr(REQUEST, 'confirm') roles = reqattr(REQUEST, 'roles') domains = reqattr(REQUEST, 'domains') return self._changeUser(name, password, confirm, roles, domains, REQUEST) if submit == 'Delete': names = reqattr(REQUEST, 'names') return self._delUsers(names, REQUEST) return self._mainUser(self, REQUEST)
[ "def", "manage_users", "(", "self", ",", "submit", "=", "None", ",", "REQUEST", "=", "None", ",", "RESPONSE", "=", "None", ")", ":", "if", "submit", "==", "'Add...'", ":", "return", "self", ".", "_add_User", "(", "self", ",", "REQUEST", ")", "if", "submit", "==", "'Edit'", ":", "try", ":", "user", "=", "self", ".", "getUser", "(", "reqattr", "(", "REQUEST", ",", "'name'", ")", ")", "except", "Exception", ":", "raise", "BadRequest", "(", "'The specified user does not exist'", ")", "return", "self", ".", "_editUser", "(", "self", ",", "REQUEST", ",", "user", "=", "user", ",", "password", "=", "user", ".", "__", ")", "if", "submit", "==", "'Add'", ":", "name", "=", "reqattr", "(", "REQUEST", ",", "'name'", ")", "password", "=", "reqattr", "(", "REQUEST", ",", "'password'", ")", "confirm", "=", "reqattr", "(", "REQUEST", ",", "'confirm'", ")", "roles", "=", "reqattr", "(", "REQUEST", ",", "'roles'", ")", "domains", "=", "reqattr", "(", "REQUEST", ",", "'domains'", ")", "return", "self", ".", "_addUser", "(", "name", ",", "password", ",", "confirm", ",", "roles", ",", "domains", ",", "REQUEST", ")", "if", "submit", "==", "'Change'", ":", "name", "=", "reqattr", "(", "REQUEST", ",", "'name'", ")", "password", "=", "reqattr", "(", "REQUEST", ",", "'password'", ")", "confirm", "=", "reqattr", "(", "REQUEST", ",", "'confirm'", ")", "roles", "=", "reqattr", "(", "REQUEST", ",", "'roles'", ")", "domains", "=", "reqattr", "(", "REQUEST", ",", "'domains'", ")", "return", "self", ".", "_changeUser", "(", "name", ",", "password", ",", "confirm", ",", "roles", ",", "domains", ",", "REQUEST", ")", "if", "submit", "==", "'Delete'", ":", "names", "=", "reqattr", "(", "REQUEST", ",", "'names'", ")", "return", "self", ".", "_delUsers", "(", "names", ",", "REQUEST", ")", "return", "self", ".", "_mainUser", "(", "self", ",", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/userfolder.py#L217-L254
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/userfolder.py
python
UserFolder._createInitialUser
(self)
If there are no users or only one user in this user folder, populates from the 'inituser' file in the instance home. We have to do this even when there is already a user just in case the initial user ignored the setup messages. We don't do it for more than one user to avoid abuse of this mechanism. Called only by OFS.Application.initialize().
If there are no users or only one user in this user folder, populates from the 'inituser' file in the instance home. We have to do this even when there is already a user just in case the initial user ignored the setup messages. We don't do it for more than one user to avoid abuse of this mechanism. Called only by OFS.Application.initialize().
[ "If", "there", "are", "no", "users", "or", "only", "one", "user", "in", "this", "user", "folder", "populates", "from", "the", "inituser", "file", "in", "the", "instance", "home", ".", "We", "have", "to", "do", "this", "even", "when", "there", "is", "already", "a", "user", "just", "in", "case", "the", "initial", "user", "ignored", "the", "setup", "messages", ".", "We", "don", "t", "do", "it", "for", "more", "than", "one", "user", "to", "avoid", "abuse", "of", "this", "mechanism", ".", "Called", "only", "by", "OFS", ".", "Application", ".", "initialize", "()", "." ]
def _createInitialUser(self): """ If there are no users or only one user in this user folder, populates from the 'inituser' file in the instance home. We have to do this even when there is already a user just in case the initial user ignored the setup messages. We don't do it for more than one user to avoid abuse of this mechanism. Called only by OFS.Application.initialize(). """ if len(self.data) <= 1: info = readUserAccessFile('inituser') if info: import App.config name, password, domains, remote_user_mode = info self._doDelUsers(self.getUserNames()) self._doAddUser(name, password, ('Manager', ), domains) cfg = App.config.getConfiguration() try: os.remove(os.path.join(cfg.instancehome, 'inituser')) except Exception: pass
[ "def", "_createInitialUser", "(", "self", ")", ":", "if", "len", "(", "self", ".", "data", ")", "<=", "1", ":", "info", "=", "readUserAccessFile", "(", "'inituser'", ")", "if", "info", ":", "import", "App", ".", "config", "name", ",", "password", ",", "domains", ",", "remote_user_mode", "=", "info", "self", ".", "_doDelUsers", "(", "self", ".", "getUserNames", "(", ")", ")", "self", ".", "_doAddUser", "(", "name", ",", "password", ",", "(", "'Manager'", ",", ")", ",", "domains", ")", "cfg", "=", "App", ".", "config", ".", "getConfiguration", "(", ")", "try", ":", "os", ".", "remove", "(", "os", ".", "path", ".", "join", "(", "cfg", ".", "instancehome", ",", "'inituser'", ")", ")", "except", "Exception", ":", "pass" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/userfolder.py#L290-L311
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/SimpleItem.py
python
PathReprProvider.__repr__
(self)
return res
Show the physical path of the object and context if available.
Show the physical path of the object and context if available.
[ "Show", "the", "physical", "path", "of", "the", "object", "and", "context", "if", "available", "." ]
def __repr__(self): """Show the physical path of the object and context if available.""" try: path = '/'.join(self.getPhysicalPath()) except Exception: return super().__repr__() context_path = None context = aq_parent(self) container = aq_parent(aq_inner(self)) if aq_base(context) is not aq_base(container): try: context_path = '/'.join(context.getPhysicalPath()) except Exception: context_path = None res = '<%s' % self.__class__.__name__ res += ' at %s' % path if context_path: res += ' used for %s' % context_path res += '>' return res
[ "def", "__repr__", "(", "self", ")", ":", "try", ":", "path", "=", "'/'", ".", "join", "(", "self", ".", "getPhysicalPath", "(", ")", ")", "except", "Exception", ":", "return", "super", "(", ")", ".", "__repr__", "(", ")", "context_path", "=", "None", "context", "=", "aq_parent", "(", "self", ")", "container", "=", "aq_parent", "(", "aq_inner", "(", "self", ")", ")", "if", "aq_base", "(", "context", ")", "is", "not", "aq_base", "(", "container", ")", ":", "try", ":", "context_path", "=", "'/'", ".", "join", "(", "context", ".", "getPhysicalPath", "(", ")", ")", "except", "Exception", ":", "context_path", "=", "None", "res", "=", "'<%s'", "%", "self", ".", "__class__", ".", "__name__", "res", "+=", "' at %s'", "%", "path", "if", "context_path", ":", "res", "+=", "' used for %s'", "%", "context_path", "res", "+=", "'>'", "return", "res" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/SimpleItem.py#L70-L89
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/DTMLDocument.py
python
addDTMLDocument
(self, id, title='', file='', REQUEST=None, submit=None)
return ''
Add a DTML Document object with the contents of file. If 'file' is empty, default document text is used.
Add a DTML Document object with the contents of file. If 'file' is empty, default document text is used.
[ "Add", "a", "DTML", "Document", "object", "with", "the", "contents", "of", "file", ".", "If", "file", "is", "empty", "default", "document", "text", "is", "used", "." ]
def addDTMLDocument(self, id, title='', file='', REQUEST=None, submit=None): """Add a DTML Document object with the contents of file. If 'file' is empty, default document text is used. """ data = safe_file_data(file) if not data: data = default_dd_html id = str(id) title = str(title) ob = DTMLDocument(data, __name__=id) ob.title = title id = self._setObject(id, ob) if REQUEST is not None: try: u = self.DestinationURL() except Exception: u = REQUEST['URL1'] if submit == "Add and Edit": u = f"{u}/{quote(id)}" REQUEST.RESPONSE.redirect(u + '/manage_main') return ''
[ "def", "addDTMLDocument", "(", "self", ",", "id", ",", "title", "=", "''", ",", "file", "=", "''", ",", "REQUEST", "=", "None", ",", "submit", "=", "None", ")", ":", "data", "=", "safe_file_data", "(", "file", ")", "if", "not", "data", ":", "data", "=", "default_dd_html", "id", "=", "str", "(", "id", ")", "title", "=", "str", "(", "title", ")", "ob", "=", "DTMLDocument", "(", "data", ",", "__name__", "=", "id", ")", "ob", ".", "title", "=", "title", "id", "=", "self", ".", "_setObject", "(", "id", ",", "ob", ")", "if", "REQUEST", "is", "not", "None", ":", "try", ":", "u", "=", "self", ".", "DestinationURL", "(", ")", "except", "Exception", ":", "u", "=", "REQUEST", "[", "'URL1'", "]", "if", "submit", "==", "\"Add and Edit\"", ":", "u", "=", "f\"{u}/{quote(id)}\"", "REQUEST", ".", "RESPONSE", ".", "redirect", "(", "u", "+", "'/manage_main'", ")", "return", "''" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/DTMLDocument.py#L134-L154
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/DTMLDocument.py
python
DTMLDocument.__call__
(self, client=None, REQUEST={}, RESPONSE=None, **kw)
return result
Render the document with the given client object. o If supplied, use REQUEST mapping, Response, and key word arguments.
Render the document with the given client object.
[ "Render", "the", "document", "with", "the", "given", "client", "object", "." ]
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw): """Render the document with the given client object. o If supplied, use REQUEST mapping, Response, and key word arguments. """ if not self._cache_namespace_keys: data = self.ZCacheable_get(default=_marker) if data is not _marker: # Return cached results. return data __traceback_supplement__ = (PathTracebackSupplement, self) kw['document_id'] = self.getId() kw['document_title'] = self.title if hasattr(self, 'aq_explicit'): bself = self.aq_explicit else: bself = self security = getSecurityManager() security.addContext(self) try: if client is None: # Called as subtemplate, so don't need error propagation! r = HTML.__call__(self, bself, REQUEST, **kw) if RESPONSE is None: result = r else: result = decapitate(r, RESPONSE) if not self._cache_namespace_keys: self.ZCacheable_set(result) return result r = HTML.__call__(self, (client, bself), REQUEST, **kw) if RESPONSE is None or not isinstance(r, str): if not self._cache_namespace_keys: self.ZCacheable_set(r) return r finally: security.removeContext(self) have_key = RESPONSE.headers.__contains__ if not (have_key('content-type') or have_key('Content-Type')): if 'content_type' in self.__dict__: c = self.content_type else: encoding = getattr(self, 'encoding', default_encoding) c, e = guess_content_type(self.getId(), r.encode(encoding)) RESPONSE.setHeader('Content-Type', c) result = decapitate(r, RESPONSE) if not self._cache_namespace_keys: self.ZCacheable_set(result) return result
[ "def", "__call__", "(", "self", ",", "client", "=", "None", ",", "REQUEST", "=", "{", "}", ",", "RESPONSE", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "not", "self", ".", "_cache_namespace_keys", ":", "data", "=", "self", ".", "ZCacheable_get", "(", "default", "=", "_marker", ")", "if", "data", "is", "not", "_marker", ":", "# Return cached results.", "return", "data", "__traceback_supplement__", "=", "(", "PathTracebackSupplement", ",", "self", ")", "kw", "[", "'document_id'", "]", "=", "self", ".", "getId", "(", ")", "kw", "[", "'document_title'", "]", "=", "self", ".", "title", "if", "hasattr", "(", "self", ",", "'aq_explicit'", ")", ":", "bself", "=", "self", ".", "aq_explicit", "else", ":", "bself", "=", "self", "security", "=", "getSecurityManager", "(", ")", "security", ".", "addContext", "(", "self", ")", "try", ":", "if", "client", "is", "None", ":", "# Called as subtemplate, so don't need error propagation!", "r", "=", "HTML", ".", "__call__", "(", "self", ",", "bself", ",", "REQUEST", ",", "*", "*", "kw", ")", "if", "RESPONSE", "is", "None", ":", "result", "=", "r", "else", ":", "result", "=", "decapitate", "(", "r", ",", "RESPONSE", ")", "if", "not", "self", ".", "_cache_namespace_keys", ":", "self", ".", "ZCacheable_set", "(", "result", ")", "return", "result", "r", "=", "HTML", ".", "__call__", "(", "self", ",", "(", "client", ",", "bself", ")", ",", "REQUEST", ",", "*", "*", "kw", ")", "if", "RESPONSE", "is", "None", "or", "not", "isinstance", "(", "r", ",", "str", ")", ":", "if", "not", "self", ".", "_cache_namespace_keys", ":", "self", ".", "ZCacheable_set", "(", "r", ")", "return", "r", "finally", ":", "security", ".", "removeContext", "(", "self", ")", "have_key", "=", "RESPONSE", ".", "headers", ".", "__contains__", "if", "not", "(", "have_key", "(", "'content-type'", ")", "or", "have_key", "(", "'Content-Type'", ")", ")", ":", "if", "'content_type'", "in", "self", ".", "__dict__", ":", "c", "=", "self", ".", "content_type", "else", ":", "encoding", "=", "getattr", "(", "self", ",", "'encoding'", ",", "default_encoding", ")", "c", ",", "e", "=", "guess_content_type", "(", "self", ".", "getId", "(", ")", ",", "r", ".", "encode", "(", "encoding", ")", ")", "RESPONSE", ".", "setHeader", "(", "'Content-Type'", ",", "c", ")", "result", "=", "decapitate", "(", "r", ",", "RESPONSE", ")", "if", "not", "self", ".", "_cache_namespace_keys", ":", "self", ".", "ZCacheable_set", "(", "result", ")", "return", "result" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/DTMLDocument.py#L55-L110
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Moniker.py
python
loadMoniker
(data)
return m
Re-creates a Moniker object from the given data which had been generated by Moniker.dump().
Re-creates a Moniker object from the given data which had been generated by Moniker.dump().
[ "Re", "-", "creates", "a", "Moniker", "object", "from", "the", "given", "data", "which", "had", "been", "generated", "by", "Moniker", ".", "dump", "()", "." ]
def loadMoniker(data): '''Re-creates a Moniker object from the given data which had been generated by Moniker.dump().''' m = Moniker() m.idpath = data return m
[ "def", "loadMoniker", "(", "data", ")", ":", "m", "=", "Moniker", "(", ")", "m", ".", "idpath", "=", "data", "return", "m" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Moniker.py#L45-L50
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Moniker.py
python
Moniker.bind
(self, app)
return ob
Returns the real object named by this moniker
Returns the real object named by this moniker
[ "Returns", "the", "real", "object", "named", "by", "this", "moniker" ]
def bind(self, app): "Returns the real object named by this moniker" ob = app.unrestrictedTraverse(self.idpath) return ob
[ "def", "bind", "(", "self", ",", "app", ")", ":", "ob", "=", "app", ".", "unrestrictedTraverse", "(", "self", ".", "idpath", ")", "return", "ob" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Moniker.py#L33-L36
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Moniker.py
python
Moniker.dump
(self)
return self.idpath
Returns an object which can be reconstituted by loadMoniker(). Result must be compatible with marshal.dump().
Returns an object which can be reconstituted by loadMoniker(). Result must be compatible with marshal.dump().
[ "Returns", "an", "object", "which", "can", "be", "reconstituted", "by", "loadMoniker", "()", ".", "Result", "must", "be", "compatible", "with", "marshal", ".", "dump", "()", "." ]
def dump(self): '''Returns an object which can be reconstituted by loadMoniker(). Result must be compatible with marshal.dump(). ''' return self.idpath
[ "def", "dump", "(", "self", ")", ":", "return", "self", ".", "idpath" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Moniker.py#L38-L42
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/DTMLMethod.py
python
addDTMLMethod
(self, id, title='', file='', REQUEST=None, submit=None)
return ''
Add a DTML Method object with the contents of file. If 'file' is empty, default document text is used.
Add a DTML Method object with the contents of file. If 'file' is empty, default document text is used.
[ "Add", "a", "DTML", "Method", "object", "with", "the", "contents", "of", "file", ".", "If", "file", "is", "empty", "default", "document", "text", "is", "used", "." ]
def addDTMLMethod(self, id, title='', file='', REQUEST=None, submit=None): """Add a DTML Method object with the contents of file. If 'file' is empty, default document text is used. """ data = safe_file_data(file) if not data: data = default_dm_html id = str(id) title = str(title) ob = DTMLMethod(data, __name__=id) ob.title = title id = self._setObject(id, ob) if REQUEST is not None: try: u = self.DestinationURL() except Exception: u = REQUEST['URL1'] if submit == "Add and Edit": u = f"{u}/{quote(id)}" REQUEST.RESPONSE.redirect(u + '/manage_main') return ''
[ "def", "addDTMLMethod", "(", "self", ",", "id", ",", "title", "=", "''", ",", "file", "=", "''", ",", "REQUEST", "=", "None", ",", "submit", "=", "None", ")", ":", "data", "=", "safe_file_data", "(", "file", ")", "if", "not", "data", ":", "data", "=", "default_dm_html", "id", "=", "str", "(", "id", ")", "title", "=", "str", "(", "title", ")", "ob", "=", "DTMLMethod", "(", "data", ",", "__name__", "=", "id", ")", "ob", ".", "title", "=", "title", "id", "=", "self", ".", "_setObject", "(", "id", ",", "ob", ")", "if", "REQUEST", "is", "not", "None", ":", "try", ":", "u", "=", "self", ".", "DestinationURL", "(", ")", "except", "Exception", ":", "u", "=", "REQUEST", "[", "'URL1'", "]", "if", "submit", "==", "\"Add and Edit\"", ":", "u", "=", "f\"{u}/{quote(id)}\"", "REQUEST", ".", "RESPONSE", ".", "redirect", "(", "u", "+", "'/manage_main'", ")", "return", "''" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/DTMLMethod.py#L456-L476
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/DTMLMethod.py
python
DTMLMethod.__call__
(self, client=None, REQUEST={}, RESPONSE=None, **kw)
return result
Render using the given client object o If client is not passed, we are being called as a sub-template: don't do any error propagation. o If supplied, use the REQUEST mapping, Response, and key word arguments.
Render using the given client object
[ "Render", "using", "the", "given", "client", "object" ]
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw): """Render using the given client object o If client is not passed, we are being called as a sub-template: don't do any error propagation. o If supplied, use the REQUEST mapping, Response, and key word arguments. """ if not self._cache_namespace_keys: data = self.ZCacheable_get(default=_marker) if data is not _marker: if IStreamIterator.isImplementedBy(data) and \ RESPONSE is not None: # This is a stream iterator and we need to set some # headers now before giving it to medusa headers_get = RESPONSE.headers.get if headers_get('content-length', None) is None: RESPONSE.setHeader('content-length', len(data)) if headers_get('content-type', None) is None and \ headers_get('Content-type', None) is None: ct = (self.__dict__.get('content_type') or self.default_content_type) RESPONSE.setHeader('content-type', ct) # Return cached results. return data __traceback_supplement__ = (PathTracebackSupplement, self) kw['document_id'] = self.getId() kw['document_title'] = self.title security = getSecurityManager() security.addContext(self) if 'validate' in self.__dict__: first_time_through = 0 else: self.__dict__['validate'] = security.DTMLValidate first_time_through = 1 try: if client is None: # Called as subtemplate, so don't need error propagation! r = HTML.__call__(self, client, REQUEST, **kw) if RESPONSE is None: result = r else: result = decapitate(r, RESPONSE) if not self._cache_namespace_keys: self.ZCacheable_set(result) return result r = HTML.__call__(self, client, REQUEST, **kw) if RESPONSE is None or not isinstance(r, str): if not self._cache_namespace_keys: self.ZCacheable_set(r) return r finally: security.removeContext(self) if first_time_through: del self.__dict__['validate'] have_key = RESPONSE.headers.__contains__ if not (have_key('content-type') or have_key('Content-Type')): if 'content_type' in self.__dict__: c = self.content_type else: encoding = getattr(self, 'encoding', default_encoding) c, e = guess_content_type(self.getId(), r.encode(encoding)) RESPONSE.setHeader('Content-Type', c) result = decapitate(r, RESPONSE) if not self._cache_namespace_keys: self.ZCacheable_set(result) return result
[ "def", "__call__", "(", "self", ",", "client", "=", "None", ",", "REQUEST", "=", "{", "}", ",", "RESPONSE", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "not", "self", ".", "_cache_namespace_keys", ":", "data", "=", "self", ".", "ZCacheable_get", "(", "default", "=", "_marker", ")", "if", "data", "is", "not", "_marker", ":", "if", "IStreamIterator", ".", "isImplementedBy", "(", "data", ")", "and", "RESPONSE", "is", "not", "None", ":", "# This is a stream iterator and we need to set some", "# headers now before giving it to medusa", "headers_get", "=", "RESPONSE", ".", "headers", ".", "get", "if", "headers_get", "(", "'content-length'", ",", "None", ")", "is", "None", ":", "RESPONSE", ".", "setHeader", "(", "'content-length'", ",", "len", "(", "data", ")", ")", "if", "headers_get", "(", "'content-type'", ",", "None", ")", "is", "None", "and", "headers_get", "(", "'Content-type'", ",", "None", ")", "is", "None", ":", "ct", "=", "(", "self", ".", "__dict__", ".", "get", "(", "'content_type'", ")", "or", "self", ".", "default_content_type", ")", "RESPONSE", ".", "setHeader", "(", "'content-type'", ",", "ct", ")", "# Return cached results.", "return", "data", "__traceback_supplement__", "=", "(", "PathTracebackSupplement", ",", "self", ")", "kw", "[", "'document_id'", "]", "=", "self", ".", "getId", "(", ")", "kw", "[", "'document_title'", "]", "=", "self", ".", "title", "security", "=", "getSecurityManager", "(", ")", "security", ".", "addContext", "(", "self", ")", "if", "'validate'", "in", "self", ".", "__dict__", ":", "first_time_through", "=", "0", "else", ":", "self", ".", "__dict__", "[", "'validate'", "]", "=", "security", ".", "DTMLValidate", "first_time_through", "=", "1", "try", ":", "if", "client", "is", "None", ":", "# Called as subtemplate, so don't need error propagation!", "r", "=", "HTML", ".", "__call__", "(", "self", ",", "client", ",", "REQUEST", ",", "*", "*", "kw", ")", "if", "RESPONSE", "is", "None", ":", "result", "=", "r", "else", ":", "result", "=", "decapitate", "(", "r", ",", "RESPONSE", ")", "if", "not", "self", ".", "_cache_namespace_keys", ":", "self", ".", "ZCacheable_set", "(", "result", ")", "return", "result", "r", "=", "HTML", ".", "__call__", "(", "self", ",", "client", ",", "REQUEST", ",", "*", "*", "kw", ")", "if", "RESPONSE", "is", "None", "or", "not", "isinstance", "(", "r", ",", "str", ")", ":", "if", "not", "self", ".", "_cache_namespace_keys", ":", "self", ".", "ZCacheable_set", "(", "r", ")", "return", "r", "finally", ":", "security", ".", "removeContext", "(", "self", ")", "if", "first_time_through", ":", "del", "self", ".", "__dict__", "[", "'validate'", "]", "have_key", "=", "RESPONSE", ".", "headers", ".", "__contains__", "if", "not", "(", "have_key", "(", "'content-type'", ")", "or", "have_key", "(", "'Content-Type'", ")", ")", ":", "if", "'content_type'", "in", "self", ".", "__dict__", ":", "c", "=", "self", ".", "content_type", "else", ":", "encoding", "=", "getattr", "(", "self", ",", "'encoding'", ",", "default_encoding", ")", "c", ",", "e", "=", "guess_content_type", "(", "self", ".", "getId", "(", ")", ",", "r", ".", "encode", "(", "encoding", ")", ")", "RESPONSE", ".", "setHeader", "(", "'Content-Type'", ",", "c", ")", "result", "=", "decapitate", "(", "r", ",", "RESPONSE", ")", "if", "not", "self", ".", "_cache_namespace_keys", ":", "self", ".", "ZCacheable_set", "(", "result", ")", "return", "result" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/DTMLMethod.py#L116-L193
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/DTMLMethod.py
python
DTMLMethod.manage_edit
(self, data, title, SUBMIT='Change', REQUEST=None)
Replace contents with 'data', title with 'title'.
Replace contents with 'data', title with 'title'.
[ "Replace", "contents", "with", "data", "title", "with", "title", "." ]
def manage_edit(self, data, title, SUBMIT='Change', REQUEST=None): """ Replace contents with 'data', title with 'title'. """ self._validateProxy() if self.wl_isLocked(): raise ResourceLockedError(self._locked_error_text) self.title = str(title) if isinstance(data, TaintedString): data = data.quoted() if hasattr(data, 'read'): data = data.read() try: self.munge(data) except ParseError as e: if REQUEST: return self.manage_main( self, REQUEST, manage_tabs_message=e, manage_tabs_type='warning') else: raise self.ZCacheable_invalidate() if REQUEST: message = "Saved changes." return self.manage_main(self, REQUEST, manage_tabs_message=message)
[ "def", "manage_edit", "(", "self", ",", "data", ",", "title", ",", "SUBMIT", "=", "'Change'", ",", "REQUEST", "=", "None", ")", ":", "self", ".", "_validateProxy", "(", ")", "if", "self", ".", "wl_isLocked", "(", ")", ":", "raise", "ResourceLockedError", "(", "self", ".", "_locked_error_text", ")", "self", ".", "title", "=", "str", "(", "title", ")", "if", "isinstance", "(", "data", ",", "TaintedString", ")", ":", "data", "=", "data", ".", "quoted", "(", ")", "if", "hasattr", "(", "data", ",", "'read'", ")", ":", "data", "=", "data", ".", "read", "(", ")", "try", ":", "self", ".", "munge", "(", "data", ")", "except", "ParseError", "as", "e", ":", "if", "REQUEST", ":", "return", "self", ".", "manage_main", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "e", ",", "manage_tabs_type", "=", "'warning'", ")", "else", ":", "raise", "self", ".", "ZCacheable_invalidate", "(", ")", "if", "REQUEST", ":", "message", "=", "\"Saved changes.\"", "return", "self", ".", "manage_main", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "message", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/DTMLMethod.py#L269-L294
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/DTMLMethod.py
python
DTMLMethod.manage_upload
(self, file='', REQUEST=None)
Replace the contents of the document with the text in 'file'. Store `file` as a native `str`.
Replace the contents of the document with the text in 'file'.
[ "Replace", "the", "contents", "of", "the", "document", "with", "the", "text", "in", "file", "." ]
def manage_upload(self, file='', REQUEST=None): """ Replace the contents of the document with the text in 'file'. Store `file` as a native `str`. """ self._validateProxy() if self.wl_isLocked(): if REQUEST is not None: return self.manage_main( self, REQUEST, manage_tabs_message=self._locked_error_text, manage_tabs_type='warning') raise ResourceLockedError(self._locked_error_text) if REQUEST is not None and not file: return self.manage_main( self, REQUEST, manage_tabs_message='No file specified', manage_tabs_type='warning') self.munge(safe_file_data(file)) self.ZCacheable_invalidate() if REQUEST is not None: message = "Content uploaded." return self.manage_main(self, REQUEST, manage_tabs_message=message)
[ "def", "manage_upload", "(", "self", ",", "file", "=", "''", ",", "REQUEST", "=", "None", ")", ":", "self", ".", "_validateProxy", "(", ")", "if", "self", ".", "wl_isLocked", "(", ")", ":", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage_main", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "self", ".", "_locked_error_text", ",", "manage_tabs_type", "=", "'warning'", ")", "raise", "ResourceLockedError", "(", "self", ".", "_locked_error_text", ")", "if", "REQUEST", "is", "not", "None", "and", "not", "file", ":", "return", "self", ".", "manage_main", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "'No file specified'", ",", "manage_tabs_type", "=", "'warning'", ")", "self", ".", "munge", "(", "safe_file_data", "(", "file", ")", ")", "self", ".", "ZCacheable_invalidate", "(", ")", "if", "REQUEST", "is", "not", "None", ":", "message", "=", "\"Content uploaded.\"", "return", "self", ".", "manage_main", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "message", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/DTMLMethod.py#L297-L321
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/DTMLMethod.py
python
DTMLMethod.manage_proxy
(self, roles=(), REQUEST=None)
Change Proxy Roles
Change Proxy Roles
[ "Change", "Proxy", "Roles" ]
def manage_proxy(self, roles=(), REQUEST=None): """Change Proxy Roles""" user = getSecurityManager().getUser() if 'Manager' not in user.getRolesInContext(self): self._validateProxy(roles) self._validateProxy() self.ZCacheable_invalidate() self._proxy_roles = tuple(roles) if REQUEST: message = "Saved changes." return self.manage_proxyForm(self, REQUEST, manage_tabs_message=message)
[ "def", "manage_proxy", "(", "self", ",", "roles", "=", "(", ")", ",", "REQUEST", "=", "None", ")", ":", "user", "=", "getSecurityManager", "(", ")", ".", "getUser", "(", ")", "if", "'Manager'", "not", "in", "user", ".", "getRolesInContext", "(", "self", ")", ":", "self", ".", "_validateProxy", "(", "roles", ")", "self", ".", "_validateProxy", "(", ")", "self", ".", "ZCacheable_invalidate", "(", ")", "self", ".", "_proxy_roles", "=", "tuple", "(", "roles", ")", "if", "REQUEST", ":", "message", "=", "\"Saved changes.\"", "return", "self", ".", "manage_proxyForm", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "message", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/DTMLMethod.py#L341-L352
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/DTMLMethod.py
python
DTMLMethod.PUT
(self, REQUEST, RESPONSE)
return RESPONSE
Handle HTTP PUT requests.
Handle HTTP PUT requests.
[ "Handle", "HTTP", "PUT", "requests", "." ]
def PUT(self, REQUEST, RESPONSE): """ Handle HTTP PUT requests. """ self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) body = safe_file_data(REQUEST.get('BODY', '')) self._validateProxy() self.munge(body) self.ZCacheable_invalidate() RESPONSE.setStatus(204) return RESPONSE
[ "def", "PUT", "(", "self", ",", "REQUEST", ",", "RESPONSE", ")", ":", "self", ".", "dav__init", "(", "REQUEST", ",", "RESPONSE", ")", "self", ".", "dav__simpleifhandler", "(", "REQUEST", ",", "RESPONSE", ",", "refresh", "=", "1", ")", "body", "=", "safe_file_data", "(", "REQUEST", ".", "get", "(", "'BODY'", ",", "''", ")", ")", "self", ".", "_validateProxy", "(", ")", "self", ".", "munge", "(", "body", ")", "self", ".", "ZCacheable_invalidate", "(", ")", "RESPONSE", ".", "setStatus", "(", "204", ")", "return", "RESPONSE" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/DTMLMethod.py#L367-L377
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Lockable.py
python
wl_isLocked
(ob)
return wl_isLockable(ob) and ob.wl_isLocked()
Returns true if the object is locked, returns 0 if the object is not locked or does not implement the WriteLockInterface
Returns true if the object is locked, returns 0 if the object is not locked or does not implement the WriteLockInterface
[ "Returns", "true", "if", "the", "object", "is", "locked", "returns", "0", "if", "the", "object", "is", "not", "locked", "or", "does", "not", "implement", "the", "WriteLockInterface" ]
def wl_isLocked(ob): """ Returns true if the object is locked, returns 0 if the object is not locked or does not implement the WriteLockInterface """ return wl_isLockable(ob) and ob.wl_isLocked()
[ "def", "wl_isLocked", "(", "ob", ")", ":", "return", "wl_isLockable", "(", "ob", ")", "and", "ob", ".", "wl_isLocked", "(", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Lockable.py#L146-L149
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/CopySupport.py
python
_cb_encode
(d)
return base64.encodebytes(squashed_bytes)
Encode a list of IDs for storage in a cookie. ``d`` must be a list or tuple of text IDs. Return text.
Encode a list of IDs for storage in a cookie.
[ "Encode", "a", "list", "of", "IDs", "for", "storage", "in", "a", "cookie", "." ]
def _cb_encode(d): """Encode a list of IDs for storage in a cookie. ``d`` must be a list or tuple of text IDs. Return text. """ json_bytes = dumps(d).encode('utf-8') squashed_bytes = compress(json_bytes, 2) # -> bytes w/ useful encoding # quote for embeding in cookie return base64.encodebytes(squashed_bytes)
[ "def", "_cb_encode", "(", "d", ")", ":", "json_bytes", "=", "dumps", "(", "d", ")", ".", "encode", "(", "'utf-8'", ")", "squashed_bytes", "=", "compress", "(", "json_bytes", ",", "2", ")", "# -> bytes w/ useful encoding", "# quote for embeding in cookie", "return", "base64", ".", "encodebytes", "(", "squashed_bytes", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/CopySupport.py#L661-L671
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/CopySupport.py
python
_cb_decode
(s, maxsize=8192)
return loads(json_bytes)
Decode a list of IDs from storage in a cookie. ``s`` is text as encoded by ``_cb_encode``. ``maxsize`` is the maximum size of uncompressed data. ``0`` means no limit. Return a list of text IDs.
Decode a list of IDs from storage in a cookie.
[ "Decode", "a", "list", "of", "IDs", "from", "storage", "in", "a", "cookie", "." ]
def _cb_decode(s, maxsize=8192): """Decode a list of IDs from storage in a cookie. ``s`` is text as encoded by ``_cb_encode``. ``maxsize`` is the maximum size of uncompressed data. ``0`` means no limit. Return a list of text IDs. """ dec = decompressobj() if isinstance(s, str): s = s.encode('latin-1') data = dec.decompress(base64.decodebytes(s), maxsize) if dec.unconsumed_tail: raise ValueError json_bytes = data.decode('utf-8') return loads(json_bytes)
[ "def", "_cb_decode", "(", "s", ",", "maxsize", "=", "8192", ")", ":", "dec", "=", "decompressobj", "(", ")", "if", "isinstance", "(", "s", ",", "str", ")", ":", "s", "=", "s", ".", "encode", "(", "'latin-1'", ")", "data", "=", "dec", ".", "decompress", "(", "base64", ".", "decodebytes", "(", "s", ")", ",", "maxsize", ")", "if", "dec", ".", "unconsumed_tail", ":", "raise", "ValueError", "json_bytes", "=", "data", ".", "decode", "(", "'utf-8'", ")", "return", "loads", "(", "json_bytes", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/CopySupport.py#L674-L689
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
compatibilityCall
(method_name, *args)
Call a method if events have not been setup yet. This is the case for some unit tests that have not been converted to use the component architecture.
Call a method if events have not been setup yet.
[ "Call", "a", "method", "if", "events", "have", "not", "been", "setup", "yet", "." ]
def compatibilityCall(method_name, *args): """Call a method if events have not been setup yet. This is the case for some unit tests that have not been converted to use the component architecture. """ if deprecatedManageAddDeleteClasses: # Events initialized, don't do compatibility call return if method_name == 'manage_afterAdd': callManageAfterAdd(*args) elif method_name == 'manage_beforeDelete': callManageBeforeDelete(*args) else: callManageAfterClone(*args)
[ "def", "compatibilityCall", "(", "method_name", ",", "*", "args", ")", ":", "if", "deprecatedManageAddDeleteClasses", ":", "# Events initialized, don't do compatibility call", "return", "if", "method_name", "==", "'manage_afterAdd'", ":", "callManageAfterAdd", "(", "*", "args", ")", "elif", "method_name", "==", "'manage_beforeDelete'", ":", "callManageBeforeDelete", "(", "*", "args", ")", "else", ":", "callManageAfterClone", "(", "*", "args", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L38-L52
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
maybeWarnDeprecated
(ob, method_name)
Send a warning if a method is deprecated.
Send a warning if a method is deprecated.
[ "Send", "a", "warning", "if", "a", "method", "is", "deprecated", "." ]
def maybeWarnDeprecated(ob, method_name): """Send a warning if a method is deprecated. """ if not deprecatedManageAddDeleteClasses: # Directives not fully loaded return if getattr(getattr(ob, method_name), '__five_method__', False): # Method knows it's deprecated return if isinstance(ob, tuple(deprecatedManageAddDeleteClasses)): return class_ = ob.__class__ LOG.debug( "%s.%s.%s is discouraged. You should use event subscribers instead." % (class_.__module__, class_.__name__, method_name))
[ "def", "maybeWarnDeprecated", "(", "ob", ",", "method_name", ")", ":", "if", "not", "deprecatedManageAddDeleteClasses", ":", "# Directives not fully loaded", "return", "if", "getattr", "(", "getattr", "(", "ob", ",", "method_name", ")", ",", "'__five_method__'", ",", "False", ")", ":", "# Method knows it's deprecated", "return", "if", "isinstance", "(", "ob", ",", "tuple", "(", "deprecatedManageAddDeleteClasses", ")", ")", ":", "return", "class_", "=", "ob", ".", "__class__", "LOG", ".", "debug", "(", "\"%s.%s.%s is discouraged. You should use event subscribers instead.\"", "%", "(", "class_", ".", "__module__", ",", "class_", ".", "__name__", ",", "method_name", ")", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L55-L69
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
dispatchObjectWillBeMovedEvent
(ob, event)
Multi-subscriber for IItem + IObjectWillBeMovedEvent.
Multi-subscriber for IItem + IObjectWillBeMovedEvent.
[ "Multi", "-", "subscriber", "for", "IItem", "+", "IObjectWillBeMovedEvent", "." ]
def dispatchObjectWillBeMovedEvent(ob, event): """Multi-subscriber for IItem + IObjectWillBeMovedEvent. """ # First, dispatch to sublocations if OFS.interfaces.IObjectManager.providedBy(ob): dispatchToSublocations(ob, event) # Next, do the manage_beforeDelete dance callManageBeforeDelete(ob, event.object, event.oldParent)
[ "def", "dispatchObjectWillBeMovedEvent", "(", "ob", ",", "event", ")", ":", "# First, dispatch to sublocations", "if", "OFS", ".", "interfaces", ".", "IObjectManager", ".", "providedBy", "(", "ob", ")", ":", "dispatchToSublocations", "(", "ob", ",", "event", ")", "# Next, do the manage_beforeDelete dance", "callManageBeforeDelete", "(", "ob", ",", "event", ".", "object", ",", "event", ".", "oldParent", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L97-L104
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
dispatchObjectMovedEvent
(ob, event)
Multi-subscriber for IItem + IObjectMovedEvent.
Multi-subscriber for IItem + IObjectMovedEvent.
[ "Multi", "-", "subscriber", "for", "IItem", "+", "IObjectMovedEvent", "." ]
def dispatchObjectMovedEvent(ob, event): """Multi-subscriber for IItem + IObjectMovedEvent. """ # First, do the manage_afterAdd dance callManageAfterAdd(ob, event.object, event.newParent) # Next, dispatch to sublocations if OFS.interfaces.IObjectManager.providedBy(ob): dispatchToSublocations(ob, event)
[ "def", "dispatchObjectMovedEvent", "(", "ob", ",", "event", ")", ":", "# First, do the manage_afterAdd dance", "callManageAfterAdd", "(", "ob", ",", "event", ".", "object", ",", "event", ".", "newParent", ")", "# Next, dispatch to sublocations", "if", "OFS", ".", "interfaces", ".", "IObjectManager", ".", "providedBy", "(", "ob", ")", ":", "dispatchToSublocations", "(", "ob", ",", "event", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L108-L115
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
dispatchObjectClonedEvent
(ob, event)
Multi-subscriber for IItem + IObjectClonedEvent.
Multi-subscriber for IItem + IObjectClonedEvent.
[ "Multi", "-", "subscriber", "for", "IItem", "+", "IObjectClonedEvent", "." ]
def dispatchObjectClonedEvent(ob, event): """Multi-subscriber for IItem + IObjectClonedEvent. """ # First, do the manage_afterClone dance callManageAfterClone(ob, event.object) # Next, dispatch to sublocations if OFS.interfaces.IObjectManager.providedBy(ob): dispatchToSublocations(ob, event)
[ "def", "dispatchObjectClonedEvent", "(", "ob", ",", "event", ")", ":", "# First, do the manage_afterClone dance", "callManageAfterClone", "(", "ob", ",", "event", ".", "object", ")", "# Next, dispatch to sublocations", "if", "OFS", ".", "interfaces", ".", "IObjectManager", ".", "providedBy", "(", "ob", ")", ":", "dispatchToSublocations", "(", "ob", ",", "event", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L120-L127
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
dispatchObjectCopiedEvent
(ob, event)
Multi-subscriber for IItem + IObjectCopiedEvent.
Multi-subscriber for IItem + IObjectCopiedEvent.
[ "Multi", "-", "subscriber", "for", "IItem", "+", "IObjectCopiedEvent", "." ]
def dispatchObjectCopiedEvent(ob, event): """Multi-subscriber for IItem + IObjectCopiedEvent. """ # Dispatch to sublocations if OFS.interfaces.IObjectManager.providedBy(ob): dispatchToSublocations(ob, event)
[ "def", "dispatchObjectCopiedEvent", "(", "ob", ",", "event", ")", ":", "# Dispatch to sublocations", "if", "OFS", ".", "interfaces", ".", "IObjectManager", ".", "providedBy", "(", "ob", ")", ":", "dispatchToSublocations", "(", "ob", ",", "event", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L131-L136
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
callManageAfterAdd
(ob, item, container)
Compatibility subscriber for manage_afterAdd.
Compatibility subscriber for manage_afterAdd.
[ "Compatibility", "subscriber", "for", "manage_afterAdd", "." ]
def callManageAfterAdd(ob, item, container): """Compatibility subscriber for manage_afterAdd. """ if container is None: return if getattr(aq_base(ob), 'manage_afterAdd', None) is None: return maybeWarnDeprecated(ob, 'manage_afterAdd') ob.manage_afterAdd(item, container)
[ "def", "callManageAfterAdd", "(", "ob", ",", "item", ",", "container", ")", ":", "if", "container", "is", "None", ":", "return", "if", "getattr", "(", "aq_base", "(", "ob", ")", ",", "'manage_afterAdd'", ",", "None", ")", "is", "None", ":", "return", "maybeWarnDeprecated", "(", "ob", ",", "'manage_afterAdd'", ")", "ob", ".", "manage_afterAdd", "(", "item", ",", "container", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L139-L147
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
callManageBeforeDelete
(ob, item, container)
Compatibility subscriber for manage_beforeDelete.
Compatibility subscriber for manage_beforeDelete.
[ "Compatibility", "subscriber", "for", "manage_beforeDelete", "." ]
def callManageBeforeDelete(ob, item, container): """Compatibility subscriber for manage_beforeDelete. """ if container is None: return if getattr(aq_base(ob), 'manage_beforeDelete', None) is None: return maybeWarnDeprecated(ob, 'manage_beforeDelete') import OFS.ObjectManager # avoid circular imports try: ob.manage_beforeDelete(item, container) except OFS.ObjectManager.BeforeDeleteException: raise except ConflictError: raise except Exception: LOG.error('_delObject() threw', exc_info=True) # In debug mode when non-Manager, let exceptions propagate. if getConfiguration().debug_mode: if not getSecurityManager().getUser().has_role('Manager'): raise
[ "def", "callManageBeforeDelete", "(", "ob", ",", "item", ",", "container", ")", ":", "if", "container", "is", "None", ":", "return", "if", "getattr", "(", "aq_base", "(", "ob", ")", ",", "'manage_beforeDelete'", ",", "None", ")", "is", "None", ":", "return", "maybeWarnDeprecated", "(", "ob", ",", "'manage_beforeDelete'", ")", "import", "OFS", ".", "ObjectManager", "# avoid circular imports", "try", ":", "ob", ".", "manage_beforeDelete", "(", "item", ",", "container", ")", "except", "OFS", ".", "ObjectManager", ".", "BeforeDeleteException", ":", "raise", "except", "ConflictError", ":", "raise", "except", "Exception", ":", "LOG", ".", "error", "(", "'_delObject() threw'", ",", "exc_info", "=", "True", ")", "# In debug mode when non-Manager, let exceptions propagate.", "if", "getConfiguration", "(", ")", ".", "debug_mode", ":", "if", "not", "getSecurityManager", "(", ")", ".", "getUser", "(", ")", ".", "has_role", "(", "'Manager'", ")", ":", "raise" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L150-L170
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/subscribers.py
python
callManageAfterClone
(ob, item)
Compatibility subscriber for manage_afterClone.
Compatibility subscriber for manage_afterClone.
[ "Compatibility", "subscriber", "for", "manage_afterClone", "." ]
def callManageAfterClone(ob, item): """Compatibility subscriber for manage_afterClone. """ if getattr(aq_base(ob), 'manage_afterClone', None) is None: return maybeWarnDeprecated(ob, 'manage_afterClone') ob.manage_afterClone(item)
[ "def", "callManageAfterClone", "(", "ob", ",", "item", ")", ":", "if", "getattr", "(", "aq_base", "(", "ob", ")", ",", "'manage_afterClone'", ",", "None", ")", "is", "None", ":", "return", "maybeWarnDeprecated", "(", "ob", ",", "'manage_afterClone'", ")", "ob", ".", "manage_afterClone", "(", "item", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/subscribers.py#L173-L179
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
filterCacheManagers
(orig, container, name, value, extra)
return 0
This is a filter method for aq_acquire. It causes objects to be found only if they are in the list of cache managers.
This is a filter method for aq_acquire. It causes objects to be found only if they are in the list of cache managers.
[ "This", "is", "a", "filter", "method", "for", "aq_acquire", ".", "It", "causes", "objects", "to", "be", "found", "only", "if", "they", "are", "in", "the", "list", "of", "cache", "managers", "." ]
def filterCacheManagers(orig, container, name, value, extra): """ This is a filter method for aq_acquire. It causes objects to be found only if they are in the list of cache managers. """ if hasattr(aq_base(container), ZCM_MANAGERS) and \ name in getattr(container, ZCM_MANAGERS): return 1 return 0
[ "def", "filterCacheManagers", "(", "orig", ",", "container", ",", "name", ",", "value", ",", "extra", ")", ":", "if", "hasattr", "(", "aq_base", "(", "container", ")", ",", "ZCM_MANAGERS", ")", "and", "name", "in", "getattr", "(", "container", ",", "ZCM_MANAGERS", ")", ":", "return", "1", "return", "0" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L55-L64
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
getVerifiedManagerIds
(container)
return tuple(rval)
Gets the list of cache managers in a container, verifying each one.
Gets the list of cache managers in a container, verifying each one.
[ "Gets", "the", "list", "of", "cache", "managers", "in", "a", "container", "verifying", "each", "one", "." ]
def getVerifiedManagerIds(container): """Gets the list of cache managers in a container, verifying each one.""" ids = getattr(container, ZCM_MANAGERS, ()) rval = [] for id in ids: if getattr(getattr(container, id, None), '_isCacheManager', 0): rval.append(id) return tuple(rval)
[ "def", "getVerifiedManagerIds", "(", "container", ")", ":", "ids", "=", "getattr", "(", "container", ",", "ZCM_MANAGERS", ",", "(", ")", ")", "rval", "=", "[", "]", "for", "id", "in", "ids", ":", "if", "getattr", "(", "getattr", "(", "container", ",", "id", ",", "None", ")", ",", "'_isCacheManager'", ",", "0", ")", ":", "rval", ".", "append", "(", "id", ")", "return", "tuple", "(", "rval", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L67-L74
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
findCacheables
( ob, manager_id, require_assoc, subfolders, meta_types, rval, path )
Used by the CacheManager UI. Recursive. Similar to the Zope "Find" function. Finds all Cacheable objects in a hierarchy.
Used by the CacheManager UI. Recursive. Similar to the Zope "Find" function. Finds all Cacheable objects in a hierarchy.
[ "Used", "by", "the", "CacheManager", "UI", ".", "Recursive", ".", "Similar", "to", "the", "Zope", "Find", "function", ".", "Finds", "all", "Cacheable", "objects", "in", "a", "hierarchy", "." ]
def findCacheables( ob, manager_id, require_assoc, subfolders, meta_types, rval, path ): """ Used by the CacheManager UI. Recursive. Similar to the Zope "Find" function. Finds all Cacheable objects in a hierarchy. """ try: if meta_types: subobs = ob.objectValues(meta_types) else: subobs = ob.objectValues() sm = getSecurityManager() # Add to the list of cacheable objects. for subob in subobs: if not isCacheable(subob): continue associated = (subob.ZCacheable_getManagerId() == manager_id) if require_assoc and not associated: continue if not sm.checkPermission('Change cache settings', subob): continue subpath = path + (subob.getId(),) info = { 'sortkey': subpath, 'path': '/'.join(subpath), 'title': getattr(aq_base(subob), 'title', ''), 'icon': None, 'associated': associated, } rval.append(info) # Visit subfolders. if subfolders: if meta_types: subobs = ob.objectValues() for subob in subobs: subpath = path + (subob.getId(),) if hasattr(aq_base(subob), 'objectValues'): if sm.checkPermission( 'Access contents information', subob): findCacheables( subob, manager_id, require_assoc, subfolders, meta_types, rval, subpath) except Exception: # Ignore exceptions. import traceback traceback.print_exc()
[ "def", "findCacheables", "(", "ob", ",", "manager_id", ",", "require_assoc", ",", "subfolders", ",", "meta_types", ",", "rval", ",", "path", ")", ":", "try", ":", "if", "meta_types", ":", "subobs", "=", "ob", ".", "objectValues", "(", "meta_types", ")", "else", ":", "subobs", "=", "ob", ".", "objectValues", "(", ")", "sm", "=", "getSecurityManager", "(", ")", "# Add to the list of cacheable objects.", "for", "subob", "in", "subobs", ":", "if", "not", "isCacheable", "(", "subob", ")", ":", "continue", "associated", "=", "(", "subob", ".", "ZCacheable_getManagerId", "(", ")", "==", "manager_id", ")", "if", "require_assoc", "and", "not", "associated", ":", "continue", "if", "not", "sm", ".", "checkPermission", "(", "'Change cache settings'", ",", "subob", ")", ":", "continue", "subpath", "=", "path", "+", "(", "subob", ".", "getId", "(", ")", ",", ")", "info", "=", "{", "'sortkey'", ":", "subpath", ",", "'path'", ":", "'/'", ".", "join", "(", "subpath", ")", ",", "'title'", ":", "getattr", "(", "aq_base", "(", "subob", ")", ",", "'title'", ",", "''", ")", ",", "'icon'", ":", "None", ",", "'associated'", ":", "associated", ",", "}", "rval", ".", "append", "(", "info", ")", "# Visit subfolders.", "if", "subfolders", ":", "if", "meta_types", ":", "subobs", "=", "ob", ".", "objectValues", "(", ")", "for", "subob", "in", "subobs", ":", "subpath", "=", "path", "+", "(", "subob", ".", "getId", "(", ")", ",", ")", "if", "hasattr", "(", "aq_base", "(", "subob", ")", ",", "'objectValues'", ")", ":", "if", "sm", ".", "checkPermission", "(", "'Access contents information'", ",", "subob", ")", ":", "findCacheables", "(", "subob", ",", "manager_id", ",", "require_assoc", ",", "subfolders", ",", "meta_types", ",", "rval", ",", "subpath", ")", "except", "Exception", ":", "# Ignore exceptions.", "import", "traceback", "traceback", ".", "print_exc", "(", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L332-L386
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_getManager
(self)
Returns the currently associated cache manager.
Returns the currently associated cache manager.
[ "Returns", "the", "currently", "associated", "cache", "manager", "." ]
def ZCacheable_getManager(self): """Returns the currently associated cache manager.""" manager_id = self.__manager_id if manager_id is None: return None try: return aq_acquire( self, manager_id, containment=1, filter=filterCacheManagers, extra=None, default=None ) except AttributeError: return None
[ "def", "ZCacheable_getManager", "(", "self", ")", ":", "manager_id", "=", "self", ".", "__manager_id", "if", "manager_id", "is", "None", ":", "return", "None", "try", ":", "return", "aq_acquire", "(", "self", ",", "manager_id", ",", "containment", "=", "1", ",", "filter", "=", "filterCacheManagers", ",", "extra", "=", "None", ",", "default", "=", "None", ")", "except", "AttributeError", ":", "return", "None" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L107-L122
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_getCache
(self)
return c
Gets the cache associated with this object.
Gets the cache associated with this object.
[ "Gets", "the", "cache", "associated", "with", "this", "object", "." ]
def ZCacheable_getCache(self): """Gets the cache associated with this object. """ if self.__manager_id is None: return None c = self._v_ZCacheable_cache if c is not None: # We have a volatile reference to the cache. if self._v_ZCacheable_manager_timestamp == manager_timestamp: return aq_base(c) manager = self.ZCacheable_getManager() if manager is not None: c = aq_base(manager.ZCacheManager_getCache()) else: return None # Set a volatile reference to the cache then return it. self._v_ZCacheable_cache = c self._v_ZCacheable_manager_timestamp = manager_timestamp return c
[ "def", "ZCacheable_getCache", "(", "self", ")", ":", "if", "self", ".", "__manager_id", "is", "None", ":", "return", "None", "c", "=", "self", ".", "_v_ZCacheable_cache", "if", "c", "is", "not", "None", ":", "# We have a volatile reference to the cache.", "if", "self", ".", "_v_ZCacheable_manager_timestamp", "==", "manager_timestamp", ":", "return", "aq_base", "(", "c", ")", "manager", "=", "self", ".", "ZCacheable_getManager", "(", ")", "if", "manager", "is", "not", "None", ":", "c", "=", "aq_base", "(", "manager", ".", "ZCacheManager_getCache", "(", ")", ")", "else", ":", "return", "None", "# Set a volatile reference to the cache then return it.", "self", ".", "_v_ZCacheable_cache", "=", "c", "self", ".", "_v_ZCacheable_manager_timestamp", "=", "manager_timestamp", "return", "c" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L125-L143
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_isCachingEnabled
(self)
return self.__enabled and self.ZCacheable_getCache()
Returns true only if associated with a cache manager and caching of this method is enabled.
Returns true only if associated with a cache manager and caching of this method is enabled.
[ "Returns", "true", "only", "if", "associated", "with", "a", "cache", "manager", "and", "caching", "of", "this", "method", "is", "enabled", "." ]
def ZCacheable_isCachingEnabled(self): """ Returns true only if associated with a cache manager and caching of this method is enabled. """ return self.__enabled and self.ZCacheable_getCache()
[ "def", "ZCacheable_isCachingEnabled", "(", "self", ")", ":", "return", "self", ".", "__enabled", "and", "self", ".", "ZCacheable_getCache", "(", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L146-L151
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_get
( self, view_name='', keywords=None, mtime_func=None, default=None )
return default
Retrieves the cached view for the object under the conditions specified by keywords. If the value is not yet cached, returns the default.
Retrieves the cached view for the object under the conditions specified by keywords. If the value is not yet cached, returns the default.
[ "Retrieves", "the", "cached", "view", "for", "the", "object", "under", "the", "conditions", "specified", "by", "keywords", ".", "If", "the", "value", "is", "not", "yet", "cached", "returns", "the", "default", "." ]
def ZCacheable_get( self, view_name='', keywords=None, mtime_func=None, default=None ): """Retrieves the cached view for the object under the conditions specified by keywords. If the value is not yet cached, returns the default. """ c = self.ZCacheable_getCache() if c is not None and self.__enabled: ob, view_name = self.ZCacheable_getObAndView(view_name) try: val = c.ZCache_get(ob, view_name, keywords, mtime_func, default) return val except Exception: LOG.warning('ZCache_get() exception') return default return default
[ "def", "ZCacheable_get", "(", "self", ",", "view_name", "=", "''", ",", "keywords", "=", "None", ",", "mtime_func", "=", "None", ",", "default", "=", "None", ")", ":", "c", "=", "self", ".", "ZCacheable_getCache", "(", ")", "if", "c", "is", "not", "None", "and", "self", ".", "__enabled", ":", "ob", ",", "view_name", "=", "self", ".", "ZCacheable_getObAndView", "(", "view_name", ")", "try", ":", "val", "=", "c", ".", "ZCache_get", "(", "ob", ",", "view_name", ",", "keywords", ",", "mtime_func", ",", "default", ")", "return", "val", "except", "Exception", ":", "LOG", ".", "warning", "(", "'ZCache_get() exception'", ")", "return", "default", "return", "default" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L159-L180
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_set
( self, data, view_name='', keywords=None, mtime_func=None )
Cacheable views should call this method after generating cacheable results. The data argument can be of any Python type.
Cacheable views should call this method after generating cacheable results. The data argument can be of any Python type.
[ "Cacheable", "views", "should", "call", "this", "method", "after", "generating", "cacheable", "results", ".", "The", "data", "argument", "can", "be", "of", "any", "Python", "type", "." ]
def ZCacheable_set( self, data, view_name='', keywords=None, mtime_func=None ): """Cacheable views should call this method after generating cacheable results. The data argument can be of any Python type. """ c = self.ZCacheable_getCache() if c is not None and self.__enabled: ob, view_name = self.ZCacheable_getObAndView(view_name) try: c.ZCache_set(ob, data, view_name, keywords, mtime_func) except Exception: LOG.warning('ZCache_set() exception')
[ "def", "ZCacheable_set", "(", "self", ",", "data", ",", "view_name", "=", "''", ",", "keywords", "=", "None", ",", "mtime_func", "=", "None", ")", ":", "c", "=", "self", ".", "ZCacheable_getCache", "(", ")", "if", "c", "is", "not", "None", "and", "self", ".", "__enabled", ":", "ob", ",", "view_name", "=", "self", ".", "ZCacheable_getObAndView", "(", "view_name", ")", "try", ":", "c", ".", "ZCache_set", "(", "ob", ",", "data", ",", "view_name", ",", "keywords", ",", "mtime_func", ")", "except", "Exception", ":", "LOG", ".", "warning", "(", "'ZCache_set() exception'", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L183-L200
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_invalidate
(self, view_name='', REQUEST=None)
return message
Called after a cacheable object is edited. Causes all cache entries that apply to the view_name to be removed. Returns a status message.
Called after a cacheable object is edited. Causes all cache entries that apply to the view_name to be removed. Returns a status message.
[ "Called", "after", "a", "cacheable", "object", "is", "edited", ".", "Causes", "all", "cache", "entries", "that", "apply", "to", "the", "view_name", "to", "be", "removed", ".", "Returns", "a", "status", "message", "." ]
def ZCacheable_invalidate(self, view_name='', REQUEST=None): """Called after a cacheable object is edited. Causes all cache entries that apply to the view_name to be removed. Returns a status message. """ c = self.ZCacheable_getCache() if c is not None: ob, view_name = self.ZCacheable_getObAndView(view_name) try: message = c.ZCache_invalidate(ob) if not message: message = 'Invalidated.' except Exception: exc = sys.exc_info() try: LOG.warning('ZCache_invalidate() exception') message = 'An exception occurred: %s: %s' % exc[:2] finally: exc = None else: message = 'This object is not associated with a cache manager.' if REQUEST is not None: return self.ZCacheable_manage( self, REQUEST, management_view='Cache', manage_tabs_message=message) return message
[ "def", "ZCacheable_invalidate", "(", "self", ",", "view_name", "=", "''", ",", "REQUEST", "=", "None", ")", ":", "c", "=", "self", ".", "ZCacheable_getCache", "(", ")", "if", "c", "is", "not", "None", ":", "ob", ",", "view_name", "=", "self", ".", "ZCacheable_getObAndView", "(", "view_name", ")", "try", ":", "message", "=", "c", ".", "ZCache_invalidate", "(", "ob", ")", "if", "not", "message", ":", "message", "=", "'Invalidated.'", "except", "Exception", ":", "exc", "=", "sys", ".", "exc_info", "(", ")", "try", ":", "LOG", ".", "warning", "(", "'ZCache_invalidate() exception'", ")", "message", "=", "'An exception occurred: %s: %s'", "%", "exc", "[", ":", "2", "]", "finally", ":", "exc", "=", "None", "else", ":", "message", "=", "'This object is not associated with a cache manager.'", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "ZCacheable_manage", "(", "self", ",", "REQUEST", ",", "management_view", "=", "'Cache'", ",", "manage_tabs_message", "=", "message", ")", "return", "message" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L203-L229
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_getModTime
(self, mtime_func=None)
return mtime
Returns the highest of the last mod times.
Returns the highest of the last mod times.
[ "Returns", "the", "highest", "of", "the", "last", "mod", "times", "." ]
def ZCacheable_getModTime(self, mtime_func=None): """Returns the highest of the last mod times.""" # Based on: # mtime_func # self.mtime # self.__class__.mtime mtime = 0 if mtime_func: # Allow mtime_func to influence the mod time. mtime = mtime_func() base = aq_base(self) mtime = max(getattr(base, '_p_mtime', mtime) or 0, mtime) klass = getattr(base, '__class__', None) if klass: klass_mtime = getattr(klass, '_p_mtime', mtime) if isinstance(klass_mtime, int): mtime = max(klass_mtime, mtime) return mtime
[ "def", "ZCacheable_getModTime", "(", "self", ",", "mtime_func", "=", "None", ")", ":", "# Based on:", "# mtime_func", "# self.mtime", "# self.__class__.mtime", "mtime", "=", "0", "if", "mtime_func", ":", "# Allow mtime_func to influence the mod time.", "mtime", "=", "mtime_func", "(", ")", "base", "=", "aq_base", "(", "self", ")", "mtime", "=", "max", "(", "getattr", "(", "base", ",", "'_p_mtime'", ",", "mtime", ")", "or", "0", ",", "mtime", ")", "klass", "=", "getattr", "(", "base", ",", "'__class__'", ",", "None", ")", "if", "klass", ":", "klass_mtime", "=", "getattr", "(", "klass", ",", "'_p_mtime'", ",", "mtime", ")", "if", "isinstance", "(", "klass_mtime", ",", "int", ")", ":", "mtime", "=", "max", "(", "klass_mtime", ",", "mtime", ")", "return", "mtime" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L232-L249
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_getManagerId
(self)
return self.__manager_id
Returns the id of the current ZCacheManager.
Returns the id of the current ZCacheManager.
[ "Returns", "the", "id", "of", "the", "current", "ZCacheManager", "." ]
def ZCacheable_getManagerId(self): """Returns the id of the current ZCacheManager.""" return self.__manager_id
[ "def", "ZCacheable_getManagerId", "(", "self", ")", ":", "return", "self", ".", "__manager_id" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L252-L254
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_getManagerURL
(self)
return None
Returns the URL of the current ZCacheManager.
Returns the URL of the current ZCacheManager.
[ "Returns", "the", "URL", "of", "the", "current", "ZCacheManager", "." ]
def ZCacheable_getManagerURL(self): """Returns the URL of the current ZCacheManager.""" manager = self.ZCacheable_getManager() if manager is not None: return manager.absolute_url() return None
[ "def", "ZCacheable_getManagerURL", "(", "self", ")", ":", "manager", "=", "self", ".", "ZCacheable_getManager", "(", ")", "if", "manager", "is", "not", "None", ":", "return", "manager", ".", "absolute_url", "(", ")", "return", "None" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L257-L262
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_getManagerIds
(self)
return tuple(rval)
Returns a list of mappings containing the id and title of the available ZCacheManagers.
Returns a list of mappings containing the id and title of the available ZCacheManagers.
[ "Returns", "a", "list", "of", "mappings", "containing", "the", "id", "and", "title", "of", "the", "available", "ZCacheManagers", "." ]
def ZCacheable_getManagerIds(self): """Returns a list of mappings containing the id and title of the available ZCacheManagers.""" rval = [] ob = self used_ids = {} while ob is not None: if hasattr(aq_base(ob), ZCM_MANAGERS): ids = getattr(ob, ZCM_MANAGERS) for id in ids: manager = getattr(ob, id, None) if manager is not None: id = manager.getId() if id not in used_ids: title = getattr(aq_base(manager), 'title', '') rval.append({'id': id, 'title': title}) used_ids[id] = 1 ob = aq_parent(aq_inner(ob)) return tuple(rval)
[ "def", "ZCacheable_getManagerIds", "(", "self", ")", ":", "rval", "=", "[", "]", "ob", "=", "self", "used_ids", "=", "{", "}", "while", "ob", "is", "not", "None", ":", "if", "hasattr", "(", "aq_base", "(", "ob", ")", ",", "ZCM_MANAGERS", ")", ":", "ids", "=", "getattr", "(", "ob", ",", "ZCM_MANAGERS", ")", "for", "id", "in", "ids", ":", "manager", "=", "getattr", "(", "ob", ",", "id", ",", "None", ")", "if", "manager", "is", "not", "None", ":", "id", "=", "manager", ".", "getId", "(", ")", "if", "id", "not", "in", "used_ids", ":", "title", "=", "getattr", "(", "aq_base", "(", "manager", ")", ",", "'title'", ",", "''", ")", "rval", ".", "append", "(", "{", "'id'", ":", "id", ",", "'title'", ":", "title", "}", ")", "used_ids", "[", "id", "]", "=", "1", "ob", "=", "aq_parent", "(", "aq_inner", "(", "ob", ")", ")", "return", "tuple", "(", "rval", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L265-L283
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_setManagerId
(self, manager_id, REQUEST=None)
Changes the manager_id for this object.
Changes the manager_id for this object.
[ "Changes", "the", "manager_id", "for", "this", "object", "." ]
def ZCacheable_setManagerId(self, manager_id, REQUEST=None): """Changes the manager_id for this object.""" self.ZCacheable_invalidate() if not manager_id: # User requested disassociation # from the cache manager. manager_id = None else: manager_id = str(manager_id) self.__manager_id = manager_id self._v_ZCacheable_cache = None if REQUEST is not None: return self.ZCacheable_manage( self, REQUEST, management_view='Cache', manage_tabs_message='Cache settings changed.' )
[ "def", "ZCacheable_setManagerId", "(", "self", ",", "manager_id", ",", "REQUEST", "=", "None", ")", ":", "self", ".", "ZCacheable_invalidate", "(", ")", "if", "not", "manager_id", ":", "# User requested disassociation", "# from the cache manager.", "manager_id", "=", "None", "else", ":", "manager_id", "=", "str", "(", "manager_id", ")", "self", ".", "__manager_id", "=", "manager_id", "self", ".", "_v_ZCacheable_cache", "=", "None", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "ZCacheable_manage", "(", "self", ",", "REQUEST", ",", "management_view", "=", "'Cache'", ",", "manage_tabs_message", "=", "'Cache settings changed.'", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L286-L304
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_enabled
(self)
return self.__enabled
Returns true if caching is enabled for this object or method.
Returns true if caching is enabled for this object or method.
[ "Returns", "true", "if", "caching", "is", "enabled", "for", "this", "object", "or", "method", "." ]
def ZCacheable_enabled(self): """Returns true if caching is enabled for this object or method.""" return self.__enabled
[ "def", "ZCacheable_enabled", "(", "self", ")", ":", "return", "self", ".", "__enabled" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L307-L309
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_setEnabled
(self, enabled=0, REQUEST=None)
Changes the enabled flag.
Changes the enabled flag.
[ "Changes", "the", "enabled", "flag", "." ]
def ZCacheable_setEnabled(self, enabled=0, REQUEST=None): """Changes the enabled flag.""" self.__enabled = enabled and 1 or 0 if REQUEST is not None: return self.ZCacheable_manage( self, REQUEST, management_view='Cache', manage_tabs_message='Cache settings changed.')
[ "def", "ZCacheable_setEnabled", "(", "self", ",", "enabled", "=", "0", ",", "REQUEST", "=", "None", ")", ":", "self", ".", "__enabled", "=", "enabled", "and", "1", "or", "0", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "ZCacheable_manage", "(", "self", ",", "REQUEST", ",", "management_view", "=", "'Cache'", ",", "manage_tabs_message", "=", "'Cache settings changed.'", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L312-L319
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
Cacheable.ZCacheable_configHTML
(self)
return ''
Override to provide configuration of caching behavior that can only be specific to the cacheable object.
Override to provide configuration of caching behavior that can only be specific to the cacheable object.
[ "Override", "to", "provide", "configuration", "of", "caching", "behavior", "that", "can", "only", "be", "specific", "to", "the", "cacheable", "object", "." ]
def ZCacheable_configHTML(self): """Override to provide configuration of caching behavior that can only be specific to the cacheable object. """ return ''
[ "def", "ZCacheable_configHTML", "(", "self", ")", ":", "return", "''" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L322-L326
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
CacheManager.ZCacheManager_locate
( self, require_assoc, subfolders, meta_types=[], REQUEST=None )
return rval
Locates cacheable objects.
Locates cacheable objects.
[ "Locates", "cacheable", "objects", "." ]
def ZCacheManager_locate( self, require_assoc, subfolders, meta_types=[], REQUEST=None ): """Locates cacheable objects. """ ob = aq_parent(aq_inner(self)) rval = [] manager_id = self.getId() if '' in meta_types: # User selected "All". meta_types = [] findCacheables( ob, manager_id, require_assoc, subfolders, meta_types, rval, () ) if REQUEST is not None: return self.ZCacheManager_associate( self, REQUEST, show_results=1, results=rval, management_view="Associate" ) return rval
[ "def", "ZCacheManager_locate", "(", "self", ",", "require_assoc", ",", "subfolders", ",", "meta_types", "=", "[", "]", ",", "REQUEST", "=", "None", ")", ":", "ob", "=", "aq_parent", "(", "aq_inner", "(", "self", ")", ")", "rval", "=", "[", "]", "manager_id", "=", "self", ".", "getId", "(", ")", "if", "''", "in", "meta_types", ":", "# User selected \"All\".", "meta_types", "=", "[", "]", "findCacheables", "(", "ob", ",", "manager_id", ",", "require_assoc", ",", "subfolders", ",", "meta_types", ",", "rval", ",", "(", ")", ")", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "ZCacheManager_associate", "(", "self", ",", "REQUEST", ",", "show_results", "=", "1", ",", "results", "=", "rval", ",", "management_view", "=", "\"Associate\"", ")", "return", "rval" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L472-L505
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/Cache.py
python
CacheManager.ZCacheManager_setAssociations
(self, props=None, REQUEST=None)
Associates and un-associates cacheable objects with this cache manager.
Associates and un-associates cacheable objects with this cache manager.
[ "Associates", "and", "un", "-", "associates", "cacheable", "objects", "with", "this", "cache", "manager", "." ]
def ZCacheManager_setAssociations(self, props=None, REQUEST=None): """Associates and un-associates cacheable objects with this cache manager. """ addcount = 0 remcount = 0 parent = aq_parent(aq_inner(self)) sm = getSecurityManager() my_id = str(self.getId()) if props is None: props = REQUEST.form for key, do_associate in props.items(): if key[:10] == 'associate_': path = key[10:] ob = parent.restrictedTraverse(path) if not sm.checkPermission('Change cache settings', ob): raise Unauthorized if not isCacheable(ob): # Not a cacheable object. continue manager_id = str(ob.ZCacheable_getManagerId()) if do_associate: if manager_id != my_id: ob.ZCacheable_setManagerId(my_id) addcount = addcount + 1 else: if manager_id == my_id: ob.ZCacheable_setManagerId(None) remcount = remcount + 1 if REQUEST is not None: return self.ZCacheManager_associate( self, REQUEST, management_view="Associate", manage_tabs_message='%d association(s) made, %d removed.' % (addcount, remcount) )
[ "def", "ZCacheManager_setAssociations", "(", "self", ",", "props", "=", "None", ",", "REQUEST", "=", "None", ")", ":", "addcount", "=", "0", "remcount", "=", "0", "parent", "=", "aq_parent", "(", "aq_inner", "(", "self", ")", ")", "sm", "=", "getSecurityManager", "(", ")", "my_id", "=", "str", "(", "self", ".", "getId", "(", ")", ")", "if", "props", "is", "None", ":", "props", "=", "REQUEST", ".", "form", "for", "key", ",", "do_associate", "in", "props", ".", "items", "(", ")", ":", "if", "key", "[", ":", "10", "]", "==", "'associate_'", ":", "path", "=", "key", "[", "10", ":", "]", "ob", "=", "parent", ".", "restrictedTraverse", "(", "path", ")", "if", "not", "sm", ".", "checkPermission", "(", "'Change cache settings'", ",", "ob", ")", ":", "raise", "Unauthorized", "if", "not", "isCacheable", "(", "ob", ")", ":", "# Not a cacheable object.", "continue", "manager_id", "=", "str", "(", "ob", ".", "ZCacheable_getManagerId", "(", ")", ")", "if", "do_associate", ":", "if", "manager_id", "!=", "my_id", ":", "ob", ".", "ZCacheable_setManagerId", "(", "my_id", ")", "addcount", "=", "addcount", "+", "1", "else", ":", "if", "manager_id", "==", "my_id", ":", "ob", ".", "ZCacheable_setManagerId", "(", "None", ")", "remcount", "=", "remcount", "+", "1", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "ZCacheManager_associate", "(", "self", ",", "REQUEST", ",", "management_view", "=", "\"Associate\"", ",", "manage_tabs_message", "=", "'%d association(s) made, %d removed.'", "%", "(", "addcount", ",", "remcount", ")", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/Cache.py#L508-L543
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/EtagSupport.py
python
EtagBaseInterface.http__etag
()
\ Entity tags are used for comparing two or more entities from the same requested resource. Predominantly used for Caching, Etags can also be used to deal with the 'Lost Updates Problem'. An HTTP Client such as Amaya that supports PUT for editing can use the Etag value returned in the head of a GET response in the 'if-match' header submitted with a PUT request. If the Etag for the requested resource in the PUT request's 'if-match' header is different from the current Etag value returned by this method, the PUT will fail (it means that the state of the resource has changed since the last copy the Client recieved) because the precondition (the 'if-match') fails (the submitted Etag does not match the current Etag).
\ Entity tags are used for comparing two or more entities from the same requested resource. Predominantly used for Caching, Etags can also be used to deal with the 'Lost Updates Problem'. An HTTP Client such as Amaya that supports PUT for editing can use the Etag value returned in the head of a GET response in the 'if-match' header submitted with a PUT request. If the Etag for the requested resource in the PUT request's 'if-match' header is different from the current Etag value returned by this method, the PUT will fail (it means that the state of the resource has changed since the last copy the Client recieved) because the precondition (the 'if-match') fails (the submitted Etag does not match the current Etag).
[ "\\", "Entity", "tags", "are", "used", "for", "comparing", "two", "or", "more", "entities", "from", "the", "same", "requested", "resource", ".", "Predominantly", "used", "for", "Caching", "Etags", "can", "also", "be", "used", "to", "deal", "with", "the", "Lost", "Updates", "Problem", ".", "An", "HTTP", "Client", "such", "as", "Amaya", "that", "supports", "PUT", "for", "editing", "can", "use", "the", "Etag", "value", "returned", "in", "the", "head", "of", "a", "GET", "response", "in", "the", "if", "-", "match", "header", "submitted", "with", "a", "PUT", "request", ".", "If", "the", "Etag", "for", "the", "requested", "resource", "in", "the", "PUT", "request", "s", "if", "-", "match", "header", "is", "different", "from", "the", "current", "Etag", "value", "returned", "by", "this", "method", "the", "PUT", "will", "fail", "(", "it", "means", "that", "the", "state", "of", "the", "resource", "has", "changed", "since", "the", "last", "copy", "the", "Client", "recieved", ")", "because", "the", "precondition", "(", "the", "if", "-", "match", ")", "fails", "(", "the", "submitted", "Etag", "does", "not", "match", "the", "current", "Etag", ")", "." ]
def http__etag(): """\ Entity tags are used for comparing two or more entities from the same requested resource. Predominantly used for Caching, Etags can also be used to deal with the 'Lost Updates Problem'. An HTTP Client such as Amaya that supports PUT for editing can use the Etag value returned in the head of a GET response in the 'if-match' header submitted with a PUT request. If the Etag for the requested resource in the PUT request's 'if-match' header is different from the current Etag value returned by this method, the PUT will fail (it means that the state of the resource has changed since the last copy the Client recieved) because the precondition (the 'if-match') fails (the submitted Etag does not match the current Etag). """
[ "def", "http__etag", "(", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/EtagSupport.py#L27-L41
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/EtagSupport.py
python
EtagBaseInterface.http__refreshEtag
()
\ While it may make sense to use the ZODB Object Id or the database mtime to generate an Etag, this could fail on certain REQUESTS because: o The object is not stored in the ZODB, or o A Request such as PUT changes the oid or database mtime *AFTER* the Response has been written out, but the Etag needs to be updated and returned with the Response of the PUT request. Thus, Etags need to be refreshed manually when an object changes.
\ While it may make sense to use the ZODB Object Id or the database mtime to generate an Etag, this could fail on certain REQUESTS because:
[ "\\", "While", "it", "may", "make", "sense", "to", "use", "the", "ZODB", "Object", "Id", "or", "the", "database", "mtime", "to", "generate", "an", "Etag", "this", "could", "fail", "on", "certain", "REQUESTS", "because", ":" ]
def http__refreshEtag(): """\ While it may make sense to use the ZODB Object Id or the database mtime to generate an Etag, this could fail on certain REQUESTS because: o The object is not stored in the ZODB, or o A Request such as PUT changes the oid or database mtime *AFTER* the Response has been written out, but the Etag needs to be updated and returned with the Response of the PUT request. Thus, Etags need to be refreshed manually when an object changes. """
[ "def", "http__refreshEtag", "(", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/EtagSupport.py#L43-L56
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/metaconfigure.py
python
_registerPackage
(module_, init_func=None)
Registers the given python package as a Zope 2 style product
Registers the given python package as a Zope 2 style product
[ "Registers", "the", "given", "python", "package", "as", "a", "Zope", "2", "style", "product" ]
def _registerPackage(module_, init_func=None): """Registers the given python package as a Zope 2 style product """ if not hasattr(module_, '__path__'): raise ValueError("Must be a package and the " "package must be filesystem based") registered_packages = get_registered_packages() registered_packages.append(module_) # Delay the actual setup until the usual product loading time in # OFS.Application. Otherwise, we may get database write errors in # ZEO, when there's no connection with which to write an entry to # Control_Panel. We would also get multiple calls to initialize(). to_initialize = get_packages_to_initialize() to_initialize.append((module_, init_func,))
[ "def", "_registerPackage", "(", "module_", ",", "init_func", "=", "None", ")", ":", "if", "not", "hasattr", "(", "module_", ",", "'__path__'", ")", ":", "raise", "ValueError", "(", "\"Must be a package and the \"", "\"package must be filesystem based\"", ")", "registered_packages", "=", "get_registered_packages", "(", ")", "registered_packages", ".", "append", "(", "module_", ")", "# Delay the actual setup until the usual product loading time in", "# OFS.Application. Otherwise, we may get database write errors in", "# ZEO, when there's no connection with which to write an entry to", "# Control_Panel. We would also get multiple calls to initialize().", "to_initialize", "=", "get_packages_to_initialize", "(", ")", "to_initialize", ".", "append", "(", "(", "module_", ",", "init_func", ",", ")", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/metaconfigure.py#L89-L104
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/metaconfigure.py
python
registerPackage
(_context, package, initialize=None)
ZCML directive function for registering a python package product
ZCML directive function for registering a python package product
[ "ZCML", "directive", "function", "for", "registering", "a", "python", "package", "product" ]
def registerPackage(_context, package, initialize=None): """ZCML directive function for registering a python package product """ _context.action( discriminator=('registerPackage', package), callable=_registerPackage, args=(package, initialize) )
[ "def", "registerPackage", "(", "_context", ",", "package", ",", "initialize", "=", "None", ")", ":", "_context", ".", "action", "(", "discriminator", "=", "(", "'registerPackage'", ",", "package", ")", ",", "callable", "=", "_registerPackage", ",", "args", "=", "(", "package", ",", "initialize", ")", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/metaconfigure.py#L107-L115
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/metaconfigure.py
python
setDeprecatedManageAddDelete
(class_)
Instances of the class will still see their old methods called.
Instances of the class will still see their old methods called.
[ "Instances", "of", "the", "class", "will", "still", "see", "their", "old", "methods", "called", "." ]
def setDeprecatedManageAddDelete(class_): """Instances of the class will still see their old methods called.""" deprecatedManageAddDeleteClasses.append(class_)
[ "def", "setDeprecatedManageAddDelete", "(", "class_", ")", ":", "deprecatedManageAddDeleteClasses", ".", "append", "(", "class_", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/metaconfigure.py#L154-L156
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
View.manage_workspace
(self, URL1, RESPONSE)
Implement a "management" interface
Implement a "management" interface
[ "Implement", "a", "management", "interface" ]
def manage_workspace(self, URL1, RESPONSE): '''Implement a "management" interface ''' RESPONSE.redirect(URL1 + '/manage')
[ "def", "manage_workspace", "(", "self", ",", "URL1", ",", "RESPONSE", ")", ":", "RESPONSE", ".", "redirect", "(", "URL1", "+", "'/manage'", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L53-L56
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
View.manage_options
(self)
return request
Return a manage option data structure for me instance
Return a manage option data structure for me instance
[ "Return", "a", "manage", "option", "data", "structure", "for", "me", "instance" ]
def manage_options(self): """Return a manage option data structure for me instance """ try: request = self.REQUEST except Exception: request = None if request is None: pre = '../../' else: pre = request['URL'] for i in (1, 2, 3): loc = pre.rfind('/') if loc >= 0: pre = pre[:loc] pre = pre + '/' request = [] for d in aq_parent(aq_parent(self)).manage_options: path = d['action'] option = { 'label': d['label'], 'action': pre + path, 'path': '../../' + path, } help = d.get('help') if help is not None: option['help'] = help request.append(option) return request
[ "def", "manage_options", "(", "self", ")", ":", "try", ":", "request", "=", "self", ".", "REQUEST", "except", "Exception", ":", "request", "=", "None", "if", "request", "is", "None", ":", "pre", "=", "'../../'", "else", ":", "pre", "=", "request", "[", "'URL'", "]", "for", "i", "in", "(", "1", ",", "2", ",", "3", ")", ":", "loc", "=", "pre", ".", "rfind", "(", "'/'", ")", "if", "loc", ">=", "0", ":", "pre", "=", "pre", "[", ":", "loc", "]", "pre", "=", "pre", "+", "'/'", "request", "=", "[", "]", "for", "d", "in", "aq_parent", "(", "aq_parent", "(", "self", ")", ")", ".", "manage_options", ":", "path", "=", "d", "[", "'action'", "]", "option", "=", "{", "'label'", ":", "d", "[", "'label'", "]", ",", "'action'", ":", "pre", "+", "path", ",", "'path'", ":", "'../../'", "+", "path", ",", "}", "help", "=", "d", ".", "get", "(", "'help'", ")", "if", "help", "is", "not", "None", ":", "option", "[", "'help'", "]", "=", "help", "request", ".", "append", "(", "option", ")", "return", "request" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L61-L90
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.xml_namespace
(self)
return self._md.get('xmlns', '')
Return a namespace string usable as an xml namespace for this property set.
Return a namespace string usable as an xml namespace for this property set.
[ "Return", "a", "namespace", "string", "usable", "as", "an", "xml", "namespace", "for", "this", "property", "set", "." ]
def xml_namespace(self): """Return a namespace string usable as an xml namespace for this property set.""" return self._md.get('xmlns', '')
[ "def", "xml_namespace", "(", "self", ")", ":", "return", "self", ".", "_md", ".", "get", "(", "'xmlns'", ",", "''", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L145-L148
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.hasProperty
(self, id)
return 0
Return a true value if a property exists with the given id.
Return a true value if a property exists with the given id.
[ "Return", "a", "true", "value", "if", "a", "property", "exists", "with", "the", "given", "id", "." ]
def hasProperty(self, id): """Return a true value if a property exists with the given id.""" for prop in self._propertyMap(): if id == prop['id']: return 1 return 0
[ "def", "hasProperty", "(", "self", ",", "id", ")", ":", "for", "prop", "in", "self", ".", "_propertyMap", "(", ")", ":", "if", "id", "==", "prop", "[", "'id'", "]", ":", "return", "1", "return", "0" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L163-L168
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.propertyIds
(self)
return [i['id'] for i in self._propertyMap()]
Return a list of property ids.
Return a list of property ids.
[ "Return", "a", "list", "of", "property", "ids", "." ]
def propertyIds(self): """Return a list of property ids.""" return [i['id'] for i in self._propertyMap()]
[ "def", "propertyIds", "(", "self", ")", ":", "return", "[", "i", "[", "'id'", "]", "for", "i", "in", "self", ".", "_propertyMap", "(", ")", "]" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L282-L284
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.propertyValues
(self)
return [self.getProperty(i['id']) for i in self._propertyMap()]
Return a list of property values.
Return a list of property values.
[ "Return", "a", "list", "of", "property", "values", "." ]
def propertyValues(self): """Return a list of property values.""" return [self.getProperty(i['id']) for i in self._propertyMap()]
[ "def", "propertyValues", "(", "self", ")", ":", "return", "[", "self", ".", "getProperty", "(", "i", "[", "'id'", "]", ")", "for", "i", "in", "self", ".", "_propertyMap", "(", ")", "]" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L287-L289
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.propertyItems
(self)
return [(i['id'], self.getProperty(i['id'])) for i in self._propertyMap()]
Return a list of (id, property) tuples.
Return a list of (id, property) tuples.
[ "Return", "a", "list", "of", "(", "id", "property", ")", "tuples", "." ]
def propertyItems(self): """Return a list of (id, property) tuples.""" return [(i['id'], self.getProperty(i['id'])) for i in self._propertyMap()]
[ "def", "propertyItems", "(", "self", ")", ":", "return", "[", "(", "i", "[", "'id'", "]", ",", "self", ".", "getProperty", "(", "i", "[", "'id'", "]", ")", ")", "for", "i", "in", "self", ".", "_propertyMap", "(", ")", "]" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L292-L295
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.propertyInfo
(self, id)
Return a mapping containing property meta-data.
Return a mapping containing property meta-data.
[ "Return", "a", "mapping", "containing", "property", "meta", "-", "data", "." ]
def propertyInfo(self, id): """Return a mapping containing property meta-data.""" for p in self._propertyMap(): if p['id'] == id: return p raise ValueError( 'The property %s does not exist.' % html.escape( id, True))
[ "def", "propertyInfo", "(", "self", ",", "id", ")", ":", "for", "p", "in", "self", ".", "_propertyMap", "(", ")", ":", "if", "p", "[", "'id'", "]", "==", "id", ":", "return", "p", "raise", "ValueError", "(", "'The property %s does not exist.'", "%", "html", ".", "escape", "(", "id", ",", "True", ")", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L298-L306
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet._propertyMap
(self)
return self.p_self()._properties
Return a tuple of mappings, giving meta-data for properties.
Return a tuple of mappings, giving meta-data for properties.
[ "Return", "a", "tuple", "of", "mappings", "giving", "meta", "-", "data", "for", "properties", "." ]
def _propertyMap(self): """Return a tuple of mappings, giving meta-data for properties.""" return self.p_self()._properties
[ "def", "_propertyMap", "(", "self", ")", ":", "return", "self", ".", "p_self", "(", ")", ".", "_properties" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L308-L310
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.propertyMap
(self)
return tuple(dict.copy() for dict in self._propertyMap())
Returns a secure copy of the property definitions.
Returns a secure copy of the property definitions.
[ "Returns", "a", "secure", "copy", "of", "the", "property", "definitions", "." ]
def propertyMap(self): """Returns a secure copy of the property definitions.""" return tuple(dict.copy() for dict in self._propertyMap())
[ "def", "propertyMap", "(", "self", ")", ":", "return", "tuple", "(", "dict", ".", "copy", "(", ")", "for", "dict", "in", "self", ".", "_propertyMap", "(", ")", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L313-L315
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.manage_addProperty
(self, id, value, type, REQUEST=None)
Add a new property via the web. Sets a new property with the given id, type, and value.
Add a new property via the web. Sets a new property with the given id, type, and value.
[ "Add", "a", "new", "property", "via", "the", "web", ".", "Sets", "a", "new", "property", "with", "the", "given", "id", "type", "and", "value", "." ]
def manage_addProperty(self, id, value, type, REQUEST=None): """Add a new property via the web. Sets a new property with the given id, type, and value.""" if type in type_converters: value = type_converters[type](value) self._setProperty(id, value, type) if REQUEST is not None: return self.manage(self, REQUEST)
[ "def", "manage_addProperty", "(", "self", ",", "id", ",", "value", ",", "type", ",", "REQUEST", "=", "None", ")", ":", "if", "type", "in", "type_converters", ":", "value", "=", "type_converters", "[", "type", "]", "(", "value", ")", "self", ".", "_setProperty", "(", "id", ",", "value", ",", "type", ")", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage", "(", "self", ",", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L331-L338
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.manage_editProperties
(self, REQUEST)
return self.manage(self, REQUEST, manage_tabs_message=message)
Edit object properties via the web.
Edit object properties via the web.
[ "Edit", "object", "properties", "via", "the", "web", "." ]
def manage_editProperties(self, REQUEST): """Edit object properties via the web.""" for prop in self._propertyMap(): name = prop['id'] if 'w' in prop.get('mode', 'wd'): value = REQUEST.get(name, '') self._updateProperty(name, value) message = 'Your changes have been saved.' return self.manage(self, REQUEST, manage_tabs_message=message)
[ "def", "manage_editProperties", "(", "self", ",", "REQUEST", ")", ":", "for", "prop", "in", "self", ".", "_propertyMap", "(", ")", ":", "name", "=", "prop", "[", "'id'", "]", "if", "'w'", "in", "prop", ".", "get", "(", "'mode'", ",", "'wd'", ")", ":", "value", "=", "REQUEST", ".", "get", "(", "name", ",", "''", ")", "self", ".", "_updateProperty", "(", "name", ",", "value", ")", "message", "=", "'Your changes have been saved.'", "return", "self", ".", "manage", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "message", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L341-L349
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.manage_changeProperties
(self, REQUEST=None, **kw)
return self.manage(self, REQUEST, manage_tabs_message=message)
Change existing object properties. Change object properties by passing either a REQUEST object or name=value parameters
Change existing object properties.
[ "Change", "existing", "object", "properties", "." ]
def manage_changeProperties(self, REQUEST=None, **kw): """Change existing object properties. Change object properties by passing either a REQUEST object or name=value parameters """ if REQUEST is None: props = {} else: props = REQUEST if kw: for name, value in kw.items(): props[name] = value propdict = self._propdict() for name, value in props.items(): if self.hasProperty(name): if 'w' not in propdict[name].get('mode', 'wd'): raise BadRequest('%s cannot be changed' % html.escape(name, True)) self._updateProperty(name, value) message = 'Your changes have been saved.' return self.manage(self, REQUEST, manage_tabs_message=message)
[ "def", "manage_changeProperties", "(", "self", ",", "REQUEST", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "REQUEST", "is", "None", ":", "props", "=", "{", "}", "else", ":", "props", "=", "REQUEST", "if", "kw", ":", "for", "name", ",", "value", "in", "kw", ".", "items", "(", ")", ":", "props", "[", "name", "]", "=", "value", "propdict", "=", "self", ".", "_propdict", "(", ")", "for", "name", ",", "value", "in", "props", ".", "items", "(", ")", ":", "if", "self", ".", "hasProperty", "(", "name", ")", ":", "if", "'w'", "not", "in", "propdict", "[", "name", "]", ".", "get", "(", "'mode'", ",", "'wd'", ")", ":", "raise", "BadRequest", "(", "'%s cannot be changed'", "%", "html", ".", "escape", "(", "name", ",", "True", ")", ")", "self", ".", "_updateProperty", "(", "name", ",", "value", ")", "message", "=", "'Your changes have been saved.'", "return", "self", ".", "manage", "(", "self", ",", "REQUEST", ",", "manage_tabs_message", "=", "message", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L352-L373
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheet.manage_delProperties
(self, ids=None, REQUEST=None)
Delete one or more properties specified by 'ids'.
Delete one or more properties specified by 'ids'.
[ "Delete", "one", "or", "more", "properties", "specified", "by", "ids", "." ]
def manage_delProperties(self, ids=None, REQUEST=None): """Delete one or more properties specified by 'ids'.""" if REQUEST: # Bugfix for properties named "ids" (casey) if ids == self.getProperty('ids', None): ids = None ids = REQUEST.get('_ids', ids) if ids is None: raise BadRequest('No property specified') for id in ids: self._delProperty(id) if REQUEST is not None: return self.manage(self, REQUEST)
[ "def", "manage_delProperties", "(", "self", ",", "ids", "=", "None", ",", "REQUEST", "=", "None", ")", ":", "if", "REQUEST", ":", "# Bugfix for properties named \"ids\" (casey)", "if", "ids", "==", "self", ".", "getProperty", "(", "'ids'", ",", "None", ")", ":", "ids", "=", "None", "ids", "=", "REQUEST", ".", "get", "(", "'_ids'", ",", "ids", ")", "if", "ids", "is", "None", ":", "raise", "BadRequest", "(", "'No property specified'", ")", "for", "id", "in", "ids", ":", "self", ".", "_delProperty", "(", "id", ")", "if", "REQUEST", "is", "not", "None", ":", "return", "self", ".", "manage", "(", "self", ",", "REQUEST", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L376-L388
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheets.isDeletable
(self, name)
return 1
currently, we say that *name* is deletable when it is not a default sheet. Later, we may further restrict deletability based on an instance attribute.
currently, we say that *name* is deletable when it is not a default sheet. Later, we may further restrict deletability based on an instance attribute.
[ "currently", "we", "say", "that", "*", "name", "*", "is", "deletable", "when", "it", "is", "not", "a", "default", "sheet", ".", "Later", "we", "may", "further", "restrict", "deletability", "based", "on", "an", "instance", "attribute", "." ]
def isDeletable(self, name): '''currently, we say that *name* is deletable when it is not a default sheet. Later, we may further restrict deletability based on an instance attribute.''' ps = self.get(name) if ps is None: return 0 if ps in self._get_defaults(): return 0 return 1
[ "def", "isDeletable", "(", "self", ",", "name", ")", ":", "ps", "=", "self", ".", "get", "(", "name", ")", "if", "ps", "is", "None", ":", "return", "0", "if", "ps", "in", "self", ".", "_get_defaults", "(", ")", ":", "return", "0", "return", "1" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L494-L503
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheets.manage_delPropertySheets
(self, ids=(), REQUEST=None)
delete all sheets identified by *ids*.
delete all sheets identified by *ids*.
[ "delete", "all", "sheets", "identified", "by", "*", "ids", "*", "." ]
def manage_delPropertySheets(self, ids=(), REQUEST=None): '''delete all sheets identified by *ids*.''' for id in ids: if not self.isDeletable(id): raise BadRequest( 'attempt to delete undeletable property sheet: ' + id) self.delPropertySheet(id) if REQUEST is not None: REQUEST.RESPONSE.redirect('%s/manage' % self.absolute_url())
[ "def", "manage_delPropertySheets", "(", "self", ",", "ids", "=", "(", ")", ",", "REQUEST", "=", "None", ")", ":", "for", "id", "in", "ids", ":", "if", "not", "self", ".", "isDeletable", "(", "id", ")", ":", "raise", "BadRequest", "(", "'attempt to delete undeletable property sheet: '", "+", "id", ")", "self", ".", "delPropertySheet", "(", "id", ")", "if", "REQUEST", "is", "not", "None", ":", "REQUEST", ".", "RESPONSE", ".", "redirect", "(", "'%s/manage'", "%", "self", ".", "absolute_url", "(", ")", ")" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L505-L513
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/OFS/PropertySheets.py
python
PropertySheets.manage_options
(self)
return request
Return a manage option data structure for me instance
Return a manage option data structure for me instance
[ "Return", "a", "manage", "option", "data", "structure", "for", "me", "instance" ]
def manage_options(self): """Return a manage option data structure for me instance """ try: request = self.REQUEST except Exception: request = None if request is None: pre = '../' else: pre = request['URLPATH0'] for i in (1, 2): loc = pre.rfind('/') if loc >= 0: pre = pre[:loc] pre = pre + '/' request = [] for d in aq_parent(self).manage_options: request.append({'label': d['label'], 'action': pre + d['action']}) return request
[ "def", "manage_options", "(", "self", ")", ":", "try", ":", "request", "=", "self", ".", "REQUEST", "except", "Exception", ":", "request", "=", "None", "if", "request", "is", "None", ":", "pre", "=", "'../'", "else", ":", "pre", "=", "request", "[", "'URLPATH0'", "]", "for", "i", "in", "(", "1", ",", "2", ")", ":", "loc", "=", "pre", ".", "rfind", "(", "'/'", ")", "if", "loc", ">=", "0", ":", "pre", "=", "pre", "[", ":", "loc", "]", "pre", "=", "pre", "+", "'/'", "request", "=", "[", "]", "for", "d", "in", "aq_parent", "(", "self", ")", ".", "manage_options", ":", "request", ".", "append", "(", "{", "'label'", ":", "d", "[", "'label'", "]", ",", "'action'", ":", "pre", "+", "d", "[", "'action'", "]", "}", ")", "return", "request" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/OFS/PropertySheets.py#L524-L544
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.dav__init
(request, response)
Init expected HTTP 1.1 / WebDAV headers which are not currently set by the base response object automagically. Also, we sniff for a ZServer response object, because we don't want to write duplicate headers (since ZS writes Date and Connection itself).
Init expected HTTP 1.1 / WebDAV headers which are not currently set by the base response object automagically.
[ "Init", "expected", "HTTP", "1", ".", "1", "/", "WebDAV", "headers", "which", "are", "not", "currently", "set", "by", "the", "base", "response", "object", "automagically", "." ]
def dav__init(request, response): """Init expected HTTP 1.1 / WebDAV headers which are not currently set by the base response object automagically. Also, we sniff for a ZServer response object, because we don't want to write duplicate headers (since ZS writes Date and Connection itself). """
[ "def", "dav__init", "(", "request", ",", "response", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L35-L42
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.HEAD
(REQUEST, RESPONSE)
Retrieve resource information without a response body.
Retrieve resource information without a response body.
[ "Retrieve", "resource", "information", "without", "a", "response", "body", "." ]
def HEAD(REQUEST, RESPONSE): """Retrieve resource information without a response body."""
[ "def", "HEAD", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L53-L54
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.PUT
(REQUEST, RESPONSE)
Replace the GET response entity of an existing resource. Because this is often object-dependent, objects which handle PUT should override the default PUT implementation with an object-specific implementation. By default, PUT requests fail with a 405 (Method Not Allowed).
Replace the GET response entity of an existing resource. Because this is often object-dependent, objects which handle PUT should override the default PUT implementation with an object-specific implementation. By default, PUT requests fail with a 405 (Method Not Allowed).
[ "Replace", "the", "GET", "response", "entity", "of", "an", "existing", "resource", ".", "Because", "this", "is", "often", "object", "-", "dependent", "objects", "which", "handle", "PUT", "should", "override", "the", "default", "PUT", "implementation", "with", "an", "object", "-", "specific", "implementation", ".", "By", "default", "PUT", "requests", "fail", "with", "a", "405", "(", "Method", "Not", "Allowed", ")", "." ]
def PUT(REQUEST, RESPONSE): """Replace the GET response entity of an existing resource. Because this is often object-dependent, objects which handle PUT should override the default PUT implementation with an object-specific implementation. By default, PUT requests fail with a 405 (Method Not Allowed)."""
[ "def", "PUT", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L56-L61
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.OPTIONS
(REQUEST, RESPONSE)
Retrieve communication options.
Retrieve communication options.
[ "Retrieve", "communication", "options", "." ]
def OPTIONS(REQUEST, RESPONSE): """Retrieve communication options."""
[ "def", "OPTIONS", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L63-L64
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.TRACE
(REQUEST, RESPONSE)
Return the HTTP message received back to the client as the entity-body of a 200 (OK) response. This will often usually be intercepted by the web server in use. If not, the TRACE request will fail with a 405 (Method Not Allowed), since it is not often possible to reproduce the HTTP request verbatim from within the Zope environment.
Return the HTTP message received back to the client as the entity-body of a 200 (OK) response. This will often usually be intercepted by the web server in use. If not, the TRACE request will fail with a 405 (Method Not Allowed), since it is not often possible to reproduce the HTTP request verbatim from within the Zope environment.
[ "Return", "the", "HTTP", "message", "received", "back", "to", "the", "client", "as", "the", "entity", "-", "body", "of", "a", "200", "(", "OK", ")", "response", ".", "This", "will", "often", "usually", "be", "intercepted", "by", "the", "web", "server", "in", "use", ".", "If", "not", "the", "TRACE", "request", "will", "fail", "with", "a", "405", "(", "Method", "Not", "Allowed", ")", "since", "it", "is", "not", "often", "possible", "to", "reproduce", "the", "HTTP", "request", "verbatim", "from", "within", "the", "Zope", "environment", "." ]
def TRACE(REQUEST, RESPONSE): """Return the HTTP message received back to the client as the entity-body of a 200 (OK) response. This will often usually be intercepted by the web server in use. If not, the TRACE request will fail with a 405 (Method Not Allowed), since it is not often possible to reproduce the HTTP request verbatim from within the Zope environment."""
[ "def", "TRACE", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L66-L72
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.DELETE
(REQUEST, RESPONSE)
Delete a resource. For non-collection resources, DELETE may return either 200 or 204 (No Content) to indicate success.
Delete a resource. For non-collection resources, DELETE may return either 200 or 204 (No Content) to indicate success.
[ "Delete", "a", "resource", ".", "For", "non", "-", "collection", "resources", "DELETE", "may", "return", "either", "200", "or", "204", "(", "No", "Content", ")", "to", "indicate", "success", "." ]
def DELETE(REQUEST, RESPONSE): """Delete a resource. For non-collection resources, DELETE may return either 200 or 204 (No Content) to indicate success."""
[ "def", "DELETE", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L74-L76
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.PROPFIND
(REQUEST, RESPONSE)
Retrieve properties defined on the resource.
Retrieve properties defined on the resource.
[ "Retrieve", "properties", "defined", "on", "the", "resource", "." ]
def PROPFIND(REQUEST, RESPONSE): """Retrieve properties defined on the resource."""
[ "def", "PROPFIND", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L78-L79
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.PROPPATCH
(REQUEST, RESPONSE)
Set and/or remove properties defined on the resource.
Set and/or remove properties defined on the resource.
[ "Set", "and", "/", "or", "remove", "properties", "defined", "on", "the", "resource", "." ]
def PROPPATCH(REQUEST, RESPONSE): """Set and/or remove properties defined on the resource."""
[ "def", "PROPPATCH", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L81-L82
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.MKCOL
(REQUEST, RESPONSE)
Create a new collection resource. If called on an existing resource, MKCOL must fail with 405 (Method Not Allowed).
Create a new collection resource. If called on an existing resource, MKCOL must fail with 405 (Method Not Allowed).
[ "Create", "a", "new", "collection", "resource", ".", "If", "called", "on", "an", "existing", "resource", "MKCOL", "must", "fail", "with", "405", "(", "Method", "Not", "Allowed", ")", "." ]
def MKCOL(REQUEST, RESPONSE): """Create a new collection resource. If called on an existing resource, MKCOL must fail with 405 (Method Not Allowed)."""
[ "def", "MKCOL", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L84-L86
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.COPY
(REQUEST, RESPONSE)
Create a duplicate of the source resource whose state and behavior match that of the source resource as closely as possible. Though we may later try to make a copy appear seamless across namespaces (e.g. from Zope to Apache), COPY is currently only supported within the Zope namespace.
Create a duplicate of the source resource whose state and behavior match that of the source resource as closely as possible. Though we may later try to make a copy appear seamless across namespaces (e.g. from Zope to Apache), COPY is currently only supported within the Zope namespace.
[ "Create", "a", "duplicate", "of", "the", "source", "resource", "whose", "state", "and", "behavior", "match", "that", "of", "the", "source", "resource", "as", "closely", "as", "possible", ".", "Though", "we", "may", "later", "try", "to", "make", "a", "copy", "appear", "seamless", "across", "namespaces", "(", "e", ".", "g", ".", "from", "Zope", "to", "Apache", ")", "COPY", "is", "currently", "only", "supported", "within", "the", "Zope", "namespace", "." ]
def COPY(REQUEST, RESPONSE): """Create a duplicate of the source resource whose state and behavior match that of the source resource as closely as possible. Though we may later try to make a copy appear seamless across namespaces (e.g. from Zope to Apache), COPY is currently only supported within the Zope namespace."""
[ "def", "COPY", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L88-L93
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.MOVE
(REQUEST, RESPONSE)
Move a resource to a new location. Though we may later try to make a move appear seamless across namespaces (e.g. from Zope to Apache), MOVE is currently only supported within the Zope namespace.
Move a resource to a new location. Though we may later try to make a move appear seamless across namespaces (e.g. from Zope to Apache), MOVE is currently only supported within the Zope namespace.
[ "Move", "a", "resource", "to", "a", "new", "location", ".", "Though", "we", "may", "later", "try", "to", "make", "a", "move", "appear", "seamless", "across", "namespaces", "(", "e", ".", "g", ".", "from", "Zope", "to", "Apache", ")", "MOVE", "is", "currently", "only", "supported", "within", "the", "Zope", "namespace", "." ]
def MOVE(REQUEST, RESPONSE): """Move a resource to a new location. Though we may later try to make a move appear seamless across namespaces (e.g. from Zope to Apache), MOVE is currently only supported within the Zope namespace."""
[ "def", "MOVE", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L95-L99
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.LOCK
(REQUEST, RESPONSE)
Lock a resource
Lock a resource
[ "Lock", "a", "resource" ]
def LOCK(REQUEST, RESPONSE): """Lock a resource"""
[ "def", "LOCK", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L101-L102
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.UNLOCK
(REQUEST, RESPONSE)
Remove an existing lock on a resource.
Remove an existing lock on a resource.
[ "Remove", "an", "existing", "lock", "on", "a", "resource", "." ]
def UNLOCK(REQUEST, RESPONSE): """Remove an existing lock on a resource."""
[ "def", "UNLOCK", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L104-L105
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVResource.manage_DAVget
()
Gets the document source
Gets the document source
[ "Gets", "the", "document", "source" ]
def manage_DAVget(): """Gets the document source"""
[ "def", "manage_DAVget", "(", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L107-L108
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVCollection.PUT
(REQUEST, RESPONSE)
The PUT method has no inherent meaning for collection resources, though collections are not specifically forbidden to handle PUT requests. The default response to a PUT request for collections is 405 (Method Not Allowed).
The PUT method has no inherent meaning for collection resources, though collections are not specifically forbidden to handle PUT requests. The default response to a PUT request for collections is 405 (Method Not Allowed).
[ "The", "PUT", "method", "has", "no", "inherent", "meaning", "for", "collection", "resources", "though", "collections", "are", "not", "specifically", "forbidden", "to", "handle", "PUT", "requests", ".", "The", "default", "response", "to", "a", "PUT", "request", "for", "collections", "is", "405", "(", "Method", "Not", "Allowed", ")", "." ]
def PUT(REQUEST, RESPONSE): """The PUT method has no inherent meaning for collection resources, though collections are not specifically forbidden to handle PUT requests. The default response to a PUT request for collections is 405 (Method Not Allowed)."""
[ "def", "PUT", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L130-L134
zopefoundation/Zope
61260fab5776ea4c8bbbb0129d729d05eb183c4c
src/webdav/interfaces.py
python
IDAVCollection.DELETE
(REQUEST, RESPONSE)
Delete a collection resource. For collection resources, DELETE may return either 200 (OK) or 204 (No Content) to indicate total success, or may return 207 (Multistatus) to indicate partial success. Note that in Zope a DELETE currently never returns 207.
Delete a collection resource. For collection resources, DELETE may return either 200 (OK) or 204 (No Content) to indicate total success, or may return 207 (Multistatus) to indicate partial success. Note that in Zope a DELETE currently never returns 207.
[ "Delete", "a", "collection", "resource", ".", "For", "collection", "resources", "DELETE", "may", "return", "either", "200", "(", "OK", ")", "or", "204", "(", "No", "Content", ")", "to", "indicate", "total", "success", "or", "may", "return", "207", "(", "Multistatus", ")", "to", "indicate", "partial", "success", ".", "Note", "that", "in", "Zope", "a", "DELETE", "currently", "never", "returns", "207", "." ]
def DELETE(REQUEST, RESPONSE): """Delete a collection resource. For collection resources, DELETE may return either 200 (OK) or 204 (No Content) to indicate total success, or may return 207 (Multistatus) to indicate partial success. Note that in Zope a DELETE currently never returns 207."""
[ "def", "DELETE", "(", "REQUEST", ",", "RESPONSE", ")", ":" ]
https://github.com/zopefoundation/Zope/blob/61260fab5776ea4c8bbbb0129d729d05eb183c4c/src/webdav/interfaces.py#L136-L140