Re: [BangPypers] Python doc using sphinx

2014-05-25 Thread Vineet Naik
Hi,

Basically there are 3 steps involved in this:

1. Write docstrings in your code using reStructuredText directives and
   field lists that are recognized by Sphinx. See an example here
   [1]. It's a good idea refer to docs of existing libs as Kracekumar
mentioned.

2. Enable the autodoc extension in `conf.py` of the Sphinx source
   project and add the path to the code to sys.path so that it's
   importable by Sphinx.

3. Add autodoc directives such as `.. automodule::`, `.. autoclass::`
   etc. in Sphinx source files wherever you want to include the docs
   for the code. See more[2]


Related: (Please don't mind the self promotion :-))

If you use emacs, check sphinx-doc.el[3] which is an emacs minor mode
that I am working on to generate the docstrings for Python functions and
methods from the formal parameters. See demo in the README on github.


[1]: http://sphinx-doc.org/domains.html#info-field-lists
[2]: http://sphinx-doc.org/ext/autodoc.html
[3]: https://github.com/naiquevin/sphinx-doc.el



On Sun, May 25, 2014 at 11:51 PM, kracekumar ramaraju 
kracethekingma...@gmail.com wrote:

 Take a look at existing third party library like requests:
 https://github.com/kennethreitz/requests/tree/master/docs


 On Sun, May 25, 2014 at 11:43 PM, Nitin Kumar nitin.n...@gmail.com
 wrote:

  I need to document python code under github repo with Sphinx for auto doc
  generation. Anyone got good tips  tricks, samples?
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 



 --

 *Thanks  RegardskracekumarTalk is cheap, show me the code -- Linus
 Torvaldshttp://kracekumar.com http://kracekumar.com*
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
~ Vineet
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] list question

2013-12-05 Thread Vineet Naik
Another way:

from collections import defaultdict

x = [['cat', 'NM123', 12], ['cat', 'NM234', 12], ['dog', 'NM56', 65]]
y = [['cat', 'NM123, NM234', 12], ['dog', 'NM56', 65]]

def f(acc, x):
acc[(x[0], x[2])] += [x[1]]
return acc

assert y == [[k[0], ', '.join(v), k[1]] for k, v in reduce(f, x,
defaultdict(list)).iteritems()]


On Thu, Dec 5, 2013 at 3:00 PM, Nitin Kumar nitin.n...@gmail.com wrote:

 long but this too works :)

  p=[]
  x=[['cat','NM123',12],['cat','NM234',12], ['dog', 'NM56',65]]
  import copy
  def fn(a,b):
 if len(a)==3 and a[0]==b[0] and a[-1]==b[-1] and a[1]!=b[1]:
 a.insert(-1,b[1])
 p.append(a)
 else:
 p.append(b)
 return p

  reduce(fn, copy.deepcopy(x))
 [['cat', 'NM123', 'NM234', 12], ['dog', 'NM56', 65]]
  p
 [['cat', 'NM123', 'NM234', 12], ['dog', 'NM56', 65]]
 
 
  x
 [['cat', 'NM123', 12], ['cat', 'NM234', 12], ['dog', 'NM56', 65]]
  'p is your y'

 Nitin K


 On Thu, Dec 5, 2013 at 1:55 PM, Vikram K vikthirtyf...@gmail.com wrote:

  Any suggestions on what i have to do to go from x to y?
 
   x = [['cat','NM123',12],['cat','NM234',12], ['dog', 'NM56',65]]
   x
  [['cat', 'NM123', 12], ['cat', 'NM234', 12], ['dog', 'NM56', 65]]
   y = []
   y = [['cat','NM123, NM234', 12], ['dog', 'NM56', 65]]
  
 
  Regards
  Vik
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] (no subject)

