|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
A decoding problem with diangoHi, all
I have some decoding problem with
django. When I use specific class type and send it to server, it got http 500
error.
"RPC Fault faultString="error"
faultCode="Channel.Call.Failed" faultDetail="NetConnection.Call.Failed: HTTP:
Status 500"
When I use just Object or remove the alias
on Flex side, It works fine.
It only occurs during decoding. Because
object from server side to flex side can mapped exactly.
And if the object is not django model, it
also works fine both in decoding and encoding.
There's not any other log except the piece
above. I don't know how to config pyamf log. Any help would be
appreciated.
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
Re: A decoding problem with diangoHi Ivan,
If you add a logger instance to the gateway that will log the request/response and any exceptions that may occur. E.g.: import logging logging.basicConfig(level=logging.DEBUG) gw = WSGIGateway(services) gw.logger = logging Hope that helps. Cheers, Nick On 14 Sep 2009, at 14:52, Ivan Wang wrote:
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
|
|
|
Re: A decoding problem with diangoI made Blank and Null to true in my Model to allow my Flex VO's to be slack; meaning if no data... then no data. You still get into strange situations where a String is null vs. "", but makes it a ton easier to work with. If not, you spend a lot of data validation on your Flex side. This is ok if you have the time, but if not, Blank + Null to git-r-done.
On Tue, Sep 15, 2009 at 10:16 AM, Ivan Wang <ivan.wang2010@...> wrote: Hi, Nick _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
Re: A decoding problem with diangoOn 15 Sep 2009, at 15:16, Ivan Wang wrote:
> Hi, Nick > Thanks for your help, now I've found what's going on here. > I have a django model like: > > class Company(BaseModel): > ''' > Company definition. > ''' > name = models.CharField(max_length=200, unique=True) > phone = models.CharField(max_length=50, blank=True) > address = models.CharField(max_length=500, blank=True) > fax = models.CharField(max_length=50, blank=True) > zip = models.IntegerField(max_length=10, blank=True, null=True) > website = models.URLField(max_length=200, blank=True) > active = models.BooleanField(default=True) > city = models.ForeignKey(City, blank=True, null=True) > objects = ModelManager() > > def __unicode__(self): > return self.name > > And seems by default they are all static_attrs. So when I pass some > object from flex side that only contains a few attrs, it will throw > errors becasue static_attr is required. > Is this a bug or I can change it because there's no need to make all > the attrs static. This was intentional to force the Flex client to send a complete model instance. This 'feature' is run into time and again with lots of questions on stackoverflow and even workarounds being created like in Jesse's mail. I can see now that this functionality was a mistake and it makes sense to not require any static properties on models for all ORM's (Django, SQLAlchemy, GAE etc.) I think even the 'required' fields should not be required by PyAMF and let the relevant ORM handle attributes. What do you think? _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
|
|
|
Re: A decoding problem with diangoThe only concern I have is default values.
String default so null, which is fine. But int, uint, and Number are NaN... what would the data default to? It wouldn't be a huge deal, but Django doesn't really give you, at least in my n00b experience, fine grained detail over WHAT it was expecting for a value; the error is like totally unrelated, at least at first glance. There seems nothing wrong with Django requiring something for what it specifically is coded to require for... but that doesn't really make things very agile. If you could coerce it to the nearest default value, by default, that'd be smokin' hawt.
On Wed, Sep 16, 2009 at 9:04 AM, Ivan Wang <ivan.wang2010@...> wrote: Yes, there's no need to make amf decide which field should be required. _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
Re: A decoding problem with diangoI have done some quick investigation into defaults in Django models, for primitive types:
Given a model: class TestModel(models.Model): char = models.CharField(max_length=100) char_blank = models.CharField(max_length=100, blank=True) char_null = models.CharField(max_length=100, null=True) char_blank_null = models.CharField(max_length=100, null=True, blank=True) char_default = models.CharField(max_length=100, default='foo') char_default_blank = models.CharField(max_length=100, default='foo', blank=True) char_default_blank_null = models.CharField(max_length=100, default='foo', blank=True, null=True) boolean = models.BooleanField() boolean_blank = models.BooleanField(blank=True) boolean_default = models.BooleanField(default=False) boolean_default_blank = models.BooleanField(default=False, blank=True) null_boolean = models.NullBooleanField() null_boolean_blank = models.NullBooleanField(blank=True) null_boolean_default = models.NullBooleanField(default=False) null_boolean_default_blank = models.NullBooleanField(default=False, blank=True) integer = models.IntegerField() integer_blank = models.IntegerField(blank=True) integer_null = models.IntegerField(null=True) integer_blank_null = models.IntegerField(null=True, blank=True) integer_default = models.IntegerField(default=0) integer_default_blank = models.IntegerField(default=0, blank=True) integer_default_blank_null = models.IntegerField(default=0, blank=True, null=True) decimal = models.DecimalField(max_digits=5, decimal_places=2) decimal_blank = models.DecimalField(max_digits=5, decimal_places=2, blank=True) decimal_null = models.DecimalField(max_digits=5, decimal_places=2, null=True) decimal_blank_null = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True) decimal_default = models.DecimalField(max_digits=5, decimal_places=2, default=0.1) decimal_default_blank = models.DecimalField(max_digits=5, decimal_places=2, default=0.1, blank=True) decimal_default_blank_null = models.DecimalField(max_digits=5, decimal_places=2, default=0.1, blank=True, null=True) Creating an instance: x =TestModel() print x.__dict__ gives: {'boolean': False, 'boolean_blank': False, 'boolean_default': False, 'boolean_default_blank': False, 'char': '', 'char_blank': '', 'char_blank_null': None, 'char_default': u'foo', 'char_default_blank': u'foo', 'char_default_blank_null': u'foo', 'char_null': None, 'decimal': None, 'decimal_blank': None, 'decimal_blank_null': None, 'decimal_default': 0.10000000000000001, 'decimal_default_blank': 0.10000000000000001, 'decimal_default_blank_null': 0.10000000000000001, 'decimal_null': None, 'id': None, 'integer': None, 'integer_blank': None, 'integer_blank_null': None, 'integer_default': 0, 'integer_default_blank': 0, 'integer_default_blank_null': 0, 'integer_null': None, 'null_boolean': None, 'null_boolean_blank': None, 'null_boolean_default': False, 'null_boolean_default_blank': False} Which is what PyAMF is going to use to encode the instance. It all looks pretty sane to me. It appears that AS3 (correct me if I'm wrong) that uint/int/Number will support 'undefined' so the Django ORM adapter would have to check for 'None' and convert accordingly. Is this sensible? Not sure if there are any other cases to check for? Cheers, Nick On 16 Sep 2009, at 14:25, Jesse Warden wrote: The only concern I have is default values. _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
| Free embeddable forum powered by Nabble | Forum Help |