示例#1
0
文件: models.py 项目: relic7/nd1404
 def get_url(self, full_address = False):
     """
     Returns the component url (something like /storage/res_id.ext)
     """
     
     storage = Storage()
     url = None
     try:        
         file_name = self.uri
         if  storage.exists(file_name):
             url = os.path.join(STORAGE_SERVER_URL, file_name)
     
             if full_address:
                 url = SERVER_PUBLIC_ADDRESS + url
             
     except Exception, ex:
         logger.exception(ex)
         return url
示例#2
0
文件: models.py 项目: relic7/nd1404
def _get_resource_url(id):
    """
    Returns resource path
    """

    storage = Storage()

    if not id:
        return None

    try:
        
        if storage.exists(id):
            url = '/storage/' + id
        else:
            url = None
    except:
        url = None
    return url