2013-09-25 Thread Vineet Naik
On Tue, Sep 24, 2013 at 6:19 PM, Dhananjay Nene dhananjay.n...@gmail.comwrote:

 On Tue, Sep 24, 2013 at 6:11 PM, Dhananjay Nene
 dhananjay.n...@gmail.com wrote:
  On Tue, Sep 24, 2013 at 6:04 PM, Dhananjay Nene
  dhananjay.n...@gmail.com wrote:
  On Tue, Sep 24, 2013 at 5:48 PM, Vineet Naik naik...@gmail.com wrote:
  Hi,
 
  On Tue, Sep 24, 2013 at 10:38 AM, bab mis bab...@outlook.com wrote:
 
  Hi ,Any XML parser which gives the same kind of data structure as yaml
  parser gives in python.  Tried with xmlmindom but ir's not of a proper
  datastrucure ,every time i need to read by element and create the
 dict.
 
 
  You can try xmltodict[1]. It also retains the node attributes and makes
  than accessible using the '@' prefix (See the example in README of the
 repo)
 
  [1]: https://github.com/martinblech/xmltodict
 
  Being curious I immediately took a look and tried the following :
 
  import xmltodict
 
  doc1 = xmltodict.parse(
  mydocument has=an attribute
and
  manyelements/many
  manymore elements/many
/and
plus a=complex
  element as well
/plus
  /mydocument
  )
 
  doc2 = xmltodict.parse(
  mydocument has=an attribute
and
  manymore elements/many
/and
plus a=complex
  element as well
/plus
  /mydocument
  )
  print(doc1['mydocument']['and'])
  print(doc2['mydocument']['and'])
 
  The output was :
  OrderedDict([(u'many', [u'elements', u'more elements'])])
  OrderedDict([(u'many', u'more elements')])
 
  The only difference is there is only one many node inside the and
  node in doc2. Do you see an issue here (at least I do). The output
  structure is a function of the cardinality of the inner nodes. Since
  it changes shape from a list of many to not a list of 1 but just 1
  element (throwing away the list). Which can make things rather
  unpredictable. Since you cannot predict upfront whether the existence
  of just one node inside a parent node is consistent with the xml
  schema or is just applicable in that particular instance.
 
  I do think the problem is tractable so long as one clearly documents
  the specific constraints which the underlying XML will satisfy,
  constraints which will allow transformations to lists or dicts safe.
  Trying to make it easy without clearly documenting the constraints
  could lead to violations of the principle of least surprise like
  above.
 


The README does mention that it's based on this spec[1] (or
rather a blog post) that has the assumptions. But it seems to be
missing a lot of documentation in general as well.

Out of curiosity I looked into the code to see if the author has left
any comments about this inconsistency (value type varying between lists
and unicode/OrderedDict). While there are no such comments, I found
that the `parse` function can take a keyword arg `dict_constructor`, so
any other dict-like structure can be used instead of OrderedDict.

for eg. to force every node to be inside a list irrespective of the
cardinality -

import xmltodict
from collections import defaultdict

doc2 = xmltodict.parse(
mydocument has=an attribute
  and
manymore elements/many
  /and
  plus a=complex
element as well
  /plus
/mydocument
, dict_constructor=lambda *a, **k: defaultdict(list))

 doc2
defaultdict(type 'list', {u'mydocument': [defaultdict(type 'list',
{u'and': [defaultdict(type 'list', {u'many': [u'more elements']})],
u'plus': [defaultdict(type 'list', {'#text': [u'element as well'], u'@a':
u'complex'})], u'@has': u'an attribute'})]})

 doc2['mydocument'][0]['and'][0]['many']
[u'more elements']

