New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrameworkError When Reusing CementApp Object #415

Closed
akhilman opened this Issue Nov 29, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@akhilman
Contributor

akhilman commented Nov 29, 2016

I'm writing unittests and got hit by this behaviour:

from cement.core.foundation import CementApp


def pre_setup(app):

    app.extend('object', object)


class BugyApp(CementApp):

    class Meta:

        label = 'bugy'

        hooks = [
            ('pre_setup', pre_setup),
        ]


# in case of unittests app is provided by CementTestCase
app = BugyApp()

# first app initialisation
with app:

    print(app.object)

# re-initialisation to check state loading
with app:

    print(app.object)

Executing this code will raise:

<class 'object'>
Traceback (most recent call last):
  File "extend_fault.py", line 28, in <module>
    with app:
  File "/home/ildar/projects/slivoglot-1/cement/cement/core/foundation.py", line 1494, in __enter__
    self.setup()
  File "/home/ildar/projects/slivoglot-1/cement/cement/core/foundation.py", line 843, in setup
    for res in self.hook.run('pre_setup', self):
  File "/home/ildar/projects/slivoglot-1/cement/cement/core/hook.py", line 150, in run
    res = hook[2](*args, **kwargs)
  File "extend_fault.py", line 6, in pre_setup
    app.extend('object', object)
  File "/home/ildar/projects/slivoglot-1/cement/cement/core/foundation.py", line 793, in extend
    member_name)
cement.core.exc.FrameworkError: App member 'object' already exists!

Second app initialisation tries to extend already extended app with object member.

akhilman added a commit to akhilman/cement that referenced this issue Nov 29, 2016

Fix for datafolklabs#415. app.extend and reusing app
Removing all extended members from app during close()

derks added a commit that referenced this issue Nov 29, 2016

Merge pull request #416 from akhilman/bug/415
Fix for #415. app.extend and reusing app

@derks derks changed the title from app.extend and reusing app fault to FrameworkError When Reusing CementApp Object Nov 29, 2016

@derks derks self-assigned this Nov 29, 2016

@derks derks added this to the 2.12.0 Stable milestone Nov 29, 2016

@derks derks closed this Nov 29, 2016

@derks derks added 4 - Done and removed 2 - Working <= 5 labels Nov 29, 2016

@derks

This comment has been minimized.

Member

derks commented Nov 29, 2016

Thanks @akhilman!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment