Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
Zope
Commits
1e2e8179
Commit
1e2e8179
authored
26 years ago
by
Jeffrey Shell
Browse files
Options
Download
Email Patches
Plain Diff
added jim's "attrget", and Selector/MultipleSelector classes
parent
c6648e43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
lib/python/Globals.py
lib/python/Globals.py
+31
-2
No files found.
lib/python/Globals.py
View file @
1e2e8179
"""Global definitions"""
__version__
=
'$Revision: 1.1
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
8
$'
[
11
:
-
2
]
import
sys
,
os
from
DateTime
import
DateTime
...
...
@@ -141,12 +141,42 @@ else:
def
package_home
(
globals_dict
):
return
globals_dict
[
'__'
].
__path__
[
0
]
# utility stuff
def
attrget
(
o
,
name
,
default
):
if
hasattr
(
o
,
name
):
return
getattr
(
o
,
name
)
return
default
class
Selector
:
def
__init__
(
self
,
key
):
self
.
_k
=
key
def
__call__
(
self
,
o
):
return
o
[
key
]
class
MultipleSelector
:
def
__init__
(
self
,
keys
):
self
.
_k
=
keys
def
__call__
(
self
,
o
):
r
=
[]
a
=
r
.
append
for
key
in
self
.
_k
:
a
(
o
[
key
])
return
r
def
getitems
(
o
,
names
):
r
=
[]
for
name
in
names
:
v
=
o
[
name
]
##########################################################################
#
# Log
#
# $Log: Globals.py,v $
# Revision 1.18 1998/11/13 20:22:34 jeffrey
# added jim's "attrget", and Selector/MultipleSelector classes
#
# Revision 1.17 1998/10/02 15:00:22 jim
# Added "DevelopmentMode" that auto-reloads HTMLFile objects.
#
...
...
@@ -208,4 +238,3 @@ else:
#
#
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment