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
Papa Tamsir Kane
erp5
Commits
e328cbcd
Commit
e328cbcd
authored
Aug 28, 2017
by
Papa Tamsir Kane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_bookmark: Auto generate reference
parent
1f80db2b
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
291 additions
and
8 deletions
+291
-8
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/URL_getReference.py
...kinTemplateItem/portal_skins/erp5_url/URL_getReference.py
+40
-0
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/URL_getReference.xml
...inTemplateItem/portal_skins/erp5_url/URL_getReference.xml
+62
-0
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_decode.py
...mark/SkinTemplateItem/portal_skins/erp5_url/Url_decode.py
+21
-0
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_decode.xml
...ark/SkinTemplateItem/portal_skins/erp5_url/Url_decode.xml
+62
-0
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_getReferenceGeneratorConfig.py
.../portal_skins/erp5_url/Url_getReferenceGeneratorConfig.py
+8
-0
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_getReferenceGeneratorConfig.xml
...portal_skins/erp5_url/Url_getReferenceGeneratorConfig.xml
+62
-0
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_getRelatedCurationRequestLines.py
...rtal_skins/erp5_url/Url_getRelatedCurationRequestLines.py
+1
-1
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_viewAsUrl.xml
.../SkinTemplateItem/portal_skins/erp5_url/Url_viewAsUrl.xml
+1
-1
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_viewAsUrl/my_reference.xml
...Item/portal_skins/erp5_url/Url_viewAsUrl/my_reference.xml
+34
-6
No files found.
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/URL_getReference.py
0 → 100644
View file @
e328cbcd
reference
=
context
.
getReference
()
if
reference
:
return
reference
def
encode
(
n
,
alphabet
,
mapping
,
mask
,
min_length
):
n_and_mask
=
n
&
mask
result
=
0
for
i
,
b
in
enumerate
(
mapping
):
if
n_and_mask
&
(
1
<<
i
):
result
|=
(
1
<<
b
)
x
=
(
n
&
~
mask
)
|
result
# convert x to adequate base
x_base
=
to_base
(
x
,
alphabet
)
padding
=
alphabet
[
0
]
*
(
min_length
-
len
(
x_base
))
return
'{}{}'
.
format
(
padding
,
x_base
)
def
to_base
(
number
,
alphabet
):
base
=
len
(
alphabet
)
number_base
=
''
while
number
>
base
:
quotient
,
remainder
=
divmod
(
number
,
base
)
number_base
=
alphabet
[
remainder
]
+
number_base
number
=
quotient
number_base
=
alphabet
[
number
]
+
number_base
return
number_base
'''
class MyException(Exception):
pass
'''
url_id
=
int
(
context
.
getId
())
config
=
context
.
Url_getReferenceGeneratorConfig
()
reference
=
encode
(
url_id
,
config
[
'ALPHABET'
],
config
[
'MAPPING'
],
config
[
'MASK'
],
config
[
'MIN_LENGTH'
])
context
.
setReference
(
reference
)
return
reference
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/URL_getReference.xml
0 → 100644
View file @
e328cbcd
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
URL_getReference
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_decode.py
0 → 100644
View file @
e328cbcd
def
from_base
(
representation
,
alphabet
):
base
=
len
(
alphabet
)
weights
=
enumerate
(
reversed
(
representation
))
return
sum
((
alphabet
.
index
(
c
)
*
(
base
**
i
)
for
i
,
c
in
weights
))
def
decode
(
representation
,
alphabet
,
mapping
,
mask
):
number
=
from_base
(
representation
,
alphabet
)
result
=
0
n_and_mask
=
number
&
mask
for
i
,
b
in
enumerate
(
mapping
):
if
n_and_mask
&
(
1
<<
b
):
result
|=
(
1
<<
i
)
x
=
(
number
&
~
mask
)
|
result
return
x
config
=
context
.
Url_getReferenceGeneratorConfig
()
decoded
=
decode
(
representation
,
config
[
'ALPHABET'
],
config
[
'MAPPING'
],
config
[
'MASK'
])
return
decoded
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_decode.xml
0 → 100644
View file @
e328cbcd
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
representation, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Url_decode
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_getReferenceGeneratorConfig.py
0 → 100644
View file @
e328cbcd
config
=
{}
config
[
'ALPHABET'
]
=
'P1DjUqRi2YVLr5Ke8gZwNTctlodkMSJOmzusQaxCnE43WyG7Bp9bFH06AhIfvX'
BLOCK_SIZE
=
24
config
[
'BLOCK_SIZE'
]
=
BLOCK_SIZE
config
[
'MASK'
]
=
(
1
<<
BLOCK_SIZE
)
-
1
config
[
'MAPPING'
]
=
range
(
BLOCK_SIZE
-
1
,
-
1
,
-
1
)
config
[
'MIN_LENGTH'
]
=
5
return
config
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_getReferenceGeneratorConfig.xml
0 → 100644
View file @
e328cbcd
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Url_getReferenceGeneratorConfig
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_getRelatedCurationRequestLines.py
View file @
e328cbcd
curation_request_lines_list
=
context
.
getAggregateRelatedValueList
()
curation_request_lines_list
=
context
.
getAggregateRelatedValueList
(
portal_type
=
'Curation Request Line'
)
return
curation_request_lines_list
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_viewAsUrl.xml
View file @
e328cbcd
...
...
@@ -88,13 +88,13 @@
<key>
<string>
left
</string>
</key>
<value>
<list>
<string>
my_reference
</string>
<string>
my_title
</string>
<string>
my_coordinate_text
</string>
<string>
your_modification_date
</string>
<string>
my_translated_validation_state_title
</string>
<string>
my_effective_date
</string>
<string>
my_language
</string>
<string>
my_reference
</string>
</list>
</value>
</item>
...
...
bt5/erp5_web_bookmark/SkinTemplateItem/portal_skins/erp5_url/Url_viewAsUrl/my_reference.xml
View file @
e328cbcd
...
...
@@ -10,7 +10,8 @@
<key>
<string>
delegated_list
</string>
</key>
<value>
<list>
<string>
title
</string>
<string>
default
</string>
<string>
editable
</string>
</list>
</value>
</item>
...
...
@@ -48,6 +49,16 @@
<key>
<string>
tales
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
editable
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
...
...
@@ -63,22 +74,39 @@
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
editable
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_
string_field
</string>
</value>
<value>
<string>
my_
view_mode_reference
</string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string>
Base_viewFieldLibrary
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Reference
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"TALESMethod"
module=
"Products.Formulator.TALESField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_text
</string>
</key>
<value>
<string>
python: context.URL_getReference()
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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