Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
insights
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
insights
Commits
a67ed840
Commit
a67ed840
authored
Apr 20, 2013
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
argspec munging works
parent
9af28bfa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
21 deletions
+41
-21
src/djanalytics/core/djobject.py
+41
-21
No files found.
src/djanalytics/core/djobject.py
View file @
a67ed840
...
@@ -8,10 +8,11 @@ a good way to make this clean, but the ugliness here will save a lot
...
@@ -8,10 +8,11 @@ a good way to make this clean, but the ugliness here will save a lot
of ugliness for the API caller.
of ugliness for the API caller.
'''
'''
import
decorator
import
inspect
import
json
import
requests
import
requests
import
urllib
import
urllib
import
json
import
decorator
schema
=
None
schema
=
None
...
@@ -93,6 +94,7 @@ class embed():
...
@@ -93,6 +94,7 @@ class embed():
raise
AttributeError
(
function
)
raise
AttributeError
(
function
)
category
=
rpcspec
[
'category'
]
category
=
rpcspec
[
'category'
]
# TODO: Category should be a list, not a string
def_params
=
category
.
replace
(
'+'
,
','
)
# Is this still needed?
def_params
=
category
.
replace
(
'+'
,
','
)
# Is this still needed?
if
def_params
:
if
def_params
:
call_params
=
","
.
join
([
"{p}={p}"
.
format
(
p
=
p
)
for
p
in
category
.
split
(
'+'
)])
call_params
=
","
.
join
([
"{p}={p}"
.
format
(
p
=
p
)
for
p
in
category
.
split
(
'+'
)])
...
@@ -128,7 +130,22 @@ class transform_embed:
...
@@ -128,7 +130,22 @@ class transform_embed:
for
arg
in
stripped_args
:
for
arg
in
stripped_args
:
args
[
arg
]
=
context
[
arg
]
args
[
arg
]
=
context
[
arg
]
return
function
(
**
args
)
return
function
(
**
args
)
## TODO: Update argspec
## TODO: Use common logic with
args
=
[
a
for
a
in
inspect
.
getargspec
(
function
)
.
args
if
a
not
in
stripped_args
]
if
args
:
def_params
=
","
.
join
(
args
)
call_params
=
","
.
join
([
"{p}={p}"
.
format
(
p
=
p
)
for
p
in
args
])
else
:
def_params
=
""
call_params
=
""
funcspec
=
"{name}({params})"
.
format
(
name
=
function
.
__name__
,
params
=
def_params
)
callspec
=
"return helper({params})"
.
format
(
params
=
call_params
)
return
decorator
.
FunctionMaker
.
create
(
funcspec
,
callspec
,
{
'helper'
:
new_helper
},
doc
=
function
.
__doc__
)
return
new_helper
return
new_helper
def
__getattr__
(
self
,
attr
):
def
__getattr__
(
self
,
attr
):
...
@@ -167,21 +184,24 @@ class djobject():
...
@@ -167,21 +184,24 @@ class djobject():
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
djo
=
djobject
(
baseurl
=
"http://127.0.0.1:8000/"
)
djo
=
djobject
(
baseurl
=
"http://127.0.0.1:8000/"
)
# print djo.query.djt_event_count()
if
False
:
# djanalytics
# print djo.query.djt_user_event_count(user = "bob")
print
djo
.
query
.
djt_event_count
()
# print djo.query.__dir__()
print
djo
.
query
.
djt_user_event_count
(
user
=
"bob"
)
print
djo
.
query
.
__dir__
()
transform_policy
=
{
'name'
:
'test'
,
'default'
:
'deny'
,
if
True
:
# edxanalytics
'policy'
:
{
'total_user_count'
:
'allow'
,
transform_policy
=
{
'name'
:
'test'
,
'user_count'
:
'allow'
,
'default'
:
'deny'
,
'dash'
:
'deny'
,
'policy'
:
{
'total_user_count'
:
'allow'
,
'page_count'
:
[
'user'
]
}
'user_count'
:
'allow'
,
}
'dash'
:
'deny'
,
'page_count'
:
[
'user'
]
}
context
=
{
'user'
:
'bob'
,
}
'course'
:
'6.002x'
}
context
=
{
'user'
:
'bob'
,
secure_view
=
transform_embed
(
transform_policy
,
context
,
djo
.
view
)
'course'
:
'6.002x'
}
print
secure_view
.
__dir__
()
print
secure_view
.
page_count
(
course
=
'6.002x'
)
secure_view
=
transform_embed
(
transform_policy
,
context
,
djo
.
view
)
print
secure_view
.
__dir__
()
print
secure_view
.
page_count
(
course
=
'6.002x'
)
print
inspect
.
getargspec
(
secure_view
.
page_count
)
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