Show
Ignore:
Timestamp:
02/27/08 19:34:49 (9 months ago)
Author:
JensDiemer
Message:

-remove all "internal page" stuff.
-add in the _install section update: DROP TABLE PyLucid_pagesinternal.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/system/plugin_manager.py

    r1447 r1450  
    3636 
    3737from PyLucid.system.exceptions import * 
    38 from PyLucid.models import Plugin, Markup, PagesInternal 
     38from PyLucid.models import Plugin, Markup 
    3939 
    4040def _import(request, from_name, object_name): 
     
    229229 
    230230 
    231 def get_internalpage_files(package_name, plugin_name, internal_page_name): 
    232     """ 
    233     read html, js, css files for the internal page. 
    234     If there exist no file, it returns "". 
    235     """ 
    236     basepath = os.path.join( 
    237         package_name.replace(".",os.sep), plugin_name, "internal_pages", 
    238         internal_page_name, 
    239     ) 
    240     def read_file(ext): 
    241         try: 
    242             f = file(basepath + ext, "r") 
    243             content = f.read() 
    244             f.close() 
    245         except IOError, e: 
    246             return "" 
    247         else: 
    248             return content 
    249  
    250     html = read_file(".html") 
    251     js = read_file(".js") 
    252     css = read_file(".css") 
    253  
    254     return html, js, css 
    255  
    256  
    257 def install_internalpage(plugin, package_name, plugin_name, plugin_config, 
    258                                                                 extra_verbose): 
    259     """ 
    260     install all internal pages for the given plugin. 
    261  
    262     TODO: Befor create: check if page is in db 
    263     """ 
    264 #    try: 
    265 #        internal_page = PagesInternal.objects.get(name = internal_page_name) 
    266 #    except PagesInternal.DoesNotExist, e: 
    267  
    268     try: 
    269         plugin_manager_data = plugin_config.plugin_manager_data 
    270     except AttributeError: 
    271         # The old way? 
    272         try: 
    273             plugin_manager_data = plugin_config.module_manager_data 
    274         except AttributeError, e: 
    275             msg = ( 
    276                 "Can't get 'plugin_manager_data' from %s.%s" 
    277                 " (Also old 'module_manager_data' not there.)" 
    278                 " Org.Error: %s" 
    279             ) % (package_name, plugin_name, e) 
    280             raise AttributeError(msg) 
    281         print "*** DeprecationWarning: ***" 
    282         print " - You should rename module_manager_data to plugin_manager_data" 
    283         print 
    284  
    285     for method, cfg in plugin_manager_data.iteritems(): 
    286         if not "internal_page_info" in cfg: 
    287             # plugin method has no internal page 
    288             continue 
    289  
    290         internal_page_info = cfg["internal_page_info"] 
    291  
    292         # complete name: 
    293         internal_page_name = internal_page_info.get("name", method) 
    294  
    295         html, js, css = get_internalpage_files( 
    296             package_name, plugin_name, internal_page_name 
    297         ) 
    298  
    299         markup_name = internal_page_info.get("markup", None) 
    300         if markup_name == None: 
    301             markup_name = "None" 
    302         elif markup_name == "tinyTextile": 
    303             print "*** DeprecationWarning: ***" 
    304             print " - Markup name 'tinyTextile' was renamed to 'textile'!" 
    305             print " - Please correct the config entry." 
    306             markup_name = "textile" 
    307  
    308         markup = Markup.objects.get(name=markup_name) 
    309  
    310         template_engine = internal_page_info.get("template_engine", None) 
    311         if template_engine: 
    312             print "*** DeprecationWarning: ***" 
    313             print " - 'template_engine' key in internal_page_info is obsolete!" 
    314             print " - Only django template engine is supported!" 
    315             print 
    316  
    317         internal_page_name = ".".join([plugin_name, internal_page_name]) 
    318  
    319         # django bug work-a-round 
    320         # http://groups.google.com/group/django-developers/browse_thread/thread/e1ed7f81e54e724a 
    321         internal_page_name = internal_page_name.replace("_", " ") 
    322  
    323         if extra_verbose: 
    324             print "install internal page '%s'..." % internal_page_name, 
    325         internal_page = PagesInternal.objects.create( 
    326             name = internal_page_name, 
    327             plugin = plugin, # The associated plugin 
    328             markup = markup, 
    329  
    330             content_html = html, 
    331             content_js = js, 
    332             content_css = css, 
    333             description = internal_page_info['description'], 
    334         ) 
    335         if extra_verbose: 
    336             print "OK" 
    337231 
    338232def _install_plugin(package_name, plugin_name, plugin_config, active, 
     
    384278        package_name, plugin_name, plugin_config, active, extra_verbose 
    385279    ) 
    386     install_internalpage( 
    387         plugin, package_name, plugin_name, plugin_config, extra_verbose 
    388     ) 
    389280 
    390281