Exemplo n.º 1
0
def run_example():
    cfg.CFG['demisauce.url'] = 'http://localhost:4951'
    cfg.CFG['demisauce.apikey'] = 'a95c21ee8e64cb5ff585b5f9b761b39d7cb9a202'
    # setup
    print '** Demisaucepy Service Example**'
    service = ServiceDefinition(
        method='service',
        format='xml',
        app='demisauce'
    )
    print 'service %s:%s get' % (service.app, service.method)
    client = ServiceClient(service=service)
    response = client.fetch_service(request='demisauce/comment')# service definition for demisauce services
    """{
    'name': 'Comment Html Service', 
    'url': '/comment', 
    'description': 'Comment html and form ', 
    'base_url': 'http://localhost:4950', 
    'authn': 'demisauce', 
    'key': 'comment', 
    'id': '2', 
    'elelmentText': ['Comment Html Service', 'http://localhost:4950', 'demisauce', '/comment', 'Comment html and form ']}
    """
    mod = response.model
    print mod.base_url
    print mod.name
    print mod.description
    print mod.authn
    if mod.url_format == 'None':
        print "dang!   'None!"
    else:
        print 'crap'
    client2 = ServiceClient(service=service,transport=GaeServiceTransport())
Exemplo n.º 2
0
 def get_service(self,service='views',format='view',data={}):
     self.service.format = format
     client = ServiceClient(service=self.service)
     client.extra_headers = self.extra_headers
     log.debug('about to fetch %s' % self.key())
     
     try:
         response = client.fetch_service(request=self.key())
     except Exception, e:
         log.error('Error on Service def get_service fetch? %s' % e)
Exemplo n.º 3
0
def service_view(service,resource,format='view',app='demisauce'):
    
    client = ServiceClient(service=ServiceDefinition(
        name=service,
        format=format,
        app_slug=app
    ))
    #client.extra_headers = self.extra_headers
    try:
        log.debug('service_view: about to fetch %s:%s  format=%s' % (service,resource,format))
        client.fetch_service(request=resource)
    except Exception, e:
        log.error('what the heck? %s' % e)
Exemplo n.º 4
0
 def test_xmlproc(self):
     """
     Test via xmlrpc
     """
     from demisaucepy import cfg
     from demisaucepy.cache import cache
     from demisaucepy import demisauce_ws, hash_email, ServiceClient, \
         ServiceDefinition, RetrievalError, args_substitute
     """{'wp_author': 'admin', 
         'userid': '1', 
         'excerpt': '', 
         'wp_page_parent_id': '0', 
         'mt_allow_comments': 1, 
         'text_more': '', 
         'custom_fields': [{'value': '1', 'id': '2', 'key': '_edit_last'}, {'value': '1232858127', 'id': '1', 'key': '_edit_lock'}], 
         'wp_author_id': '1', 
         'title': 'About', 
         'wp_password': '', 
         'wp_page_parent_title': '', 
         'page_id': '2', 
         'wp_slug': 'about', 'wp_page_order': '0', 
         'permaLink': 'http://192.168.0.106/blog/about/', 
         'description': 'This is an example of a <strong>WordPress</strong> page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.', 'dateCreated': <DateTime '20090124T12:02:32' at 143cda0>, 'wp_author_display_name': 'admin', 'link': 'http://192.168.0.106/blog/about/', 'page_status': 'publish', 'categories': ['Uncategorized'], 'wp_page_template': 'default', 'mt_allow_pings': 1, 'date_created_gmt': <DateTime '20090124T19:02:32' at 143cfa8>}
     
     """
     sd = ServiceDefinition(
             name='wordpress',
             app_slug='wordpress'
         )
     sd.isdefined = False
     sd.method_url = None
     #.service_registry = None
     #self.api_key = api_key
     #sd.base_url = "http://192.168.0.106/blog/xmlrpc.php"
     client = ServiceClient(service=sd)
     #client.extra_headers = self.extra_headers
     response = client.fetch_service(request="2",data={'blog_id':'1','user':'******','password':'******'})
     page = response.model[0]
     assert client.service.format == 'xmlrpc'
     assert page.wp_author == 'admin'
     assert page.wp_slug == 'about'