librelist archives

« back to archive

Module routing beast

Module routing beast

From:
Faris Chebib
Date:
2010-11-10 @ 07:19
I seem to be hitting a wall with a circular import of some sort when I
tried to break my application down into modules.

Now I keep getting the error: "AttributeError: 'function' has no
attribute 'route'

The traceback cites line 121:
https://github.com/octaflop/synapse/blob/adminmodule/synapse/views/admin.py#L121

Which I find especially bizzare, considering the 'route' decorator is
used a number of times before that function.

For the record, the register module function is in __init__.py :
https://github.com/octaflop/synapse/blob/adminmodule/synapse/__init__.py#L12


Am I missing something in regards to how app-directories are configured?
Thanks for any insight.

Re: [flask] Module routing beast

From:
Hasan Ammar
Date:
2010-11-10 @ 07:51
You've redefined admin to point to a new function called admin.

admin = Module(__name__) <-- this is the flask module that has the
route function

def admin(): <-- this is the function that you've defined with the
same name that overrides the module.
    meta = Meta()
    user_form = RegistrationForm(request.form)
    text_post_form = TextPostForm(request.form)
    audio_post_form = AudioPostForm(request.form)
    image_post_form = ImagePostForm(request.form)
    site_post_form = SitePostForm(request.form)
    return dict(meta=meta,user_form=user_form,\
            text_post_form=text_post_form,\
            audio_post_form=audio_post_form,\
            image_post_form=image_post_form,\
            site_post_form=site_post_form)



On Wed, Nov 10, 2010 at 12:19 PM, Faris Chebib <octaflop@gmail.com> wrote:

> I seem to be hitting a wall with a circular import of some sort when I
> tried to break my application down into modules.
>
> Now I keep getting the error: "AttributeError: 'function' has no
> attribute 'route'
>
> The traceback cites line 121:
>
> https://github.com/octaflop/synapse/blob/adminmodule/synapse/views/admin.py#L121
>
> Which I find especially bizzare, considering the 'route' decorator is
> used a number of times before that function.
>
> For the record, the register module function is in __init__.py :
>
> https://github.com/octaflop/synapse/blob/adminmodule/synapse/__init__.py#L12
>
>
> Am I missing something in regards to how app-directories are configured?
> Thanks for any insight.
>

Re: [flask] Module routing beast

From:
Faris Chebib
Date:
2010-11-10 @ 08:06
wow! Thanks for the speedy response.

I'm still new at programming — thanks for catching that.

There are still quite a few problems with the code, but that
definitely got things going again.

~~~
Cognizing the tubes,
Faris Chebib

British Columbia: 778.230.9386
Utah: 801.930.8930

#198-7078 Inlet Dr.
Burnaby, BC V5A 1C1
Canada

7078 Holiday Dr.
Brigham City, Utah 84302



On 9 November 2010 23:51, Hasan Ammar <ammarh@gmail.com> wrote:
> You've redefined admin to point to a new function called admin.
>
> admin = Module(__name__) <-- this is the flask module that has the route
> function
>
>
> def admin(): <-- this is the function that you've defined with the same name
> that overrides the module.
>     meta = Meta()
>     user_form = RegistrationForm(request.form)
>     text_post_form = TextPostForm(request.form)
>     audio_post_form = AudioPostForm(request.form)
>     image_post_form = ImagePostForm(request.form)
>     site_post_form = SitePostForm(request.form)
>     return dict(meta=meta,user_form=user_form,\
>             text_post_form=text_post_form,\
>             audio_post_form=audio_post_form,\
>             image_post_form=image_post_form,\
>             site_post_form=site_post_form)
>
>
> On Wed, Nov 10, 2010 at 12:19 PM, Faris Chebib <octaflop@gmail.com> wrote:
>>
>> I seem to be hitting a wall with a circular import of some sort when I
>> tried to break my application down into modules.
>>
>> Now I keep getting the error: "AttributeError: 'function' has no
>> attribute 'route'
>>
>> The traceback cites line 121:
>>
>> 
https://github.com/octaflop/synapse/blob/adminmodule/synapse/views/admin.py#L121
>>
>> Which I find especially bizzare, considering the 'route' decorator is
>> used a number of times before that function.
>>
>> For the record, the register module function is in __init__.py :
>>
>> https://github.com/octaflop/synapse/blob/adminmodule/synapse/__init__.py#L12
>>
>>
>> Am I missing something in regards to how app-directories are configured?
>> Thanks for any insight.
>
>

Re: [flask] Module routing beast

From:
Hasan Ammar
Date:
2010-11-10 @ 08:22
You may be interested in integrating tools like pyflakes or pylint into your
development environment. These can help catch common errors such as
redefinition, unused variables and imports etc.

AFAIK, PyDev (python IDE built on eclipse) comes with pylint built in so
that would be a good starting point.

On Wed, Nov 10, 2010 at 1:06 PM, Faris Chebib <octaflop@gmail.com> wrote:

