as alluded by the subject, aliasing a package appears to work, but the
__path__ attribute is missing and thus relative (and absolute) imports
fail with:
Traceback (most recent call last):
File "/path/to/package/types/type-salesforce-cases//__init__.py",
line 3, in <module>
from .application.instance import entry_point
ValueError: Attempted relative import in non-package
... and ...
Traceback (most recent call last):
File "/path/to/package/types/type-salesforce-cases//__init__.py",
line 1, in <module>
from Self.application.instance import entry_point
ImportError: No module named application.instance
... respectively. setting __path__ manually works fine, but that
sorta defeats the goal of a generic loader :-)
in this case, i am aliasing the "running" application package to
package `Self`, and also it's canonical name ... the running
application is actually an "instance" of an app template (type), and
potentially only one of N active instances ... it doesn't know it's
"real name" ahead of time, and i wanted to avoid
`sys.modules[__name__]` business.
absolute imports also fail (Self.package.module) for the same reason,
even though uWSGI originally imported the package by the aliased name
(module = Self) !
i can work around this a number of ways (and in all fairness, it
already *was* working several times -- this is experimental), but i
think uWSGI should set __path__ accordingly, and ... (anything else?)
...
hopefully this is enough context/config to make sense -- lmk if
anything else is needed, eg. a more comprehensive bug report.
thanks!
NOTE: ver 1.1.2
NOTE: very late, apologies if this whole message is, uhm, hard to
follow ... also just realized that uWSGI is only aliasing the FIRST
module specified in the config, others are dropped (i should probably
not alias the same module twice for *lots* of reasons, but it's
failing for *any* module after the first, not just dupes like this
example)
NOTE: virtualenv in use, all packages (including uWSGI) installed via pip.
UNRELATED: `inherit` works with %(placeholders), but `ini` does not
(from within a top-level INI)? expected?
command:
----------------------------------------------------------------
# uwsgi --set AppType=type-salesforce-cases --set AppName=Salesforce
--set AppRunContext=Debug --ini application.ini --show-config
[... see last section for output ...]
----------------------------------------------------------------
top-level INI entry point:
----------------------------------------------------------------
# grep -Ev '^$|^#' application.ini
[uwsgi]
master = true
processes = 2
http-socket = :8000
auto-procname = true
log-micros = true
BasePath = %d
AppPath = %(BasePath)%(AppType)/
AppPathStatic = %(AppPath)resources/static/
AppPathTemplates = %(AppPath)resources/templates/
AppPathVirtualenv = %(BasePath).%(AppType).%(AppName).vfs/
virtualenv = %(AppPathVirtualenv)
pymodule-alias = Self=%(AppPath)
pymodule-alias = %(AppName)=%(AppPath)
^^^^^ NOT in sys.modules if listed second
static-map = /static=%(BasePath)static/
module = Self
inherit = %(AppPath)application.ini
^^^^^ `ini` doesn't like placeholders (actual file is empty)
----------------------------------------------------------------
aliased package (relative import also fails):
----------------------------------------------------------------
# cat type-salesforce-cases/__init__.py
from Self.application.instance import entry_point
application = entry_point()
----------------------------------------------------------------
output (scrubbed by simple sed to protect the innocent):
----------------------------------------------------------------
[uWSGI] getting INI configuration from application.ini
[uwsgi-static] added mapping for /static => /path/to/package/types/static/
[uWSGI] getting INI configuration from
/path/to/package/types/type-salesforce-cases/application.ini
;uWSGI instance configuration
[uwsgi]
set = AppType=type-salesforce-cases
AppType = type-salesforce-cases
set = AppName=Salesforce
AppName = Salesforce
set = AppRunContext=Debug
AppRunContext = Debug
ini = application.ini
master = true
processes = 2
http-socket = :8000
auto-procname = true
log-micros = true
BasePath = /path/to/package/types/
AppPath = /path/to/package/types/type-salesforce-cases/
AppPathStatic = /path/to/package/types/type-salesforce-cases/resources/static/
AppPathTemplates =
/path/to/package/types/type-salesforce-cases/resources/templates/
AppPathVirtualenv =
/path/to/package/types/.type-salesforce-cases.Salesforce.vfs/
virtualenv = /path/to/package/types/.type-salesforce-cases.Salesforce.vfs/
pymodule-alias = Self=/path/to/package/types/type-salesforce-cases/
pymodule-alias = Salesforce=/path/to/package/types/type-salesforce-cases/
static-map = /static=/path/to/package/types/static/
module = Self
inherit = /path/to/package/types/type-salesforce-cases/application.ini
show-config = true
;end of configuration
*** Starting uWSGI 1.1.2 (64bit) on [Thu Mar 29 04:56:22 2012] ***
compiled with version: 4.7.0 on 29 March 2012 04:55:23
current working directory: /path/to/package/types
detected binary path:
/path/to/package/types/.type-salesforce-cases.Salesforce.vfs/bin/uwsgi
your memory page size is 4096 bytes
building mime-types dictionary from file /etc/mime.types...1017 entry found
detected max file descriptor number: 1024
lock engine: pthread mutexes
uwsgi socket 0 bound to TCP address :8000 fd 4
Python version: 2.7.2 (default, Jan 31 2012, 13:19:49) [GCC 4.6.2
20120120 (prerelease)]
Set PythonHome to /path/to/package/types/.type-salesforce-cases.Salesforce.vfs/
Python main interpreter initialized at 0x1f31ee0
your server socket listen backlog is limited to 100 connections
*** Operational MODE: preforking ***
Traceback (most recent call last):
File "/path/to/package/types/type-salesforce-cases//__init__.py",
line 1, in <module>
from Self.application.instance import entry_point
ImportError: No module named application.instance
----------------------------------------------------------------
... boo! mwa hahaha! night :-)
C Anthony
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi