pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

does not remember field order #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. just create the file users.py:
------------------------------------------------
from sqlalchemy import Column, Integer, String

from meta import Base

class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    fullname = Column(String)
    password = Column(String)

    def __init__(self, name = None, fullname = None, password = None):
        self.name = name
        self.fullname = fullname
        self.password = password

    def __repr__(self):
        return "<User('%s','%s', '%s')>" % (self.name, self.fullname, self.password)
-----------------------------------
if i go to http://127.0.0.1:5000/admin/User
i get: 
<< Models  
Related types
Existing objects
Name
Fullname
Password
Edit
Delete
New object
 Create form

But if i do create form i get:

New object User 
Fullname  
Password  
Name  

In this order. As you can see, Name, that was the first field is the last one.  

What version of the product are you using? On what operating system?

SQLAlchemy 0.5.0rc4
FormAlchemy 1.1

Please provide any additional information below.

Original issue reported on code.google.com by vincenzo...@gmail.com on 30 Dec 2008 at 11:49

Attachments:

GoogleCodeExporter commented 9 years ago
I can't reproduce.  What does this do for you?

>>> list(fs.render_fields.itervalues())

I get

[AttributeField(name), AttributeField(fullname), AttributeField(password)]

which is the order the renderer will output them.

Original comment by jbel...@gmail.com on 31 Dec 2008 at 4:10

GoogleCodeExporter commented 9 years ago
In [10]: list(fs.render_fields)
Out[10]: ['name', 'fullname', 'password']

In [11]: list(fs.render_fields.intervalues)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/goshawk/Documents/Projects/FairPro/program/managecorp/managecom/<ipython
console> in <module>()

AttributeError: 'OrderedDict' object has no attribute 'intervalues'

In [12]:

But i still have the same issue... any idea?

Original comment by vincenzo...@gmail.com on 31 Dec 2008 at 10:23

GoogleCodeExporter commented 9 years ago
and:
In [9]: list(fs.render_fields.intervalues())
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/goshawk/Documents/Projects/FairPro/program/managecorp/managecom/<ipython
console> in <module>()

AttributeError: 'OrderedDict' object has no attribute 'intervalues'

Original comment by vincenzo...@gmail.com on 31 Dec 2008 at 10:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
itervalues*

Original comment by gael.pas...@gmail.com on 31 Dec 2008 at 10:29

GoogleCodeExporter commented 9 years ago
list(fs.render_fields.itervalues())
Out[4]: [AttributeField(name), AttributeField(fullname), 
AttributeField(password)]

But the order is still: Fullname Password Name as in the attached pic.

Original comment by vincenzo...@gmail.com on 31 Dec 2008 at 4:05

GoogleCodeExporter commented 9 years ago
Found the bug.  Fixed in r623.  Thanks for the report!

Verified that Table/mapper pairs will also sort attributes correctly in 0.5, 
btw.  
You don't have to use declarative style.  (But, it's nicer anyway. :)

Original comment by jbel...@gmail.com on 1 Jan 2009 at 6:22