Show
Ignore:
Timestamp:
05/02/08 16:47:16 (23 months ago)
Author:
JensDiemer
Message:

update preferences:

  • move the preferences form from the plugin module into the plugin config modul
  • a plugin must not use try...except to get the preferences
  • update all modules around the plugin install/deinstall etc.
  • detect_page used the system_settings "index_page" value (setup a other default index page works!)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/plugins_internal/page_admin/page_admin.py

    r1547 r1551  
    4545from PyLucid.plugins_internal.page_style.page_style import replace_add_data 
    4646 
    47  
    48 class ParentChoiceField(forms.IntegerField): 
    49     def clean(self, parent_id): 
    50         """ 
    51         returns the parent page instance. 
    52         Note: 
    53             In PyLucid.models.Page.save() it would be checkt if the selected 
    54             parent page is logical valid. Here we check only, if the page with 
    55             the given ID exists. 
    56         """ 
    57         # let convert the string into a integer: 
    58         parent_id = super(ParentChoiceField, self).clean(parent_id) 
    59         assert isinstance(parent_id, int) 
    60  
    61         if parent_id == 0: 
    62             # assigned to the tree root. 
    63             return None 
    64  
    65         try: 
    66             #parent_id = 999999999 # Not exists test 
    67             page = Page.objects.get(id=parent_id) 
    68             return page 
    69         except Exception, msg: 
    70             raise ValidationError(_(u"Wrong parent POST data: %s" % msg)) 
    71  
    72  
    73 def get_parent_choices(): 
    74     """ 
    75     generate a verbose page name tree for the parent choice field. 
    76     """ 
    77     page_list = flat_tree_list() 
    78     choices = [(0, "---[root]---")] 
    79     for page in page_list: 
    80         choices.append((page["id"], page["level_name"])) 
    81     return choices 
     47from PyLucid.db.page import PageChoiceField, get_page_choices 
     48 
    8249 
    8350class EditPageForm(forms.Form): 
     
    9562    ) 
    9663 
    97     parent = ParentChoiceField( 
    98         widget=forms.Select(choices=get_parent_choices()), 
     64    parent = PageChoiceField( 
     65        widget=forms.Select(choices=get_page_choices()), 
    9966        # FIXME: How to set invalid_choice here? 
    10067        help_text="the higher-ranking father page",