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
c070bd29
Commit
c070bd29
authored
May 09, 2005
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved ZApplication from ZODB to the App package.
parent
e352bcc5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
5 deletions
+94
-5
lib/python/App/RefreshFuncs.py
lib/python/App/RefreshFuncs.py
+1
-1
lib/python/App/ZApplication.py
lib/python/App/ZApplication.py
+88
-0
lib/python/OFS/tests/testAppInitializer.py
lib/python/OFS/tests/testAppInitializer.py
+1
-1
lib/python/OFS/tests/testProductInit.py
lib/python/OFS/tests/testProductInit.py
+1
-1
lib/python/Testing/ZopeTestCase/sandbox.py
lib/python/Testing/ZopeTestCase/sandbox.py
+3
-2
No files found.
lib/python/App/RefreshFuncs.py
View file @
c070bd29
...
...
@@ -326,7 +326,7 @@ def autoRefresh(jar):
def
setupAutoRefresh
(
jar
):
# Install hook.
from
ZODB
.ZApplication
import
connection_open_hooks
from
App
.ZApplication
import
connection_open_hooks
connection_open_hooks
.
append
(
autoRefresh
)
# Init mod times.
checkAutoRefresh
(
jar
)
lib/python/App/ZApplication.py
0 → 100644
View file @
c070bd29
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Implement an bobo_application object that is BoboPOS3 aware
This module provides a wrapper that causes a database connection to be created
and used when bobo publishes a bobo_application object.
"""
import
transaction
connection_open_hooks
=
[]
class
ZApplicationWrapper
:
def
__init__
(
self
,
db
,
name
,
klass
=
None
,
klass_args
=
(),
version_cookie_name
=
None
):
self
.
_stuff
=
db
,
name
,
version_cookie_name
if
klass
is
not
None
:
conn
=
db
.
open
()
root
=
conn
.
root
()
if
not
root
.
has_key
(
name
):
root
[
name
]
=
klass
()
transaction
.
commit
()
conn
.
close
()
self
.
_klass
=
klass
# This hack is to overcome a bug in Bobo!
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
_klass
,
name
)
def
__bobo_traverse__
(
self
,
REQUEST
=
None
,
name
=
None
):
db
,
aname
,
version_support
=
self
.
_stuff
if
version_support
is
not
None
and
REQUEST
is
not
None
:
version
=
REQUEST
.
get
(
version_support
,
''
)
else
:
version
=
''
conn
=
db
.
open
(
version
)
if
connection_open_hooks
:
for
hook
in
connection_open_hooks
:
hook
(
conn
)
# arrange for the connection to be closed when the request goes away
cleanup
=
Cleanup
(
conn
)
REQUEST
.
_hold
(
cleanup
)
conn
.
setDebugInfo
(
REQUEST
.
environ
,
REQUEST
.
other
)
v
=
conn
.
root
()[
aname
]
if
name
is
not
None
:
if
hasattr
(
v
,
'__bobo_traverse__'
):
return
v
.
__bobo_traverse__
(
REQUEST
,
name
)
if
hasattr
(
v
,
name
):
return
getattr
(
v
,
name
)
return
v
[
name
]
return
v
def
__call__
(
self
,
connection
=
None
):
db
,
aname
,
version_support
=
self
.
_stuff
if
connection
is
None
:
connection
=
db
.
open
()
elif
isinstance
(
connection
,
basestring
):
connection
=
db
.
open
(
connection
)
return
connection
.
root
()[
aname
]
class
Cleanup
:
def
__init__
(
self
,
jar
):
self
.
_jar
=
jar
def
__del__
(
self
):
self
.
_jar
.
close
()
lib/python/OFS/tests/testAppInitializer.py
View file @
c070bd29
...
...
@@ -51,7 +51,7 @@ def getSchema():
return
ZConfig
.
loadSchema
(
schemafile
)
def
getApp
():
from
ZODB
.ZApplication
import
ZApplicationWrapper
from
App
.ZApplication
import
ZApplicationWrapper
DB
=
getConfiguration
().
dbtab
.
getDatabase
(
'/'
)
return
ZApplicationWrapper
(
DB
,
'Application'
,
Application
,
(),
'foo'
)()
...
...
lib/python/OFS/tests/testProductInit.py
View file @
c070bd29
...
...
@@ -62,7 +62,7 @@ def getSchema():
return
ZConfig
.
loadSchema
(
schemafile
)
def
getApp
():
from
ZODB
.ZApplication
import
ZApplicationWrapper
from
App
.ZApplication
import
ZApplicationWrapper
DB
=
getConfiguration
().
dbtab
.
getDatabase
(
'/'
)
return
ZApplicationWrapper
(
DB
,
'Application'
,
Application
,
(),
'foo'
)()
...
...
lib/python/Testing/ZopeTestCase/sandbox.py
View file @
c070bd29
...
...
@@ -70,8 +70,9 @@ def __bobo_traverse__(self, REQUEST=None, name=None):
return
self
.
__old_bobo_traverse__
(
REQUEST
,
name
)
from
ZODB
.ZApplication
import
ZApplicationWrapper
from
App
.ZApplication
import
ZApplicationWrapper
if
not
hasattr
(
ZApplicationWrapper
,
'__old_bobo_traverse__'
):
ZApplicationWrapper
.
__old_bobo_traverse__
=
ZApplicationWrapper
.
__bobo_traverse__
ZApplicationWrapper
.
__old_bobo_traverse__
=
(
ZApplicationWrapper
.
__bobo_traverse__
)
ZApplicationWrapper
.
__bobo_traverse__
=
__bobo_traverse__
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