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
1
Merge Requests
1
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
Vincent Bechu
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):
### Mix-in methods
security
.
declareProtected
(
Permissions
.
View
,
'view'
)
def
view
(
self
):
"""
Return the default view even if index_html is overridden.
"""
return
self
()
"""
Return the default view even if index_html is overridden.
"""
return
self
()
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asText'
)
def
asText
(
self
):
"""
returns the coordinate as a text string
"""
script
=
self
.
_getTypeBasedMethod
(
'asText'
)
if
script
is
not
None
:
return
script
()
"""
returns the coordinate as a text string
"""
script
=
self
.
_getTypeBasedMethod
(
'asText'
)
if
script
is
not
None
:
return
script
()
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getText'
)
...
...
@@ -141,13 +141,13 @@ class Coordinate(Base):
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'fromText'
)
@
deprecated
def
fromText
(
self
,
coordinate_text
):
"""
modifies the coordinate according to the input text
must be implemented by subclasses
"""
script
=
self
.
_getTypeBasedMethod
(
'fromText'
)
if
script
is
not
None
:
return
script
(
text
=
coordinate_text
)
"""
modifies the coordinate according to the input text
must be implemented by subclasses
"""
script
=
self
.
_getTypeBasedMethod
(
'fromText'
)
if
script
is
not
None
:
return
script
(
text
=
coordinate_text
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'_setText'
)
def
_setText
(
self
,
value
):
...
...
@@ -159,69 +159,69 @@ class Coordinate(Base):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'standardTextFormat'
)
def
standardTextFormat
(
self
):
"""
Returns the standard text formats for telephone numbers
"""
pass
"""
Returns the standard text formats for telephone numbers
"""
pass
security
.
declarePrivate
(
'_writeFromPUT'
)
def
_writeFromPUT
(
self
,
body
):
headers
=
{}
headers
,
body
=
parseHeadersBody
(
body
,
headers
)
lines
=
body
.
split
(
'
\
n
'
)
self
.
edit
(
lines
[
0
]
)
headers
[
'Format'
]
=
self
.
COORDINATE_FORMAT
new_subject
=
keywordsplitter
(
headers
)
headers
[
'Subject'
]
=
new_subject
or
self
.
Subject
()
haveheader
=
headers
.
has_key
for
key
,
value
in
self
.
getMetadataHeaders
():
if
key
!=
'Format'
and
not
haveheader
(
key
):
headers
[
key
]
=
value
self
.
_editMetadata
(
title
=
headers
[
'Title'
],
subject
=
headers
[
'Subject'
],
description
=
headers
[
'Description'
],
contributors
=
headers
[
'Contributors'
],
effective_date
=
headers
[
'Effective_date'
],
expiration_date
=
headers
[
'Expiration_date'
],
format
=
headers
[
'Format'
],
language
=
headers
[
'Language'
],
rights
=
headers
[
'Rights'
],
)
headers
=
{}
headers
,
body
=
parseHeadersBody
(
body
,
headers
)
lines
=
body
.
split
(
'
\
n
'
)
self
.
edit
(
lines
[
0
]
)
headers
[
'Format'
]
=
self
.
COORDINATE_FORMAT
new_subject
=
keywordsplitter
(
headers
)
headers
[
'Subject'
]
=
new_subject
or
self
.
Subject
()
haveheader
=
headers
.
has_key
for
key
,
value
in
self
.
getMetadataHeaders
():
if
key
!=
'Format'
and
not
haveheader
(
key
):
headers
[
key
]
=
value
self
.
_editMetadata
(
title
=
headers
[
'Title'
],
subject
=
headers
[
'Subject'
],
description
=
headers
[
'Description'
],
contributors
=
headers
[
'Contributors'
],
effective_date
=
headers
[
'Effective_date'
],
expiration_date
=
headers
[
'Expiration_date'
],
format
=
headers
[
'Format'
],
language
=
headers
[
'Language'
],
rights
=
headers
[
'Rights'
],
)
## FTP handlers
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'PUT'
)
def
PUT
(
self
,
REQUEST
,
RESPONSE
):
"""
Handle HTTP / WebDAV / FTP PUT requests.
"""
if
not
NoWL
:
self
.
dav__init
(
REQUEST
,
RESPONSE
)
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
try
:
self
.
_writeFromPUT
(
body
)
RESPONSE
.
setStatus
(
204
)
return
RESPONSE
except
ResourceLockedError
,
msg
:
get_transaction
().
abort
()
RESPONSE
.
setStatus
(
423
)
return
RESPONSE
"""
Handle HTTP / WebDAV / FTP PUT requests.
"""
if
not
NoWL
:
self
.
dav__init
(
REQUEST
,
RESPONSE
)
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
try
:
self
.
_writeFromPUT
(
body
)
RESPONSE
.
setStatus
(
204
)
return
RESPONSE
except
ResourceLockedError
,
msg
:
get_transaction
().
abort
()
RESPONSE
.
setStatus
(
423
)
return
RESPONSE
security
.
declareProtected
(
Permissions
.
View
,
'manage_FTPget'
)
def
manage_FTPget
(
self
):
"""
Get the coordinate as text for WebDAV src / FTP download.
"""
hdrlist
=
self
.
getMetadataHeaders
()
hdrtext
=
formatRFC822Headers
(
hdrlist
)
bodytext
=
'%s
\
n
\
n
%s'
%
(
hdrtext
,
self
.
asText
()
)
"""
Get the coordinate as text for WebDAV src / FTP download.
"""
hdrlist
=
self
.
getMetadataHeaders
()
hdrtext
=
formatRFC822Headers
(
hdrlist
)
bodytext
=
'%s
\
n
\
n
%s'
%
(
hdrtext
,
self
.
asText
()
)
return
bodytext
return
bodytext
security
.
declareProtected
(
Permissions
.
View
,
'get_size'
)
def
get_size
(
self
):
"""
Used for FTP and apparently the ZMI now too
"""
return
len
(
self
.
manage_FTPget
())
"""
Used for FTP and apparently the ZMI now too
"""
return
len
(
self
.
manage_FTPget
())
product/ERP5/Document/GeographicAddress.py
View file @
a717e296
...
...
@@ -37,91 +37,91 @@ from Products.ERP5.Document.Coordinate import Coordinate
import
string
class
GeographicAddress
(
Coordinate
,
Base
):
"""
A geographic address holds a complete set of
geographic coordinates including street, number,
city, zip code, region.
"""
A geographic address holds a complete set of
geographic coordinates including street, number,
city, zip code, region.
Geographic address is a terminating leaf
in the OFS. It can not contain anything.
Geographic address is a terminating leaf
in the OFS. It can not contain anything.
Geographic address inherits from Base and
from the mix-in Coordinate
"""
meta_type
=
'ERP5 Geographic Address'
portal_type
=
'Address'
add_permission
=
Permissions
.
AddPortalContent
Geographic address inherits from Base and
from the mix-in Coordinate
"""
meta_type
=
'ERP5 Geographic Address'
portal_type
=
'Address'
add_permission
=
Permissions
.
AddPortalContent
# Declarative security
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
# Declarative security
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
# Declarative properties
property_sheets
=
(
PropertySheet
.
Base
,
PropertySheet
.
SimpleItem
,
PropertySheet
.
SortIndex
,
PropertySheet
.
CategoryCore
,
PropertySheet
.
Coordinate
,
PropertySheet
.
GeographicAddress
)
# Declarative properties
property_sheets
=
(
PropertySheet
.
Base
,
PropertySheet
.
SimpleItem
,
PropertySheet
.
SortIndex
,
PropertySheet
.
CategoryCore
,
PropertySheet
.
Coordinate
,
PropertySheet
.
GeographicAddress
)
def
_splitCoordinateText
(
self
,
coordinate_text
):
"""return street_address, zip_code, city tuple parsed from string
"""
line_list
=
coordinate_text
.
splitlines
()
street_address
=
zip_code
=
city
=
''
zip_city
=
None
if
len
(
line_list
)
>
1
:
street_address
=
''
.
join
(
line_list
[
0
:
-
1
])
zip_city
=
line_list
[
-
1
].
split
()
elif
len
(
line_list
):
street_address
=
''
zip_city
=
line_list
[
-
1
].
split
()
if
zip_city
:
zip_code
=
zip_city
[
0
]
if
len
(
zip_city
)
>
1
:
city
=
''
.
join
(
zip_city
[
1
:])
return
street_address
,
zip_code
,
city
def
_splitCoordinateText
(
self
,
coordinate_text
):
"""return street_address, zip_code, city tuple parsed from string
"""
line_list
=
coordinate_text
.
splitlines
()
street_address
=
zip_code
=
city
=
''
zip_city
=
None
if
len
(
line_list
)
>
1
:
street_address
=
''
.
join
(
line_list
[
0
:
-
1
])
zip_city
=
line_list
[
-
1
].
split
()
elif
len
(
line_list
):
street_address
=
''
zip_city
=
line_list
[
-
1
].
split
()
if
zip_city
:
zip_code
=
zip_city
[
0
]
if
len
(
zip_city
)
>
1
:
city
=
''
.
join
(
zip_city
[
1
:])
return
street_address
,
zip_code
,
city
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asText'
)
def
asText
(
self
):
"""
Returns the address as a complete formatted string
with street address, zip, and city
"""
result
=
Coordinate
.
asText
(
self
)
if
result
is
None
:
if
self
.
hasData
():
street_address
,
city
,
zip_code
=
self
.
_splitCoordinateText
(
self
.
getData
(
''
))
else
:
street_address
=
self
.
getStreetAddress
(
''
)
city
=
self
.
getCity
(
''
)
zip_code
=
self
.
getZipCode
(
''
)
result
=
'%s
\
n
%s %s'
%
(
street_address
,
city
,
zip_code
,)
if
not
result
.
strip
():
return
''
return
result
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asText'
)
def
asText
(
self
):
"""
Returns the address as a complete formatted string
with street address, zip, and city
"""
result
=
Coordinate
.
asText
(
self
)
if
result
is
None
:
if
self
.
hasData
():
street_address
,
city
,
zip_code
=
self
.
_splitCoordinateText
(
self
.
getData
(
''
))
else
:
street_address
=
self
.
getStreetAddress
(
''
)
city
=
self
.
getCity
(
''
)
zip_code
=
self
.
getZipCode
(
''
)
result
=
'%s
\
n
%s %s'
%
(
street_address
,
city
,
zip_code
,)
if
not
result
.
strip
():
return
''
return
result
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'fromText'
)
@
deprecated
def
fromText
(
self
,
coordinate_text
):
"""Save given data then continue parsing
(deprecated because computed values are stored)
"""
self
.
_setData
(
coordinate_text
)
street_address
,
city
,
zip_code
=
self
.
_splitCoordinateText
(
coordinate_text
)
self
.
setStreetAddress
(
street_address
)
self
.
setZipCode
(
zip_code
)
self
.
setCity
(
city
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'fromText'
)
@
deprecated
def
fromText
(
self
,
coordinate_text
):
"""Save given data then continue parsing
(deprecated because computed values are stored)
"""
self
.
_setData
(
coordinate_text
)
street_address
,
city
,
zip_code
=
self
.
_splitCoordinateText
(
coordinate_text
)
self
.
setStreetAddress
(
street_address
)
self
.
setZipCode
(
zip_code
)
self
.
setCity
(
city
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'standardTextFormat'
)
def
standardTextFormat
(
self
):
"""
Returns the standard text format for geographic addresses
"""
return
(
"""
\
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'standardTextFormat'
)
def
standardTextFormat
(
self
):
"""
Returns the standard text format for geographic addresses
"""
return
(
"""
\
c/o Jean-Paul Sartre
43, avenue Kleber
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