Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Eteri
erp5
Commits
a717e296
Commit
a717e296
authored
Jun 17, 2011
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use indentation with 2 spaces
parent
d6cf2eda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
145 deletions
+145
-145
product/ERP5/Document/Coordinate.py
product/ERP5/Document/Coordinate.py
+69
-69
product/ERP5/Document/GeographicAddress.py
product/ERP5/Document/GeographicAddress.py
+76
-76
No files found.
product/ERP5/Document/Coordinate.py
View file @
a717e296
...
@@ -115,20 +115,20 @@ class Coordinate(Base):
...
@@ -115,20 +115,20 @@ class Coordinate(Base):
### Mix-in methods
### Mix-in methods
security
.
declareProtected
(
Permissions
.
View
,
'view'
)
security
.
declareProtected
(
Permissions
.
View
,
'view'
)
def
view
(
self
):
def
view
(
self
):
"""
"""
Return the default view even if index_html is overridden.
Return the default view even if index_html is overridden.
"""
"""
return
self
()
return
self
()
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asText'
)
'asText'
)
def
asText
(
self
):
def
asText
(
self
):
"""
"""
returns the coordinate as a text string
returns the coordinate as a text string
"""
"""
script
=
self
.
_getTypeBasedMethod
(
'asText'
)
script
=
self
.
_getTypeBasedMethod
(
'asText'
)
if
script
is
not
None
:
if
script
is
not
None
:
return
script
()
return
script
()
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getText'
)
'getText'
)
...
@@ -141,13 +141,13 @@ class Coordinate(Base):
...
@@ -141,13 +141,13 @@ class Coordinate(Base):
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'fromText'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'fromText'
)
@
deprecated
@
deprecated
def
fromText
(
self
,
coordinate_text
):
def
fromText
(
self
,
coordinate_text
):
"""
"""
modifies the coordinate according to the input text
modifies the coordinate according to the input text
must be implemented by subclasses
must be implemented by subclasses
"""
"""
script
=
self
.
_getTypeBasedMethod
(
'fromText'
)
script
=
self
.
_getTypeBasedMethod
(
'fromText'
)
if
script
is
not
None
:
if
script
is
not
None
:
return
script
(
text
=
coordinate_text
)
return
script
(
text
=
coordinate_text
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'_setText'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'_setText'
)
def
_setText
(
self
,
value
):
def
_setText
(
self
,
value
):
...
@@ -159,69 +159,69 @@ class Coordinate(Base):
...
@@ -159,69 +159,69 @@ class Coordinate(Base):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'standardTextFormat'
)
'standardTextFormat'
)
def
standardTextFormat
(
self
):
def
standardTextFormat
(
self
):
"""
"""
Returns the standard text formats for telephone numbers
Returns the standard text formats for telephone numbers
"""
"""
pass
pass
security
.
declarePrivate
(
'_writeFromPUT'
)
security
.
declarePrivate
(
'_writeFromPUT'
)
def
_writeFromPUT
(
self
,
body
):
def
_writeFromPUT
(
self
,
body
):
headers
=
{}
headers
=
{}
headers
,
body
=
parseHeadersBody
(
body
,
headers
)
headers
,
body
=
parseHeadersBody
(
body
,
headers
)
lines
=
body
.
split
(
'
\
n
'
)
lines
=
body
.
split
(
'
\
n
'
)
self
.
edit
(
lines
[
0
]
)
self
.
edit
(
lines
[
0
]
)
headers
[
'Format'
]
=
self
.
COORDINATE_FORMAT
headers
[
'Format'
]
=
self
.
COORDINATE_FORMAT
new_subject
=
keywordsplitter
(
headers
)
new_subject
=
keywordsplitter
(
headers
)
headers
[
'Subject'
]
=
new_subject
or
self
.
Subject
()
headers
[
'Subject'
]
=
new_subject
or
self
.
Subject
()
haveheader
=
headers
.
has_key
haveheader
=
headers
.
has_key
for
key
,
value
in
self
.
getMetadataHeaders
():
for
key
,
value
in
self
.
getMetadataHeaders
():
if
key
!=
'Format'
and
not
haveheader
(
key
):
if
key
!=
'Format'
and
not
haveheader
(
key
):
headers
[
key
]
=
value
headers
[
key
]
=
value
self
.
_editMetadata
(
title
=
headers
[
'Title'
],
self
.
_editMetadata
(
title
=
headers
[
'Title'
],
subject
=
headers
[
'Subject'
],
subject
=
headers
[
'Subject'
],
description
=
headers
[
'Description'
],
description
=
headers
[
'Description'
],
contributors
=
headers
[
'Contributors'
],
contributors
=
headers
[
'Contributors'
],
effective_date
=
headers
[
'Effective_date'
],
effective_date
=
headers
[
'Effective_date'
],
expiration_date
=
headers
[
'Expiration_date'
],
expiration_date
=
headers
[
'Expiration_date'
],
format
=
headers
[
'Format'
],
format
=
headers
[
'Format'
],
language
=
headers
[
'Language'
],
language
=
headers
[
'Language'
],
rights
=
headers
[
'Rights'
],
rights
=
headers
[
'Rights'
],
)
)
## FTP handlers
## FTP handlers
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'PUT'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'PUT'
)
def
PUT
(
self
,
REQUEST
,
RESPONSE
):
def
PUT
(
self
,
REQUEST
,
RESPONSE
):
"""
"""
Handle HTTP / WebDAV / FTP PUT requests.
Handle HTTP / WebDAV / FTP PUT requests.
"""
"""
if
not
NoWL
:
if
not
NoWL
:
self
.
dav__init
(
REQUEST
,
RESPONSE
)
self
.
dav__init
(
REQUEST
,
RESPONSE
)
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
try
:
try
:
self
.
_writeFromPUT
(
body
)
self
.
_writeFromPUT
(
body
)
RESPONSE
.
setStatus
(
204
)
RESPONSE
.
setStatus
(
204
)
return
RESPONSE
return
RESPONSE
except
ResourceLockedError
,
msg
:
except
ResourceLockedError
,
msg
:
get_transaction
().
abort
()
get_transaction
().
abort
()
RESPONSE
.
setStatus
(
423
)
RESPONSE
.
setStatus
(
423
)
return
RESPONSE
return
RESPONSE
security
.
declareProtected
(
Permissions
.
View
,
'manage_FTPget'
)
security
.
declareProtected
(
Permissions
.
View
,
'manage_FTPget'
)
def
manage_FTPget
(
self
):
def
manage_FTPget
(
self
):
"""
"""
Get the coordinate as text for WebDAV src / FTP download.
Get the coordinate as text for WebDAV src / FTP download.
"""
"""
hdrlist
=
self
.
getMetadataHeaders
()
hdrlist
=
self
.
getMetadataHeaders
()
hdrtext
=
formatRFC822Headers
(
hdrlist
)
hdrtext
=
formatRFC822Headers
(
hdrlist
)
bodytext
=
'%s
\
n
\
n
%s'
%
(
hdrtext
,
self
.
asText
()
)
bodytext
=
'%s
\
n
\
n
%s'
%
(
hdrtext
,
self
.
asText
()
)
return
bodytext
return
bodytext
security
.
declareProtected
(
Permissions
.
View
,
'get_size'
)
security
.
declareProtected
(
Permissions
.
View
,
'get_size'
)
def
get_size
(
self
):
def
get_size
(
self
):
"""
"""
Used for FTP and apparently the ZMI now too
Used for FTP and apparently the ZMI now too
"""
"""
return
len
(
self
.
manage_FTPget
())
return
len
(
self
.
manage_FTPget
())
product/ERP5/Document/GeographicAddress.py
View file @
a717e296
...
@@ -37,91 +37,91 @@ from Products.ERP5.Document.Coordinate import Coordinate
...
@@ -37,91 +37,91 @@ from Products.ERP5.Document.Coordinate import Coordinate
import
string
import
string
class
GeographicAddress
(
Coordinate
,
Base
):
class
GeographicAddress
(
Coordinate
,
Base
):
"""
"""
A geographic address holds a complete set of
A geographic address holds a complete set of
geographic coordinates including street, number,
geographic coordinates including street, number,
city, zip code, region.
city, zip code, region.
Geographic address is a terminating leaf
Geographic address is a terminating leaf
in the OFS. It can not contain anything.
in the OFS. It can not contain anything.
Geographic address inherits from Base and
Geographic address inherits from Base and
from the mix-in Coordinate
from the mix-in Coordinate
"""
"""
meta_type
=
'ERP5 Geographic Address'
meta_type
=
'ERP5 Geographic Address'
portal_type
=
'Address'
portal_type
=
'Address'
add_permission
=
Permissions
.
AddPortalContent
add_permission
=
Permissions
.
AddPortalContent
# Declarative security
# Declarative security
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
# Declarative properties
# Declarative properties
property_sheets
=
(
PropertySheet
.
Base
property_sheets
=
(
PropertySheet
.
Base
,
PropertySheet
.
SimpleItem
,
PropertySheet
.
SimpleItem
,
PropertySheet
.
SortIndex
,
PropertySheet
.
SortIndex
,
PropertySheet
.
CategoryCore
,
PropertySheet
.
CategoryCore
,
PropertySheet
.
Coordinate
,
PropertySheet
.
Coordinate
,
PropertySheet
.
GeographicAddress
,
PropertySheet
.
GeographicAddress
)
)
def
_splitCoordinateText
(
self
,
coordinate_text
):
def
_splitCoordinateText
(
self
,
coordinate_text
):
"""return street_address, zip_code, city tuple parsed from string
"""return street_address, zip_code, city tuple parsed from string
"""
"""
line_list
=
coordinate_text
.
splitlines
()
line_list
=
coordinate_text
.
splitlines
()
street_address
=
zip_code
=
city
=
''
street_address
=
zip_code
=
city
=
''
zip_city
=
None
zip_city
=
None
if
len
(
line_list
)
>
1
:
if
len
(
line_list
)
>
1
:
street_address
=
''
.
join
(
line_list
[
0
:
-
1
])
street_address
=
''
.
join
(
line_list
[
0
:
-
1
])
zip_city
=
line_list
[
-
1
].
split
()
zip_city
=
line_list
[
-
1
].
split
()
elif
len
(
line_list
):
elif
len
(
line_list
):
street_address
=
''
street_address
=
''
zip_city
=
line_list
[
-
1
].
split
()
zip_city
=
line_list
[
-
1
].
split
()
if
zip_city
:
if
zip_city
:
zip_code
=
zip_city
[
0
]
zip_code
=
zip_city
[
0
]
if
len
(
zip_city
)
>
1
:
if
len
(
zip_city
)
>
1
:
city
=
''
.
join
(
zip_city
[
1
:])
city
=
''
.
join
(
zip_city
[
1
:])
return
street_address
,
zip_code
,
city
return
street_address
,
zip_code
,
city
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asText'
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asText'
)
def
asText
(
self
):
def
asText
(
self
):
"""
"""
Returns the address as a complete formatted string
Returns the address as a complete formatted string
with street address, zip, and city
with street address, zip, and city
"""
"""
result
=
Coordinate
.
asText
(
self
)
result
=
Coordinate
.
asText
(
self
)
if
result
is
None
:
if
result
is
None
:
if
self
.
hasData
():
if
self
.
hasData
():
street_address
,
city
,
zip_code
=
self
.
_splitCoordinateText
(
self
.
getData
(
''
))
street_address
,
city
,
zip_code
=
self
.
_splitCoordinateText
(
self
.
getData
(
''
))
else
:
else
:
street_address
=
self
.
getStreetAddress
(
''
)
street_address
=
self
.
getStreetAddress
(
''
)
city
=
self
.
getCity
(
''
)
city
=
self
.
getCity
(
''
)
zip_code
=
self
.
getZipCode
(
''
)
zip_code
=
self
.
getZipCode
(
''
)
result
=
'%s
\
n
%s %s'
%
(
street_address
,
city
,
zip_code
,)
result
=
'%s
\
n
%s %s'
%
(
street_address
,
city
,
zip_code
,)
if
not
result
.
strip
():
if
not
result
.
strip
():
return
''
return
''
return
result
return
result
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'fromText'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'fromText'
)
@
deprecated
@
deprecated
def
fromText
(
self
,
coordinate_text
):
def
fromText
(
self
,
coordinate_text
):
"""Save given data then continue parsing
"""Save given data then continue parsing
(deprecated because computed values are stored)
(deprecated because computed values are stored)
"""
"""
self
.
_setData
(
coordinate_text
)
self
.
_setData
(
coordinate_text
)
street_address
,
city
,
zip_code
=
self
.
_splitCoordinateText
(
coordinate_text
)
street_address
,
city
,
zip_code
=
self
.
_splitCoordinateText
(
coordinate_text
)
self
.
setStreetAddress
(
street_address
)
self
.
setStreetAddress
(
street_address
)
self
.
setZipCode
(
zip_code
)
self
.
setZipCode
(
zip_code
)
self
.
setCity
(
city
)
self
.
setCity
(
city
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'standardTextFormat'
)
'standardTextFormat'
)
def
standardTextFormat
(
self
):
def
standardTextFormat
(
self
):
"""
"""
Returns the standard text format for geographic addresses
Returns the standard text format for geographic addresses
"""
"""
return
(
"""
\
return
(
"""
\
c/o Jean-Paul Sartre
c/o Jean-Paul Sartre
43, avenue Kleber
43, avenue Kleber
75118 Paris Cedex 5
75118 Paris Cedex 5
...
...
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