Sprox 0.8.2 released

48 views
Skip to first unread message

Alessandro Molina

unread,
Jan 21, 2013, 4:42:36 PM1/21/13
to sprox, TurboGears .
Today Chris Perkins released the new version of Sprox, this is a minor release with some major improvements for people using Sprox and the TurboGears admin. Most notable change is initial support for SQLAlchemy 0.8, some bugs might still be around, but things seem to work correctly.

Other changes include:
 - Fix MultipleSelection validation with TW2 not working correctly (crash on safe_validate)
 - Fix broken Unicode validation for strings on TW1
 - Fix ming provider trying to cast already correctly casted datetimes
 - When available use the new ming.odm namespace instead of the old ming.orm
 - Fix fields being removed even when specified in add_fields

Stuart Zurcher

unread,
Feb 15, 2013, 3:35:02 PM2/15/13
to sp...@googlegroups.com, TurboGears .
Thanks for the great work you guys are doing.

I had an issue where SproxCheckBox would default to true rather than displaying what is in the data. I had to change the code in sprox.widgets.tw2widgets.widget.py.  Following is the change I made.



class SproxCheckBox(CheckBox):
    def prepare(self):
        super(SproxCheckBox, self).prepare()
    self.attrs['value'] = self.value
    if self.attrs['value'] == 'False':
        self.attrs.pop("checked", None)  #checkbox automatically checked if checked in self.attrs

Hopefully this will help someone...
 

Alessandro Molina

unread,
Feb 15, 2013, 3:51:06 PM2/15/13
to TurboGears ., sprox
Should have already been fixed, you can find more informations at https://bitbucket.org/percious/sprox/issue/41/sprox-with-ming-doesnt-work-with-bool and a work-around until the new release is done.

Thanks anyway for reporting this!


--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Stuart Zurcher

unread,
Feb 15, 2013, 3:53:09 PM2/15/13
to sp...@googlegroups.com, TurboGears .
Had to adjust the code in my previous reply.
The self.attrs['value'] = "true" needed to remain. Following is the working code:

class SproxCheckBox(CheckBox):
    def prepare(self):
        super(SproxCheckBox, self).prepare()
        self.attrs['value'] = 'True'
        if self.value == 'False':
           self.attrs.pop("checked", None)

Sorry for the confusion.

On Monday, January 21, 2013 3:42:36 PM UTC-6, Alessandro Molina wrote:

Stuart Zurcher

unread,
Feb 16, 2013, 1:52:51 PM2/16/13
to turbo...@googlegroups.com, sprox
You are correct in that ming had an issue with bool that was fixed in the update.  However, this was an issue with the class SproxCheckBox(CheckBox) always being checked when displayed rather than being checked or unchecked depending on the bool value in the database.  The checked attr was always being passed to the checkbox widget so that the box was always checked when displayed.  Simply having "checked=" in the html causes the the box to be checked.  The code I added removes the "checked" attr if the self.value is false so that the checkbox is in agreement with the database.  It  may be better to check for this in tw2.form.widgets.widgets.py  class CheckBox.

The "value" attr needs to remain "true' at all times so that when the box is checked and the form is submitted, 'true' is passed as a value. If the box is not checked, then '' is passed.   On submission, the controller then checks for a value and passes it to the database.

I am a newbie with Turbogears, so please feel free to correct and dirrect me.

Alessandro Molina

unread,
Feb 16, 2013, 4:37:44 PM2/16/13
to sprox
I'll double check this, but I was quite sure that the issue with checkboxes was related to the wrong validator being used, and so should have been fixed with the validator change happened to fix the ming bug.
Using the correct validator should make the chekbox receive True/False bool values instead of strings.

But I checked this a few weeks ago, so I might be missing something :D


--
You received this message because you are subscribed to the Google Groups "sprox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sprox+un...@googlegroups.com.
To post to this group, send email to sp...@googlegroups.com.
Visit this group at http://groups.google.com/group/sprox?hl=en.
Message has been deleted

Alessandro Molina

unread,
May 11, 2014, 6:28:09 PM5/11/14
to sprox
Just tested this right now with:

Ming==0.4.7
pymongo==2.6.3
sprox==0.9.3
tw2.core==2.2.1.1
tw2.forms==2.2.0.3

And it seems to work as expected with:

from ming import schema as s

class TestModel(MappedClass):
    class __mongometa__:
        session = DBSession
        name = 'test_model'

    _id = FieldProperty(s.ObjectId)
    name = FieldProperty(s.String)
    display_name = FieldProperty(s.String)
    active = FieldProperty(s.Bool)

Looks like the issue is FieldProperty(s.Bool) vs FieldProperty(bool), it is usually best to use Ming schemes when declaring properties, but both should behave equally. 
There should be some issue with validator detection when using bool in place of s.Bool.


On Fri, May 9, 2014 at 5:48 PM, Stuart Zurcher <stuart...@gmail.com> wrote:
I revisited this issue with the sprox update and am still having checkboxes checked when value is False using ming.
The reason appears to be that on line 441 in  tw2.forms.fields,  d.attrs['checked'] = checked or None still is passed with None when false, just having checked= in the html causes the checkbox to be checked.  In other-words, tw2.forms passes checked= no matter what the value is and causes the checkbox to be checked.

I still have to use the following in my code to make the checkboxes function correctly by removing the 'checked' attrs when false:

class CheckBox(SproxCheckBox):
    def prepare(self):
        super(SproxCheckBox, self).prepare()
        self.attrs['value'] = 'True'
        if self.value == 'False':
           self.attrs.pop("checked", None)
 
 class forms(CrudRestControllerConfig):

        class edit_form_type(EditableForm):
            __entity__ = Forms
            boolField = CheckBox
 
shortened model is:
 
class Forms(MappedClass):
    """model for form info"""
 
    class __mongometa__:
        session = DBSession
        name = 'forms'
 
    _id = FieldProperty(s.ObjectId)
    boolField = FieldProperty(bool)
 
Visit this group at http://groups.google.com/group/sprox.
For more options, visit https://groups.google.com/d/optout.

Alessandro Molina

unread,
May 13, 2014, 4:56:23 PM5/13/14
to sprox
This has been fixed on sprox repository, after some testing I'll release a 0.9.4 update which should work with FieldProperty(bool) too

Stuart Zurcher

unread,
May 13, 2014, 7:14:45 PM5/13/14
to sp...@googlegroups.com
Yes, I realized that s.Bool works while bool doesn't and deleted my post...but not quick enough. :)

 FYI,  The same is true with FieldProperty(int) compared to FieldProperty(s.Int).  The validation fails on Sprox with (int).

Stuart
Reply all
Reply to author
Forward
0 new messages