> wow! Thanks for the speedy response.
>
> I'm still new at programming — thanks for catching that.
>
> There are still quite a few problems with the code, but that
> definitely got things going again.
>
> ~~~
> Cognizing the tubes,
> Faris Chebib
>
> British Columbia: 778.230.9386
> Utah: 801.930.8930
>
> #198-7078 Inlet Dr.
> Burnaby, BC V5A 1C1
> Canada
>
> 7078 Holiday Dr.
> Brigham City, Utah 84302
>
>
>
> On 9 November 2010 23:51, Hasan Ammar <ammarh@gmail.com> wrote:
> > You've redefined admin to point to a new function called admin.
> >
> > admin = Module(__name__) <-- this is the flask module that has the route
> > function
> >
> >
> > def admin(): <-- this is the function that you've defined with the same
> name
> > that overrides the module.
> >     meta = Meta()
> >     user_form = RegistrationForm(request.form)
> >     text_post_form = TextPostForm(request.form)
> >     audio_post_form = AudioPostForm(request.form)
> >     image_post_form = ImagePostForm(request.form)
> >     site_post_form = SitePostForm(request.form)
> >     return dict(meta=meta,user_form=user_form,\
> >             text_post_form=text_post_form,\
> >             audio_post_form=audio_post_form,\
> >             image_post_form=image_post_form,\
> >             site_post_form=site_post_form)
> >
> >
> > On Wed, Nov 10, 2010 at 12:19 PM, Faris Chebib <octaflop@gmail.com>
> wrote:
> >>
> >> I seem to be hitting a wall with a circular import of some sort when I
> >> tried to break my application down into modules.
> >>
> >> Now I keep getting the error: "AttributeError: 'function' has no
> >> attribute 'route'
> >>
> >> The traceback cites line 121:
> >>
> >>
> https://github.com/octaflop/synapse/blob/adminmodule/synapse/views/admin.py#L121
> >>
> >> Which I find especially bizzare, considering the 'route' decorator is
> >> used a number of times before that function.
> >>
> >> For the record, the register module function is in __init__.py :
> >>
> >>
> https://github.com/octaflop/synapse/blob/adminmodule/synapse/__init__.py#L12
> >>
> >>
> >> Am I missing something in regards to how app-directories are configured?
> >> Thanks for any insight.
> >
> >
>

Re: [flask] Module routing beast

From:
Faris Chebib
Date:
2010-11-10 @ 08:29
Yeah, in the last stages of this app, vim just doesn't cut it.
However, I'm sure there's a pylint extension... yup:
http://www.vim.org/scripts/script.php?script_id=891

Thanks a bunch for the advice.

On 10 November 2010 00:22, Hasan Ammar <ammarh@gmail.com> wrote:
> You may be interested in integrating tools like pyflakes or pylint into your
> development environment. These can help catch common errors such as
> redefinition, unused variables and imports etc.
>
> AFAIK, PyDev (python IDE built on eclipse) comes with pylint built in so
> that would be a good starting point.
>
> On Wed, Nov 10, 2010 at 1:06 PM, Faris Chebib <octaflop@gmail.com> wrote:
>>
>> wow! Thanks for the speedy response.
>>
>> I'm still new at programming — thanks for catching that.
>>
>> There are still quite a few problems with the code, but that
>> definitely got things going again.
>>
>>
>>
>> On 9 November 2010 23:51, Hasan Ammar <ammarh@gmail.com> wrote:
>> > You've redefined admin to point to a new function called admin.
>> >
>> > admin = Module(__name__) <-- this is the flask module that has the route
>> > function
>> >
>> >
>> > def admin(): <-- this is the function that you've defined with the same
>> > name
>> > that overrides the module.
>> >     meta = Meta()
>> >     user_form = RegistrationForm(request.form)
>> >     text_post_form = TextPostForm(request.form)
>> >     audio_post_form = AudioPostForm(request.form)
>> >     image_post_form = ImagePostForm(request.form)
>> >     site_post_form = SitePostForm(request.form)
>> >     return dict(meta=meta,user_form=user_form,\
>> >             text_post_form=text_post_form,\
>> >             audio_post_form=audio_post_form,\
>> >             image_post_form=image_post_form,\
>> >             site_post_form=site_post_form)
>> >
>> >
>> > On Wed, Nov 10, 2010 at 12:19 PM, Faris Chebib <octaflop@gmail.com>
>> > wrote:
>> >>
>> >> I seem to be hitting a wall with a circular import of some sort when I
>> >> tried to break my application down into modules.
>> >>
>> >> Now I keep getting the error: "AttributeError: 'function' has no
>> >> attribute 'route'
>> >>
>> >> The traceback cites line 121:
>> >>
>> >>
>> >> 
https://github.com/octaflop/synapse/blob/adminmodule/synapse/views/admin.py#L121
>> >>
>> >> Which I find especially bizzare, considering the 'route' decorator is
>> >> used a number of times before that function.
>> >>
>> >> For the record, the register module function is in __init__.py :
>> >>
>> >>
>> >> https://github.com/octaflop/synapse/blob/adminmodule/synapse/__init__.py#L12
>> >>
>> >>
>> >> Am I missing something in regards to how app-directories are
>> >> configured?
>> >> Thanks for any insight.
>> >
>> >
>
>

Re: [flask] Module routing beast

From:
Dag Odenhall
Date:
2010-11-10 @ 12:16
On Wed, 2010-11-10 at 00:29 -0800, Faris Chebib wrote:
> Yeah, in the last stages of this app, vim just doesn't cut it.
> However, I'm sure there's a pylint extension... yup:
> http://www.vim.org/scripts/script.php?script_id=891
> 
> Thanks a bunch for the advice.

I have modified pyflakes.vim to work with latest pyflakes:

http://paste.pocoo.org/show/288789

Put in ~/.vim/ftplugin/python/pyflakes.vim and install pyflakes.