Exemplo n.º 1
0
 def get_db_prep_value(self, value, *a, **kw):
     if value is None:
         url = None
     elif isinstance(value, basestring):
         url = to_slumber_scheme(value, get_slumber_services())
     else:
         url = to_slumber_scheme(value._url, get_slumber_services())
     return super(RemoteForeignKey, self).get_db_prep_value(url, *a, **kw)
Exemplo n.º 2
0
 def get_db_prep_value(self, value, *a, **kw):
     if value is None:
         url = None
     elif isinstance(value, basestring):
         url = to_slumber_scheme(value, get_slumber_services())
     else:
         url = to_slumber_scheme(value._url, get_slumber_services())
     return super(RemoteForeignKey, self).get_db_prep_value(url, *a, **kw)
Exemplo n.º 3
0
 def test_ambiguous_prefix(self):
     translated = to_slumber_scheme(
         'http://www.example.com/slumber/testservice/Model/',
         dict(
             a='http://www.example.com/slumber/testservice/',
             testmodel='http://www.example.com/slumber/testservice/Model/'))
     self.assertEquals(translated, 'slumber://testmodel/')
Exemplo n.º 4
0
 def get_prep_value(self, value, *a, **kw):
     url = value
     if value is not None:
         if isinstance(value, basestring) or isinstance(value, DictObject):
             return value
         url = to_slumber_scheme(value._url, get_slumber_services())
     return super(RemoteForeignKey, self).get_prep_value(url, *a, **kw)
Exemplo n.º 5
0
 def render(self, name, value, attrs=None, choices=()):
     # we had to cast slumber field to string
     if value is not None:
         value = to_slumber_scheme(value._url, get_slumber_services())
     return super(RemoteSelect, self).render(name,
                                             value,
                                             attrs=attrs,
                                             choices=choices)
Exemplo n.º 6
0
 def test_ambiguous_prefix(self):
     translated = to_slumber_scheme(
         'http://www.example.com/slumber/testservice/Model/',
         dict(a='http://www.example.com/slumber/testservice/',
             testmodel='http://www.example.com/slumber/testservice/Model/'))
     self.assertEquals(translated, 'slumber://testmodel/')
Exemplo n.º 7
0
 def test_is_a_service(self):
     translated = to_slumber_scheme(
         'http://example.com/slumber/testservice/Model/',
         dict(testservice='http://example.com/slumber/testservice/'))
     self.assertEquals(translated,
         'slumber://testservice/Model/')
Exemplo n.º 8
0
 def test_not_a_service(self):
     translated = to_slumber_scheme(
         'http://example.org/slumber/',
         dict(testservice='http://example.com/slumber/testservice/'))
     self.assertEquals(translated,
         'http://example.org/slumber/')
Exemplo n.º 9
0
 def test_no_services_pass_url_unchanged(self):
     translated = to_slumber_scheme(
         'http://example.com/slumber/', None)
     self.assertEquals(translated,
         'http://example.com/slumber/')
Exemplo n.º 10
0
 def test_is_a_service(self):
     translated = to_slumber_scheme(
         'http://example.com/slumber/testservice/Model/',
         dict(testservice='http://example.com/slumber/testservice/'))
     self.assertEquals(translated, 'slumber://testservice/Model/')
Exemplo n.º 11
0
 def test_not_a_service(self):
     translated = to_slumber_scheme(
         'http://example.org/slumber/',
         dict(testservice='http://example.com/slumber/testservice/'))
     self.assertEquals(translated, 'http://example.org/slumber/')
Exemplo n.º 12
0
 def test_no_services_pass_url_unchanged(self):
     translated = to_slumber_scheme('http://example.com/slumber/', None)
     self.assertEquals(translated, 'http://example.com/slumber/')