Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
e2c36131
Commit
e2c36131
authored
Dec 09, 1999
by
Amos Latteier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support in the Product registration process for registering online help topics.
parent
aa3ed4ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
2 deletions
+73
-2
lib/python/App/Product.py
lib/python/App/Product.py
+6
-1
lib/python/App/ProductContext.py
lib/python/App/ProductContext.py
+67
-1
No files found.
lib/python/App/Product.py
View file @
e2c36131
...
...
@@ -113,6 +113,8 @@ from string import rfind, atoi, find, strip, join
from
Factory
import
Factory
from
Permission
import
PermissionManager
import
ZClasses
,
ZClasses
.
ZClass
from
HelpSys.HelpSystem
import
ProductHelp
class
ProductFolder
(
Folder
):
"Manage a collection of Products"
...
...
@@ -198,6 +200,8 @@ class Product(Folder, PermissionManager):
{
'id'
:
'version'
,
'type'
:
'string'
},
)
_reserved_names
=
(
'Help'
,)
manage_addPrincipiaFactoryForm
=
Globals
.
HTMLFile
(
'addFactory'
,
globals
())
def
manage_addPrincipiaFactory
(
self
,
id
,
title
,
object_type
,
initial
,
permission
=
None
,
REQUEST
=
None
):
...
...
@@ -210,7 +214,8 @@ class Product(Folder, PermissionManager):
def
__init__
(
self
,
id
,
title
):
self
.
id
=
id
self
.
title
=
title
self
.
_setObject
(
'Help'
,
ProductHelp
(
'Help'
,
'%s Help'
%
id
))
def
Destination
(
self
):
"Return the destination for factory output"
return
self
...
...
lib/python/App/ProductContext.py
View file @
e2c36131
...
...
@@ -86,6 +86,8 @@
"""
from
AccessControl.PermissionRole
import
PermissionRole
import
Globals
,
os
,
OFS
.
ObjectManager
,
OFS
.
misc_
,
Products
,
OFS
.
PropertySheets
from
HelpSys
import
HelpTopic
import
string
,
os
.
path
if
not
hasattr
(
Products
,
'meta_types'
):
Products
.
meta_types
=
()
if
not
hasattr
(
Products
,
'meta_classes'
):
...
...
@@ -102,6 +104,7 @@ class ProductContext:
def
registerClass
(
self
,
instance_class
=
None
,
meta_type
=
''
,
permission
=
None
,
constructors
=
(),
icon
=
None
,
permissions
=
None
,
legacy
=
(),
constructor_help
=
None
,
):
"""Register a constructor
...
...
@@ -201,7 +204,8 @@ class ProductContext:
{
'name'
:
meta_type
or
instance_class
.
meta_type
,
'action'
:
(
'manage_addProduct/%s/%s'
%
(
pid
,
name
)),
'product'
:
pid
,
'permission'
:
permission
,
'permission'
:
permission
,
'help'
:
constructor_help
},)
m
[
name
]
=
initial
...
...
@@ -248,3 +252,65 @@ class ProductContext:
Z
.
__module__
=
pack
.
__name__
setattr
(
pack
,
zname
,
Z
)
return
self
.
registerZClass
(
Z
,
meta_type
)
def
registerHelpTopic
(
self
,
id
,
topic
):
"""
Register a Help Topic for a product.
"""
self
.
__prod
.
__of__
(
self
.
__app
.
Control_Panel
.
Products
).
Help
.
_setObject
(
id
,
topic
)
def
registerHelpViews
(
self
,
klass
):
"""
Associates a class's views with help topics.
This relies on the manage_options structure of
the class.
Note: right now this just sets the permissions on
the help topics.
"""
# this needs to be better thought out.
#
for
option
in
klass
.
manage_options
:
if
option
.
has_key
(
'help'
):
prod_id
,
topic_id
=
option
[
'help'
]
prod
=
getattr
(
self
.
__app
.
Control_Panel
.
Products
,
prod_id
)
topic
=
getattr
(
pdoc
.
Help
,
topic_id
)
perms
=
topic
.
permissions
+
[
permission
]
topic
.
_setPropValue
(
'permissions'
,
perms
)
def
registerHelp
(
self
,
directory
=
'help'
,
clear
=
1
):
"""
Registers Help Topics for all objects in a directory.
'clear' indicates whether or not to delete all existing
Topics from the Product.
HelpTopics are created for these kind of files
.dtml -- DTMLHelpTopic
.html .htm .txt -- TextHelpTopic
.stx .txt -- STXHelpTopic
.jpg .png .gif -- ImageHelpTopic
"""
if
clear
:
help
=
self
.
__prod
.
__of__
(
self
.
__app
.
Control_Panel
.
Products
).
Help
for
id
in
help
.
objectIds
(
'Help Topic'
):
help
.
_delObject
(
id
)
path
=
os
.
path
.
join
(
Globals
.
package_home
(
self
.
__pack
.
__dict__
),
directory
)
for
file
in
os
.
listdir
(
path
):
ext
=
os
.
path
.
splitext
(
file
)[
1
]
ext
=
string
.
lower
(
ext
)
if
ext
in
(
'.dtml'
,):
ht
=
HelpTopic
.
DTMLTopic
(
file
,
''
,
os
.
path
.
join
(
path
,
file
))
self
.
registerHelpTopic
(
file
,
ht
)
elif
ext
in
(
'.html'
,
'.htm'
):
ht
=
HelpTopic
.
TextTopic
(
file
,
''
,
os
.
path
.
join
(
path
,
file
))
self
.
registerHelpTopic
(
file
,
ht
)
elif
ext
in
(
'.stx'
,
'.txt'
):
ht
=
HelpTopic
.
STXTopic
(
file
,
''
,
os
.
path
.
join
(
path
,
file
))
self
.
registerHelpTopic
(
file
,
ht
)
elif
ext
in
(
'.jpg'
,
'.gif'
,
'.png'
):
ht
=
HelpTopic
.
ImageTopic
(
file
,
''
,
os
.
path
.
join
(
path
,
file
))
self
.
registerHelpTopic
(
file
,
ht
)
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