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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
erp5
Commits
3fb5aaa2
Commit
3fb5aaa2
authored
May 06, 2019
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CUSTOM [erp5_tristan] add repr text editor
parent
d6ab6769
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
596 additions
and
0 deletions
+596
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Base_createBytesFromReprText.py
...portal_skins/erp5_tristan/Base_createBytesFromReprText.py
+22
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Base_createBytesFromReprText.xml
...ortal_skins/erp5_tristan/Base_createBytesFromReprText.xml
+62
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Base_createReprTextFromBytes.py
...portal_skins/erp5_tristan/Base_createReprTextFromBytes.py
+15
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Base_createReprTextFromBytes.xml
...ortal_skins/erp5_tristan/Base_createReprTextFromBytes.xml
+62
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_editReprTextFromDialog.py
...tal_skins/erp5_tristan/Document_editReprTextFromDialog.py
+21
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_editReprTextFromDialog.xml
...al_skins/erp5_tristan/Document_editReprTextFromDialog.xml
+62
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_viewReprEditor.xml
...tem/portal_skins/erp5_tristan/Document_viewReprEditor.xml
+133
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_viewReprEditor/your_property.xml
...ns/erp5_tristan/Document_viewReprEditor/your_property.xml
+89
-0
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_viewReprEditor/your_repr_text.xml
...s/erp5_tristan/Document_viewReprEditor/your_repr_text.xml
+130
-0
No files found.
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Base_createBytesFromReprText.py
0 → 100644
View file @
3fb5aaa2
import
re
def
replacer
(
match
):
if
match
.
group
(
1
):
return
chr
(
int
(
match
.
group
(
1
),
8
))
if
match
.
group
(
2
):
return
chr
(
int
(
match
.
group
(
2
),
16
))
return
({
"
\
n
"
:
""
,
"
\
\
"
:
"
\
\
"
,
"'"
:
"'"
,
'"'
:
'"'
,
"a"
:
"
\
a
"
,
"b"
:
"
\
b
"
,
"f"
:
"
\
f
"
,
"n"
:
"
\
n
"
,
"r"
:
"
\
r
"
,
"t"
:
"
\
t
"
,
"v"
:
"
\
v
"
,
}).
get
(
match
.
group
(
3
),
"
\
\
"
+
match
.
group
(
3
))
return
re
.
sub
(
r'''(?:\\([0-9]{1,3})|\\x([0-9a-fA-F]{2})|\\([\n\\'"abfnrtv]))'''
,
replacer
,
repr_text
)
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Base_createBytesFromReprText.xml
0 → 100644
View file @
3fb5aaa2
<?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>
repr_text
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_createBytesFromReprText
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Base_createReprTextFromBytes.py
0 → 100644
View file @
3fb5aaa2
s
=
""
for
c
in
bytes
:
byte
=
ord
(
c
)
if
(
byte
==
0x0A
):
s
+=
"
\
n
"
elif
(
byte
==
0x09
):
s
+=
"
\
\
t"
elif
(
byte
==
0x0D
):
s
+=
"
\
\
r"
elif
(
byte
==
0x08
):
s
+=
"
\
\
b"
elif
(
byte
==
0x0C
):
s
+=
"
\
\
f"
elif
(
byte
==
0x0B
):
s
+=
"
\
\
v"
#elif (byte == 0x22): s += "\\\""
elif
(
byte
==
0x5C
):
s
+=
"
\
\
\
\
"
elif
(
byte
<
0x10
):
s
+=
"
\
\
x0"
+
hex
(
byte
)[
2
:]
elif
(
byte
<
0x20
or
byte
>=
0x7F
):
s
+=
"
\
\
x"
+
hex
(
byte
)[
2
:]
else
:
s
+=
c
return
s
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Base_createReprTextFromBytes.xml
0 → 100644
View file @
3fb5aaa2
<?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>
bytes
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_createReprTextFromBytes
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_editReprTextFromDialog.py
0 → 100644
View file @
3fb5aaa2
"""
\
Document_editReprTextFromDialog(r"Hello
\
n
World", property="text_content", batch_mode=True)
"""
#if REQUEST is not None:
if
property
==
"invalid"
:
raise
ValueError
(
"invalid call"
)
# https://docs.python.org/2.0/ref/strings.html
data
=
context
.
Base_createBytesFromReprText
(
repr_text
)
if
use_set_property
:
context
.
setProperty
(
property
,
data
)
else
:
context
.
edit
(
**
{
property
:
data
})
if
batch_mode
:
return
None
return
context
.
Base_redirect
(
dialog_id
,
keep_items
=
{
"portal_status_message"
:
"Edited"
})
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_editReprTextFromDialog.xml
0 → 100644
View file @
3fb5aaa2
<?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>
repr_text, property="invalid", batch_mode=False, dialog_id="Document_viewReprEditor", use_set_property=False, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Document_editReprTextFromDialog
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_viewReprEditor.xml
0 → 100644
View file @
3fb5aaa2
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ERP5 Form"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
Document_editReprTextFromDialog
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
edit_order
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
encoding
</string>
</key>
<value>
<string>
UTF-8
</string>
</value>
</item>
<item>
<key>
<string>
enctype
</string>
</key>
<value>
<string>
multipart/form-data
</string>
</value>
</item>
<item>
<key>
<string>
group_list
</string>
</key>
<value>
<list>
<string>
left
</string>
<string>
right
</string>
<string>
center
</string>
<string>
bottom
</string>
<string>
hidden
</string>
</list>
</value>
</item>
<item>
<key>
<string>
groups
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
bottom
</string>
</key>
<value>
<list>
<string>
your_repr_text
</string>
</list>
</value>
</item>
<item>
<key>
<string>
center
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
hidden
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
left
</string>
</key>
<value>
<list>
<string>
your_property
</string>
</list>
</value>
</item>
<item>
<key>
<string>
right
</string>
</key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Document_viewReprEditor
</string>
</value>
</item>
<item>
<key>
<string>
method
</string>
</key>
<value>
<string>
POST
</string>
</value>
</item>
<item>
<key>
<string>
name
</string>
</key>
<value>
<string>
Document_viewReprEditor
</string>
</value>
</item>
<item>
<key>
<string>
pt
</string>
</key>
<value>
<string>
form_dialog
</string>
</value>
</item>
<item>
<key>
<string>
row_length
</string>
</key>
<value>
<int>
4
</int>
</value>
</item>
<item>
<key>
<string>
stored_encoding
</string>
</key>
<value>
<string>
UTF-8
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Edit as Repr
</string>
</value>
</item>
<item>
<key>
<string>
unicode_mode
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
update_action
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
update_action_title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_viewReprEditor/your_property.xml
0 → 100644
View file @
3fb5aaa2
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ProxyField"
module=
"Products.ERP5Form.ProxyField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
delegated_list
</string>
</key>
<value>
<list>
<string>
default
</string>
<string>
title
</string>
</list>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
your_property
</string>
</value>
</item>
<item>
<key>
<string>
message_values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
external_validator_failed
</string>
</key>
<value>
<string>
The input failed the external validator.
</string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
overrides
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
tales
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string>
text_content
</string>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_string_field
</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>
Property ID
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_tristan/SkinTemplateItem/portal_skins/erp5_tristan/Document_viewReprEditor/your_repr_text.xml
0 → 100644
View file @
3fb5aaa2
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ProxyField"
module=
"Products.ERP5Form.ProxyField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
delegated_list
</string>
</key>
<value>
<list>
<string>
default
</string>
<string>
extra
</string>
<string>
text_editor
</string>
<string>
whitespace_preserve
</string>
</list>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
your_repr_text
</string>
</value>
</item>
<item>
<key>
<string>
message_values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
external_validator_failed
</string>
</key>
<value>
<string>
The input failed the external validator.
</string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
overrides
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<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>
extra
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
text_editor
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
whitespace_preserve
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
extra
</string>
</key>
<value>
<string>
style="font-family: monospace; width: 100%; height: 75vh;"
</string>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_editor_field
</string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string>
Base_viewFieldLibrary
</string>
</value>
</item>
<item>
<key>
<string>
text_editor
</string>
</key>
<value>
<string>
text_area
</string>
</value>
</item>
<item>
<key>
<string>
whitespace_preserve
</string>
</key>
<value>
<int>
1
</int>
</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.Base_createReprTextFromBytes(context.getTextContent() or context.getData() or "")
</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