marek, hi,
just a quick review of the work you're doing (which is really
appreciated!). nothing major - just some style issues. please keep
up the good work!
+def force_positional_arguments(f):
+ """decorator that checks if params are tuple containing only one
dict (indicating that on client side there was call
+ with positional arguments too - if so, pass values from dict as
keyword arguments to decorated function"""
79 chars per line limit, please
+def describe_fields(form, field_names_to_describe = []):
+ field_names_to_describe = field_names_to_describe or [bf.name for bf in for
+ return dict((bf.name, describe_field(bf)) for bf in form if bf.name in fiel
likewise, 79 chars per line limit. also, as a general rule, i'm not
in favour of the "for ... in ... if" syntax. i know it looks nice and
compact, but it results in overly-complex-looking statements.
for-loops are for-loops... but then they get modified whoops... it
breaks readability / expectations.
+ if len(args) == 1: # if calign code with keyword parameters
from django or some other code
79 chars per line please.
+ if isinstance(params, types.TupleType) and len(params) == 1
and isinstance(params[0], types.DictType):
ditto. use \s and indentation to bring the statements up to the same
point (but slightly indented beyond the "if" itself) i don't mind if
you put all the "ands" at the end of the line or the beginnings, but
if it's the beginnings please make sure that they all line up one
under the other.
+ #assert extra == None # we do not yet support GET requests,
something pyjams do not use anyways.
79 chars per line please.
+ return {'id': id, 'error': {"code": -2, "message":
str(e), "data": ""}}
+ else:
+ return {'id': id, 'error': {"message": "No such method",
"data": "", 'code': -1}}
and here.
+ "argument name stands for BoundField, see django.forms.BoundField
definition - it has interface to extract name from form's field"
and here.
+ if isinstance(res[fname], Promise): # force translation if
translatable name (can't serialize some proxy obj exception)
+ res[fname] = res[fname].title()
+ if field_type in ['ComboField', 'MultiValueField',
'SplitDateTimeField']:#TODO: (may work but look at it)
and here.
-def describe_fields(fields, field_names):
- res = {}
- if not field_names:
- field_names = fields.keys()
- for name in field_names:
- field = fields[name]
- res[name] = describe_field(field)
- return res
+def describe_fields(form, field_names_to_describe = []):
+ field_names_to_describe = field_names_to_describe or [bf.name for
bf in form] # by default describe all fields
+ return dict((bf.name, describe_field(bf)) for bf in form if
bf.name in field_names_to_describe)
please revert this.
from django.core.serializers import serialize
-import datetime
+import datetime #remove ?
from datetime import date
probably :)
+# return [dict_datetimeflatten(i) for i in serialize('python', l,
fields=fields)]
again - please don't use this "for" syntax.
commit 866bea9f45fde8842b1a9f471425fb86fa75ef11
Author: Marek Wawrzyczek <[email protected]>
Date: Sat Nov 12 05:16:37 2011 +0100
further work
this commit should have said "added new jsonservice and formmanager to
jsonformprocessor" or something like that.
commit 1391182cae33a282a8aa06d5f4378270d45fb00c
Author: Marek Wawrzyczek <[email protected]>
Date: Tue Nov 15 00:50:57 2011 +0100
.
this commit - apart from the comment being not very helpful - appears
to be multi-purpose, which is something that i'm keen to see being
avoided, as it's generally bad practice.
this part:
@@ -33,10 +50,10 @@ class JSONRPCService:
#TODO: add support for jsonrpc tag
#assert extra == None # we do not yet support GET requests, something p
data = simplejson.loads(request.raw_post_data)
- id, method, params = data["id"], data["method"], [request,] + data["par
+ id, method, params = data["id"], data["method"], data["params"]
if method in self.method_map:
try:
- result = self.method_map[method](*params)
+ result = self.method_map[method](request, *params)
return {'id': id, 'result': result}
should have been committed on its own, with a message saying "moving
request out of *params and adding it back in in a more optimal way" or
something meaningful. i thought for a moment that you'd introduced a
bug (by removing the request from the params). a commit message
explaining what was being done would have helped.
then a _second_ commit should have been done, on the decorator
function (love it, btw - should help people enormously), and
potentially even a third one for that writebr (even just as one line).
ok that's all.
l.