Changeset 1839

Show
Ignore:
Timestamp:
11/03/08 17:48:10 (2 months ago)
Author:
rmarianski
Message:

check in additional attempt at using a property for the story type. The type does not yet stay match the actual story type across all add/edit workflows

Location:
siteapp/branches/story-type-as-attribute/opengeo/almanac
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • siteapp/branches/story-type-as-attribute/opengeo/almanac/content.py

    r1827 r1839  
    271271    grok.implements(IStory) 
    272272 
     273    def _get_type(self): 
     274        from utils import _media_type_scheme 
     275        for scheme, type, label in self.categories: 
     276            if scheme == _media_type_scheme: 
     277                if label == 'words': 
     278                    return 'text' 
     279                return label 
     280        return 'text' 
     281        raise ValueError('Could not find media type from categories: %s' % 
     282                         self.categories) 
     283 
     284    def _set_type(self, value): 
     285        assert value in ('text', 'image', 'video'), "Invalid story media type: '%s'" % value 
     286        from utils import _media_type_scheme 
     287        cats = [] 
     288        media_type_added = False 
     289        for scheme, type, label in self.categories: 
     290            if scheme == _media_type_scheme: 
     291                cats.append((scheme, type, value)) 
     292                media_type_added = True 
     293            else: 
     294                cats.append((scheme, type, label)) 
     295        if not media_type_added: 
     296            cats.append((_media_type_scheme, 'Story', value)) 
     297        self.categories = tuple(cats) 
     298 
     299    type = property(_get_type, _set_type) 
    273300 
    274301class Comment(BaseModel): 
     
    382409    @grok.action("Update") 
    383410    def update_obj(self, **data): 
     411        # XXX we lose the correct type for whatever reason 
     412        type = self.context.type 
    384413        self.applyData(self.context, **data) 
     414        self.context.type = type 
    385415        self.flash(u'Almanac updated') 
    386416        self.redirect(self.url(self.context)) 
  • siteapp/branches/story-type-as-attribute/opengeo/almanac/rest.txt

    r1837 r1839  
    3030    >>> request = testing.new_interaction('bob') 
    3131    >>> alm1, s1 = content_setup(app, request, data1, data2) 
    32     >>> s1.type = 'image' 
    33     >>> s1.photoid = '1234' 
    3432    >>> endInteraction() 
    3533 
     
    206204     ('http://xmlns.opengeo.org/almanac/atom#contenttype', 'Story', 'Story')) 
    207205 
    208     >>> story.type = 'text' 
    209  
    210206 
    211207Security 
  • siteapp/branches/story-type-as-attribute/opengeo/almanac/security.txt

    r1837 r1839  
    232232and should be able to delete the story of another:: 
    233233 
    234     >>> app['a1']['third-awesome-story.1'].type = 'text' 
    235234    >>> url = "http://localhost/++rest++app/our-app/a1/third-awesome-story.1" 
    236235    >>> response = http_call('DELETE', url, data=testing.entry1, handle_errors=True, **make_header('dude')) 
  • siteapp/branches/story-type-as-attribute/opengeo/almanac/smoketest.txt

    r1837 r1839  
    2020 
    2121    >>> a1, s1 = testing.setup_basic_content_fixture(app, request, data1, data2) 
    22     >>> s1.type = 'text' 
    2322    >>> endInteraction() 
    2423    >>> alm1 = a1