Of course, defaultdict would lead to the order of nodes being lost, but an
OrderedDefaultDict (never tried before :-)) might work.


   It gets even more interesting, eg. below
 
  doc3 = xmltodict.parse(
  mydocument has=an attribute
and
  manyelements/many
/and
plus a=complex
  element as well
/plus
and
  manymore elements/many
/and
  /mydocument
  )
 
  print(doc3['mydocument']['and'])
 
  leads to the output :
 
  [OrderedDict([(u'many', u'elements')]), OrderedDict([(u'many', u'more
  elements')])]
 
  Definitely not what would be naively expected.

 Correction:

 print(doc3['mydocument'])

 prints

 OrderedDict([(u'@has', u'an attribute'), (u'and',
 [OrderedDict([(u'many', u'elements')]), OrderedDict([(u'many', u'more
 elements')])]), (u'plus', OrderedDict([(u'@a', u'complex'), ('#text',
 u'element as well')]))])

 which just trashed the ordering of an and followed by a plus followed by
 an and.


This is a more serious problem particularly if the dict is required to be
serialized back to xml.

Thanks for pointing out these issues, I had missed them entirely :-)

[1]:
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html

- Vineet


 Dhananjay

 --

 --
 http://blog.dhananjaynene.com twitter: @dnene google plus

Re: [BangPypers] (no subject)

2013-09-25 Thread Vineet Naik
On Thu, Sep 26, 2013 at 8:58 AM, st...@lonetwin.net wrote:

 On 2013-09-25 17:21, Dhananjay Nene wrote:

 On Wed, Sep 25, 2013 at 7:09 PM, Vineet Naik naik...@gmail.com wrote:

 On Tue, Sep 24, 2013 at 6:19 PM, Dhananjay Nene 
 dhananjay.n...@gmail.com**wrote:

  On Tue, Sep 24, 2013 at 6:11 PM, Dhananjay Nene
 dhananjay.n...@gmail.com wrote:

 [..]


 which just trashed the ordering of an and followed by a plus followed by
 an and.


 This is a more serious problem particularly if the dict is required to be
 serialized back to xml.

 = = =
 TL;DR. Use domain rather than use cases for exploring data structures
 especially where they can cause a lot of change later. Semantic
 Consistency is important, don't treat it lightly. Impedance mismatch
 can be fragile. If feasible, stay away.
 = = =


 Nice one, Dhananjay ! Thanks for spelling out so clearly what feels
 instinctively like common sense at times and is just as easy (and
 seductive)
 to forget about, at others.


+1. Thanks for putting it so clearly.

- Vineet




 cheers,
 - steve

 [...snip...]

 __**_
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/**mailman/listinfo/bangpypershttps://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] (no subject)

2013-09-24 Thread Vineet Naik
Hi,

On Tue, Sep 24, 2013 at 10:38 AM, bab mis bab...@outlook.com wrote:

 Hi ,Any XML parser which gives the same kind of data structure as yaml
 parser gives in python.  Tried with xmlmindom but ir's not of a proper
 datastrucure ,every time i need to read by element and create the dict.


You can try xmltodict[1]. It also retains the node attributes and makes
than accessible using the '@' prefix (See the example in README of the repo)

[1]: https://github.com/martinblech/xmltodict


 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Do you pin your requirements.txt ?

2013-09-14 Thread Vineet Naik
I too have learnt the hard way how `--upgrade` can cause conflicts due
to the `pip freeze` flattening the dependency tree. What works for me
though is to keep requirements.txt completely out of picture when
upgrading packages ie. to upgrade manually and preferably do it one
package at a time as far as possible. Considering that upgrades don't
happen frequently (at least in projects I have worked on), it's not
much of a hassle. But yes, this requires a list of top level deps to
be maintained (or they may be found out by guessing and confirming at
the time of upgrading :-))

IMO, where pinning really helps is guaranteeing a stable environment at
any time.

One advantage of pinning requirements even if there are automated
tests is that if tests fail due to a breaking upgrade, it will be
easier to know which version to rollback to.

Another thing is, as per the deployment workflow we follow at my
workplace, everytime while deploying code to the server, fabric runs a
`pip install -r requirements.txt` remotely. Since requirements are
pinned, most of the time installation is skipped unless some package
has been upgraded locally. But in case they are not pinned, a buggy
upgrade could break production (there could be a better
approach for synchronizing dependencies across different environments
and I would be happy to know about it)


On Fri, Sep 13, 2013 at 1:06 PM, Saager Mhatre saager.mha...@gmail.comwrote:

 On Sep 13, 2013 9:19 AM, Dhananjay Nene dhananjay.n...@gmail.com
 wrote:
  [...]
  Given adequate test coverage to verify negative side effects of any
 transitive dependency version upgrades, pinning could be skipped imo.
 
  Dhananjay

 +1 for automated tests to cover relevant API contracts of dependencies.
 That's a great approach to decide when to pin.

 Thanks for pointing that out Dhananjay.

 - d
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Do you pin your requirements.txt ?

2013-09-12 Thread Vineet Naik
I always pin requirements. Here is a related article on the topic -
http://nvie.com/posts/pin-your-packages/


On Thu, Sep 12, 2013 at 5:45 PM, BibhasD m...@bibhas.in wrote:

 Quick googling suggests pinning = specifying versions.

 I do it. I think that makes more sense if you're depending on 3rd party
 packages.

 --
 Bibhas

 On Thursday 12 September 2013 05:41 PM, Baishampayan Ghose wrote:
  What do you mean by pin? ~BG
 
  On Thu, Sep 12, 2013 at 5:37 PM, Shabda Raaj sha...@agiliq.com
  wrote:
  Curious how many people are doing/not doing it.
 
  (We pin our requirements.txt).
 
  -- Thanks, Shabda
 
  Agiliq.com - Building Amazing Apps agiliq.com/blog/ |
  github.com/agiliq US: +13152854388 | IN: +919949997612 | Skype:
  shabda.raaj Our Android Apps
  https://play.google.com/store/apps/developer?id=Agiliq | Our iOS
  Apps https://itunes.apple.com/us/artist/agiliq/id407918088
  ___ BangPypers mailing
  list BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 
 
 


 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Vineet Naik
Command line json formatter
$ echo '{name: Bangpypers, location: Bangalore}' | python -m
json.tool


On Tue, Sep 10, 2013 at 3:28 PM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Me@Bibhas m...@bibhas.in writes:

  Don't know if I can call it a snippet, But this command on terminal -
 
  $ python -m SimpleHTTPServer 8080

 Similar but less well known.

 Command line ftp client (similar to ftp(1))
 python -m ftplib ftp.gnu.org

 Command line mail client (similar to mail(1)) but needs a local MTA
 running
 python -m smtplib

 Command line IMAP client (similar mutt -f imap://...)
 python -m imaplib -d5 nou...@imap.gmail.com

 Command line POP client
 python -m poplib pop.gmail.com

 There are probably others too.


 [...]


 --
 Cordially,
 Noufal
 http://nibrahim.net.in
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Vineet Naik
On Tue, Sep 10, 2013 at 4:16 PM, Saju M sajup...@gmail.com wrote:

 echo '{name: Bangpypers, location: Bangalore}' | python -m
 json.tool

 In this command, what is this json.tool ?

 I could not find tool in dir(json)

  import json
  dir(json)
 ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
 '__doc__', '__file__', '__name__', '__package__', '__path__',
 '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
 'dumps', 'encoder', 'load', 'loads', 'scanner']


It's a module by itself. Located at /usr/lib/python2.7/json/tool.py on my
machine




 Regards
 Saju Madhavan
 +91 09535134654


 On Tue, Sep 10, 2013 at 3:39 PM, Vineet Naik naik...@gmail.com wrote:

  Command line json formatter
  $ echo '{name: Bangpypers, location: Bangalore}' | python -m
  json.tool
 
 
  On Tue, Sep 10, 2013 at 3:28 PM, Noufal Ibrahim nou...@nibrahim.net.in
  wrote:
 
   Me@Bibhas m...@bibhas.in writes:
  
Don't know if I can call it a snippet, But this command on terminal -
   
$ python -m SimpleHTTPServer 8080
  
   Similar but less well known.
  
   Command line ftp client (similar to ftp(1))
   python -m ftplib ftp.gnu.org
  
   Command line mail client (similar to mail(1)) but needs a local MTA
   running
   python -m smtplib
  
   Command line IMAP client (similar mutt -f imap://...)
   python -m imaplib -d5 nou...@imap.gmail.com
  
   Command line POP client
   python -m poplib pop.gmail.com
  
   There are probably others too.
  
  
   [...]
  
  
   --
   Cordially,
   Noufal
   http://nibrahim.net.in
   ___
   BangPypers mailing list
   BangPypers@python.org
   https://mail.python.org/mailman/listinfo/bangpypers
  
 
 
 
  --
  Vineet Naik
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Vineet Naik
On Tue, Sep 10, 2013 at 4:48 PM, Saju M sajup...@gmail.com wrote:

 Hi,
 I have couple of doubts


 * How do you find json has module named tool ?.


 * Why dir(json) not showing tool ??

  import json
  dir(json)
 ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
 '__doc__', '__file__', '__name__', '__package__', '__path__',
 '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
 'dumps', 'encoder', 'load', 'loads', 'scanner']
 


 * How to list all modules of a package in python console ?.


 * Is this what you guys are using to check modules of a package ?.

 ls /usr/lib/python2.7/json/ | grep .py$
 decoder.py
 encoder.py
 __init__.py
 scanner.py
 tool.py


Don't know how to get all modules of a package as a list but if you just
need to refer to the package contents, then pydoc gives this info. eg. run,

$ pydoc json

and then search for the section titled PACKAGE CONTENTS and you can find
tool listed there along with the other modules in the package.



 Regards
 Saju Madhavan
 +91 09535134654


 On Tue, Sep 10, 2013 at 4:21 PM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:

  Saju M sajup...@gmail.com writes:
 
   echo '{name: Bangpypers, location: Bangalore}' | python -m
  json.tool
  
   In this command, what is this json.tool ?
  
   I could not find tool in dir(json)
  
   import json
   dir(json)
   ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
   '__doc__', '__file__', '__name__', '__package__', '__path__',
   '__version__', '_default_decoder', '_default_encoder', 'decoder',
 'dump',
   'dumps', 'encoder', 'load', 'loads', 'scanner']
 
  It needn't be.
   from json import tool
   tool.__file__
  '/usr/lib/python2.7/json/tool.pyc'
  
 
  json is a package and tool is one of the modules inside that.
 
  To get to this, I have a little shell function that I stole from Anand
  that has
  been super useful repeatedly.
 
  epy () {
  cmd=import $1 as a ; print a.__file__.endswith('.pyc') and
  a.__file__[:-1] or a.__file__
  file=$(/usr/bin/env python -c $cmd)
  echo $file
  emacsclient --no-wait $file
  }
 
  If you want to read the source for the json module, just do
 
  $ epy json
 
  and the json module is loaded into Emacs.
 
 
  [...]
 
 
  --
  Cordially,
  Noufal
  http://nibrahim.net.in
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Wake Up guys!

2012-12-24 Thread Vineet Naik

 [...]

whereas the other groups from Mumbai http://mumpy.org/wiki/**
 Upcoming_Events http://mumpy.org/wiki/Upcoming_Events [...] are super
 active.


I am from Mumbai and a part of the Mumpy group and I can certainly
say that the above statement is not true to the point of sounding funny.


On Tue, Dec 25, 2012 at 11:06 AM, Bibhas Ch Debnath m...@bibhas.in wrote:

 What exactly is BingoPypers?
 On Dec 25, 2012 9:53 AM, Senthil Kumaran sent...@uthcode.com wrote:

  And the subject of your email is not helpful.  I get grumpy if you wake
 me
  up in midst of my activity. :-)
  Welcome to the group!
  ___
  BangPypers mailing list
  BangPypers@python.org
  http://mail.python.org/mailman/listinfo/bangpypers
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Maintaining dev and prod env alike

2012-03-25 Thread Vineet Naik
I keep a file devsettings.py alongside settings.py and add environment
specific config in it.

Then inside settings.py, devsettings is imported and all those
settings are taken from there

devsettings.py is ignored by git but so that you don't lose any
settings and to make sharing of this file with other
contributors easy, maintain a file devsettings.py.sample which is
tracked by git.

Whenever a new setting is added in devsettings, it should also go into
the sample file.


On Sun, Mar 25, 2012 at 4:55 PM, kracethekingmaker
kracethekingma...@gmail.com wrote:
 hi

 Hi

  I am using git. I do dev in my localhost and prod env is my web
 server, I don't have test env. My issue is my model has db params, so
 param are different in both env, so every time I pull and change db
 param, I dont think so this is encouraged, though this has nothing to
 do with python, but most people out here must have faced similar
 situation, kindly let me know best practices.

 You should probably keep a -dev settings file which can override the
 server parameters (or vice versa). This shouldn be as small as possible
 and should be ignored by git.

 Mean config.py ignored by git and have sample_config.py bare bone skeleton?



 --
 Talk is cheap, show me the code -- Linus Torvalds
 Regards
 Kracekumar.R
 www.kracekumar.com

 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers



-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Heterogeneous forms in django formset

2012-03-13 Thread Vineet Naik
Just a guess, but do you want multiple form classes for saving a main
object and its related objects ? in that case, may be you are looking
for inline formsets
[https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-an-inline-formset-in-a-view]

Also, I have written a small jquery plugin
[https://github.com/kodeplay/augForm] for handling the adding/removing
of forms in a formset on the client side. It includes a django formset
helper which achieves this by manipulating the management form
associated with the formset using javascript.  Might be of your help..

Regards,
Vineet

On Tue, Mar 13, 2012 at 11:36 AM, Amit Sethi amit.pureene...@gmail.com wrote:
 Hi all , I have a certain problem with django forms that seems to me
 should definitely have a solution already written.

 I have a couple of different forms that are submitted in the same view
 something like  ...( Sorry just using pseudo code for now )..


    class Form1():
        #different attributes

    Class Form2()
        #different attributes




 `html`

    form 

     {{ 1-instance-Form1 }}

      {{ 2-instance-Form1 }}

    {{ 1-instance-Form2 }}
    {{ 2-instance-Form2 }}

    /form

 `/html`

 Apart from that I want to give the user the ability to add a form
 instance of one of the form classes available through jquery so the
 form might become
 `html`

    form 


         {{ 1-instance-Form1 }}

          {{ 2-instance-Form1 }}

        {{ 1-instance-Form2 }}
        {{ 2-instance-Form2 }}
        {{ 3-instance-Form2 }}

    /form

 `/html`

 Now while looking for a solution to handle such a problem I came
 accross the concept of django formset which as the documentation
 describes is a collection of instances of the same Form class. However
 as I can see formsets can have the ability to handle heterogenous
 forms as well:

 With some definitions changed


    class BaseHeterogenousFormSet(StrAndUnicode):

        def append(form):
        #add one more form to the formset

        def is_valid():
        #run is_valid for each of the forms in the formset

        def clean():
            #run the clean for each of the forms ...



 Is there something wrong with the way i am thinking about this problem
 ??   Is this a proper way a handle the problem that I am describing

 --
 A-M-I-T S|S
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers



-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] [pythonpune] Re: To use Pinax or just Django

2011-11-21 Thread Vineet Naik
On Mon, Nov 21, 2011 at 2:12 PM, Navin Kabra navin.ka...@gmail.com wrote:

 I have a different perspective. I think Django is a good choice, especially
 if you don't know what you want.


Yes, that's exactly my case. I don't really mind the framework choosing
stuff for me at least to start with. I am happy with Django's template
system and ORM so far.

But I understand Noufal's point. For a framework in a more familiar
language, I would prefer loosely coupled components too.

Thanks
-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] To use Pinax or just Django

2011-11-19 Thread Vineet Naik
Hi,

I am considering Pinax/Django for a new project. When I came across Pinax,
I initially liked it but after installing it locally and evaluating it for
the project's requirement, I feel that most of the apps that come with it
may not work for the project as they are, and would require some amount of
customization.

I am confused whether to use Pinax or just Django.

my main concerns about Pinax are -

1) It supports Django ver 1.xx whereas current stable Django is at 1.3 and
the apps are also not quite upto-date
2) Code for the ready apps lies inside the Pinax project and there is no
way to override their behaviour for a certain project only. ie. either the
code inside Pinax directory will have to be modified or the app will have
to be copied inside the project (and renamed to avoid conflict if I am not
wrong ?)
3) Modifying the default theme looks like some work

One thing in Pinax that would be helpful is the Group and Group Aware
Apps - [http://pinaxproject.com/docs/dev/groups/]

My experience with Django itself is very limited in the first place, never
having used it in production.
My background is mostly web development using PHP  Java, although I am
quite comfortable with writing python scripts  involving file system
operations, web scraping etc.

What do you suggest, Pinax or just Django ? Please share your experiences
with Pinax.

Thanks,
vineet

-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers