Changeset 1450
- Timestamp:
- 27.02.2008 19:34:49 (3 months ago)
- Files:
-
- trunk/pylucid/PyLucid/install/update.py (modified) (3 diffs)
- trunk/pylucid/PyLucid/models.py (modified) (1 diff)
- trunk/pylucid/PyLucid/plugins_internal/plugin_admin/plugin_admin.py (modified) (6 diffs)
- trunk/pylucid/PyLucid/system/plugin_manager.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pylucid/PyLucid/install/update.py
r1445 r1450 21 21 class Update2(BaseInstall): 22 22 def view(self): 23 self._redirect_execute(self._update) 23 self._redirect_execute(self._update_markup) 24 self._redirect_execute(self._update_tables) 24 25 25 26 return self._simple_render( … … 27 28 ) 28 29 29 def _update (self):30 def _update_markup(self): 30 31 print "update markup...", 31 32 # insert a new markup for html without TinyMCE … … 42 43 for m in Markup.objects.all(): 43 44 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" 44 56 45 57 trunk/pylucid/PyLucid/models.py
r1332 r1450 366 366 367 367 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 404 371 405 372 trunk/pylucid/PyLucid/plugins_internal/plugin_admin/plugin_admin.py
r1303 r1450 29 29 from django.conf import settings 30 30 31 from PyLucid.models import Plugin , PagesInternal31 from PyLucid.models import Plugin 32 32 from PyLucid.system.plugin_manager import get_plugin_list, get_plugin_config, \ 33 33 install_plugin … … 95 95 active_plugins = [] 96 96 deactive_plugins = [] 97 installed_plugins = Plugin.objects.all() 97 installed_plugins = Plugin.objects.all().order_by( 98 'package_name', 'plugin_name' 99 ) 98 100 for plugin in installed_plugins: 99 101 installed_names.append(plugin.plugin_name) … … 154 156 # The real action methods 155 157 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_names160 161 158 def _install_plugin(self, plugin_name, package_name, active=False): 162 159 """ … … 173 170 raise ActionError(_("Error installing Plugin:"), e) 174 171 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 180 174 ) 181 175 … … 189 183 self.page_msg.red("Can't deinstall the plugin. It's locked.") 190 184 return 191 pages, page_names = self._get_internal_page_info(plugin)192 pages.delete()193 185 plugin.delete() 194 186 except Exception, e: … … 198 190 else: 199 191 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 202 193 ) 203 194 trunk/pylucid/PyLucid/system/plugin_manager.py
r1447 r1450 36 36 37 37 from PyLucid.system.exceptions import * 38 from PyLucid.models import Plugin, Markup , PagesInternal38 from PyLucid.models import Plugin, Markup 39 39 40 40 def _import(request, from_name, object_name): … … 229 229 230 230 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 content249 250 html = read_file(".html")251 js = read_file(".js")252 css = read_file(".css")253 254 return html, js, css255 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 db263 """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_data270 except AttributeError:271 # The old way?272 try:273 plugin_manager_data = plugin_config.module_manager_data274 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 print284 285 for method, cfg in plugin_manager_data.iteritems():286 if not "internal_page_info" in cfg:287 # plugin method has no internal page288 continue289 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_name297 )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 print316 317 internal_page_name = ".".join([plugin_name, internal_page_name])318 319 # django bug work-a-round320 # http://groups.google.com/group/django-developers/browse_thread/thread/e1ed7f81e54e724a321 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 plugin328 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"337 231 338 232 def _install_plugin(package_name, plugin_name, plugin_config, active, … … 384 278 package_name, plugin_name, plugin_config, active, extra_verbose 385 279 ) 386 install_internalpage(387 plugin, package_name, plugin_name, plugin_config, extra_verbose388 )389 280 390 281
