Deployment namespace question

View: New views
3 Messages — Rating Filter:   Alert me  

Deployment namespace question

by Polly Powledge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm preparing my jython app for deployment as a standalone jar. I've
been following the advice in
http://wiki.python.org/jython/JythonFaq/DistributingJythonScripts and
in http://jython.extreme.st/talk/talk.html and have a couple of
questions about the namespace.

I've built the jar and am using a __run__.py script at the root to
launch my app. If I put my app in Lib, the __run__.py can import my
classes and run them successfully.

But I'd like to put my stuff in a folder two levels down from Lib, i.e.:

 Lib/myrootdirectory/mysubdirectory/foo.py

If I'm reading http://jython.extreme.st/talk/talk.html, I should be
able to do this by putting empty __init__.py files in myrootdirectory
and in mysubdirectory. Then if I do:

  from myrootdirectory.mysubdiretctory import foo

I should be able to instantiate foo in my__run__.py

However my jar file begs to differ. :^)  It gives me a TypeError: call
of non-function ('module'). And if I dump out my local dictionary
after my " from myrootdirectory.mysubdiretctory import foo", it does
indeed have it typed as a module and not a class.

Does anybody know what I'm doing wrong?

Thanks in advance,

Polly Powledge

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: Deployment namespace question

by David Huebel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I assume you have a class foo defined in foo.py.  To Python, foo.py
defines a module named foo, and your class foo is defined inside
module foo.  The class and the module are different entities, both
named foo.  Try:

from myrootdirectory.mysubdirectory.foo import foo

Then the unqualified name "foo" will refer to the class, not the module.

-David

On Thu, Jun 12, 2008 at 8:54 PM, Polly Powledge <pollyp@...> wrote:

> Hi,
>
> I'm preparing my jython app for deployment as a standalone jar. I've
> been following the advice in
> http://wiki.python.org/jython/JythonFaq/DistributingJythonScripts and
> in http://jython.extreme.st/talk/talk.html and have a couple of
> questions about the namespace.
>
> I've built the jar and am using a __run__.py script at the root to
> launch my app. If I put my app in Lib, the __run__.py can import my
> classes and run them successfully.
>
> But I'd like to put my stuff in a folder two levels down from Lib, i.e.:
>
>  Lib/myrootdirectory/mysubdirectory/foo.py
>
> If I'm reading http://jython.extreme.st/talk/talk.html, I should be
> able to do this by putting empty __init__.py files in myrootdirectory
> and in mysubdirectory. Then if I do:
>
>  from myrootdirectory.mysubdiretctory import foo
>
> I should be able to instantiate foo in my__run__.py
>
> However my jar file begs to differ. :^)  It gives me a TypeError: call
> of non-function ('module'). And if I dump out my local dictionary
> after my " from myrootdirectory.mysubdiretctory import foo", it does
> indeed have it typed as a module and not a class.
>
> Does anybody know what I'm doing wrong?
>
> Thanks in advance,
>
> Polly Powledge
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

Re: Deployment namespace question

by Polly Powledge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David,

That worked like a charm! Thanks so much for your help.

Polly Powledge

On Thu, Jun 12, 2008 at 9:29 PM, David Huebel <davidhuebel@...> wrote:

> I assume you have a class foo defined in foo.py.  To Python, foo.py
> defines a module named foo, and your class foo is defined inside
> module foo.  The class and the module are different entities, both
> named foo.  Try:
>
> from myrootdirectory.mysubdirectory.foo import foo
>
> Then the unqualified name "foo" will refer to the class, not the module.
>
> -David
>
> On Thu, Jun 12, 2008 at 8:54 PM, Polly Powledge <pollyp@...> wrote:
>> Hi,
>>
>> I'm preparing my jython app for deployment as a standalone jar. I've
>> been following the advice in
>> http://wiki.python.org/jython/JythonFaq/DistributingJythonScripts and
>> in http://jython.extreme.st/talk/talk.html and have a couple of
>> questions about the namespace.
>>
>> I've built the jar and am using a __run__.py script at the root to
>> launch my app. If I put my app in Lib, the __run__.py can import my
>> classes and run them successfully.
>>
>> But I'd like to put my stuff in a folder two levels down from Lib, i.e.:
>>
>>  Lib/myrootdirectory/mysubdirectory/foo.py
>>
>> If I'm reading http://jython.extreme.st/talk/talk.html, I should be
>> able to do this by putting empty __init__.py files in myrootdirectory
>> and in mysubdirectory. Then if I do:
>>
>>  from myrootdirectory.mysubdiretctory import foo
>>
>> I should be able to instantiate foo in my__run__.py
>>
>> However my jar file begs to differ. :^)  It gives me a TypeError: call
>> of non-function ('module'). And if I dump out my local dictionary
>> after my " from myrootdirectory.mysubdiretctory import foo", it does
>> indeed have it typed as a module and not a class.
>>
>> Does anybody know what I'm doing wrong?
>>
>> Thanks in advance,
>>
>> Polly Powledge
>>
>> -------------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> _______________________________________________
>> Jython-users mailing list
>> Jython-users@...
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>
>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users
LightInTheBox - Buy quality products at wholesale price