Changeset 1450

Show
Ignore:
Timestamp:
27.02.2008 19:34:49 (3 months ago)
Author:
JensDiemer
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pylucid/PyLucid/install/update.py

    r1445 r1450  
    2121class Update2(BaseInstall): 
    2222    def view(self): 
    23         self._redirect_execute(self._update) 
     23        self._redirect_execute(self._update_markup) 
     24        self._redirect_execute(self._update_tables) 
    2425 
    2526        return self._simple_render( 
     
    2728        ) 
    2829 
    29     def _update(self): 
     30    def _update_markup(self): 
    3031        print "update markup...", 
    3132        # insert a new markup for html without TinyMCE 
     
    4243        for m in Markup.objects.all(): 
    4344            print "%5s - %s" % (m.id, m) 
     45 
     46    def _update_tables(self): 
     47        print "update database tables...", 
     48        try: 
     49            # FIXME: Can we use the ORM here? 
     50            cursor = connection.cursor() 
     51            cursor.execute("DROP TABLE PyLucid_pagesinternal;") 
     52        except Exception, e: 
     53            print "Error:", e 
     54        else: 
     55            print "OK" 
    4456 
    4557 
  • trunk/pylucid/PyLucid/models.py

    r1332 r1450  
    366366 
    367367 
    368 class PagesInternal(models.Model): 
    369     name = models.CharField(primary_key=True, max_length=150) 
    370     plugin = models.ForeignKey( 
    371         "Plugin", #to_field="id", 
    372         help_text="The associated plugin" 
    373     ) 
    374     markup = models.ForeignKey("Markup", 
    375         related_name="page_internal_markup", 
    376         help_text="the used markup language for this page" 
    377     ) 
    378  
    379     createtime = models.DateTimeField(auto_now_add=True) 
    380     lastupdatetime = models.DateTimeField(auto_now=True) 
    381     createby = models.ForeignKey( 
    382         User, related_name="page_internal_createby", 
    383         null=True, blank=True, 
    384     ) 
    385     lastupdateby = models.ForeignKey( 
    386         User, related_name="page_internal_lastupdateby", 
    387         null=True, blank=True, 
    388     ) 
    389  
    390     content_html = models.TextField() 
    391     content_js = models.TextField(blank=True) 
    392     content_css = models.TextField(blank=True) 
    393     description = models.TextField() 
    394  
    395     class Admin: 
    396         list_display = ("name", "description") 
    397         #ordering = ('plugin',"name") 
    398         list_filter = ("plugin",) 
    399         date_hierarchy = 'lastupdatetime' 
    400         search_fields = ["name", "content_html", "content_js", "content_css"] 
    401  
    402     def __unicode__(self): 
    403         return self.name 
     368#class PagesInternal(models.Model): 
     369#    # Obsolete! 
     370#    pass 
    404371 
    405372 
  • trunk/pylucid/PyLucid/plugins_internal/plugin_admin/plugin_admin.py

    r1303 r1450  
    2929from django.conf import settings 
    3030 
    31 from PyLucid.models import Plugin, PagesInternal 
     31from PyLucid.models import Plugin 
    3232from PyLucid.system.plugin_manager import get_plugin_list, get_plugin_config, \ 
    3333                                                                install_plugin 
     
    9595        active_plugins = [] 
    9696        deactive_plugins = [] 
    97         installed_plugins = Plugin.objects.all() 
     97        installed_plugins = Plugin.objects.all().order_by( 
     98            'package_name', 'plugin_name' 
     99        ) 
    98100        for plugin in installed_plugins: 
    99101            installed_names.append(plugin.plugin_name) 
     
    154156    # The real action methods 
    155157 
    156     def _get_internal_page_info(self, plugin_obj): 
    157         pages = PagesInternal.objects.filter(plugin=plugin_obj) 
    158         page_names = [page.name.split(".",1)[-1] for page in pages] 
    159         return pages, page_names 
    160  
    161158    def _install_plugin(self, plugin_name, package_name, active=False): 
    162159        """ 
     
    173170            raise ActionError(_("Error installing Plugin:"), e) 
    174171        else: 
    175             plugin = Plugin.objects.get(plugin_name=plugin_name) 
    176             pages, page_names = self._get_internal_page_info(plugin) 
    177             self.page_msg.green( 
    178                 _("Plugin '%s' and internal pages %s saved into" 
    179                 " the database.") % (plugin, page_names) 
     172            self.page_msg.green( 
     173                _("Plugin '%s' saved into the database.") % plugin_name 
    180174            ) 
    181175 
     
    189183                self.page_msg.red("Can't deinstall the plugin. It's locked.") 
    190184                return 
    191             pages, page_names = self._get_internal_page_info(plugin) 
    192             pages.delete() 
    193185            plugin.delete() 
    194186        except Exception, e: 
     
    198190        else: 
    199191            self.page_msg.green( 
    200                 _("Plugin '%s' and internal pages %s removed from the" 
    201                 " database.") % (plugin, page_names) 
     192                _("Plugin '%s' removed from the database.") % plugin 
    202193            ) 
    203194 
  • 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