【问题标题】:Unable to load apache server while loading external modules in a class在类中加载外部模块时无法加载 apache 服务器
【发布时间】:2012-07-09 01:54:14
【问题描述】:

这是我的 django 项目层次结构

project/
       apache/ django.wsgi
       project/ __init__.py, settings.py, urls.py ..
       pages/
             __init__.py
             widgets.py
             website_views.py
       services/
               __init__.py
               apis/
                    __init__.py
                    fparser.py
                    googleData.py
                    wp.py
                    ...
               wservice.py
       ...

所以,wservice.py 是一个类似于类的总结类,它位于 apis 模块的所有类之上。它甚至为它继承的所有类提供了一些通用功能。

wservice.py

import feedparser
from bs4 import BeautifulSoup

class WidgetService(FParser):
    def post_content_summary(self, post_number):   
        ....
        content_text = content_soup.get_text()

        ...

    def get_random_image(self, post_number):
        ...
        content_soup = BeautifulSoup(html_content)

        ...

FParser 类位于fparser.py

fparser.py中的方法就是这样使用上面的类的。

from services.wservice import WidgetService
def method1():
    obj = WidgetService()
    m1 = obj.foo1() # described in FParser class
    m2 = obj.foo2() # described in WidgetService class

我在pages/widgets.py 中使用这个 WidgetService()。所以,我发现,当我开始使用BeautifulSoup 时,apache 服务器没有加载。它甚至没有显示任何语法错误。

我什至没有在日志文件中看到任何错误。

可能出了什么问题???有趣的是,我在开发服务器heroku(gunicorn)中没有遇到过这种错误

【问题讨论】:

    标签: python django apache web-applications beautifulsoup


    【解决方案1】:

    这可能是 here 描述的 Cython 和 mod_wsgi 之间的交互,并在 Beautiful Soup 上下文 here 中进行了探索。这是an earlier question,与您的相似。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-04
      • 2018-07-12
      • 2017-06-06
      • 1970-01-01
      • 2017-02-22
      • 2017-02-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多