Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ramin Yaghoubzadeh Torky
ipaaca
Commits
5908d702
Commit
5908d702
authored
12 years ago
by
Ramin Yaghoubzadeh
Browse files
Options
Downloads
Patches
Plain Diff
Forced automatic conversion to UTF-8 in payload (python)
parent
b34cf917
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ipaacalib/python/build.properties
+1
-0
1 addition, 0 deletions
ipaacalib/python/build.properties
ipaacalib/python/src/ipaaca.py
+18
-5
18 additions, 5 deletions
ipaacalib/python/src/ipaaca.py
with
19 additions
and
5 deletions
ipaacalib/python/build.properties
+
1
−
0
View file @
5908d702
...
...
@@ -6,5 +6,6 @@ pyzip.excludes=
run.py
=
run.py
publish.resolver
=
soa.core.repository
dist.dir
=
../../dist
deps.dir
=
../../deps
extra.python.path
=
/vol/soa/opt64/python-spread/current/lib/python2.7/site-packages
This diff is collapsed.
Click to expand it.
ipaacalib/python/src/ipaaca.py
+
18
−
5
View file @
5908d702
...
...
@@ -55,14 +55,14 @@ def enum(*sequential, **named):
def
pack_typed_payload_item
(
protobuf_object
,
key
,
value
):
protobuf_object
.
key
=
str
(
key
)
protobuf_object
.
value
=
str
(
value
)
protobuf_object
.
key
=
key
protobuf_object
.
value
=
value
protobuf_object
.
type
=
'
str
'
# TODO: more types
def
unpack_typed_payload_item
(
protobuf_object
):
# TODO: more types
return
(
protobuf_object
.
key
,
str
(
protobuf_object
.
value
)
)
return
(
protobuf_object
.
key
,
protobuf_object
.
value
)
class
IpaacaLoggingHandler
(
logging
.
Handler
):
...
...
@@ -131,7 +131,14 @@ class IUNotFoundError(Exception):
class
Payload
(
dict
):
def
__init__
(
self
,
iu
,
writer_name
=
None
,
new_payload
=
None
,
omit_init_update_message
=
False
):
pl
=
{}
if
new_payload
is
None
else
new_payload
pl1
=
{}
if
new_payload
is
None
else
new_payload
pl
=
{}
for
k
,
v
in
pl1
.
items
():
if
type
(
k
)
==
str
:
k
=
unicode
(
k
,
'
utf8
'
)
if
type
(
v
)
==
str
:
v
=
unicode
(
v
,
'
utf8
'
)
pl
[
k
]
=
v
self
.
iu
=
iu
# NOTE omit_init_update_message is necessary to prevent checking for
# exceptions and sending updates in the case where we just receive
...
...
@@ -141,9 +148,15 @@ class Payload(dict):
for
k
,
v
in
pl
.
items
():
dict
.
__setitem__
(
self
,
k
,
v
)
def
__setitem__
(
self
,
k
,
v
,
writer_name
=
None
):
if
type
(
k
)
==
str
:
k
=
unicode
(
k
,
'
utf8
'
)
if
type
(
v
)
==
str
:
v
=
unicode
(
v
,
'
utf8
'
)
self
.
iu
.
_modify_payload
(
is_delta
=
True
,
new_items
=
{
k
:
v
},
keys_to_remove
=
[],
writer_name
=
writer_name
)
result
=
dict
.
__setitem__
(
self
,
k
,
v
)
def
__delitem__
(
self
,
k
,
writer_name
=
None
):
if
type
(
k
)
==
str
:
k
=
unicode
(
k
,
'
utf8
'
)
self
.
iu
.
_modify_payload
(
is_delta
=
True
,
new_items
=
{},
keys_to_remove
=
[
k
],
writer_name
=
writer_name
)
result
=
dict
.
__delitem__
(
self
,
k
)
def
_remotely_enforced_setitem
(
self
,
k
,
v
):
...
...
@@ -179,7 +192,7 @@ class IUInterface(object): #{{{
self
.
_links
=
collections
.
defaultdict
(
set
)
def
__str__
(
self
):
s
=
str
(
self
.
__class__
)
+
"
{
"
s
=
unicode
(
self
.
__class__
)
+
"
{
"
s
+=
"
uid=
"
+
self
.
_uid
+
"
"
s
+=
"
(buffer=
"
+
(
self
.
buffer
.
unique_name
if
self
.
buffer
is
not
None
else
"
<None>
"
)
+
"
)
"
s
+=
"
owner_name=
"
+
(
"
<None>
"
if
self
.
owner_name
is
None
else
self
.
owner_name
)
+
"
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment