当前位置: 首页>>代码示例>>Python>>正文


Python Pages.save方法代码示例

本文整理汇总了Python中models.Pages.save方法的典型用法代码示例。如果您正苦于以下问题:Python Pages.save方法的具体用法?Python Pages.save怎么用?Python Pages.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Pages的用法示例。


在下文中一共展示了Pages.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cms_users_put

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def cms_users_put(request, recurso):
    print "CMS"   
    if request.method == 'GET':
        try:
            pages = Pages.objects.get(name=recurso)

             #Indicamos plantilla
            template = get_template("index.html")
            #Marcamos contexto:
            c = Context({'mensaje' : pages.page})
            renderizado = template.render(c)
            return HttpResponse(renderizado)

        except Pages.DoesNotExist:
            template = get_template("index.html")
            #Marcamos contexto:
            c = Context({'mensaje' : "Recurso no encontrado"})
            renderizado = template.render(c)
            return HttpResponseNotFound(renderizado)
    elif request.method == 'PUT':
 
        if  request.body.find('<body>') == -1:
            return HttpResponseNotFound("formato html erroneo</br>" +
                    "formato: <html><body>...texto...</body></html")


        lista = request.body.split('<body>')[1]
        to_save = lista.split('</body>')[0]

        p = Pages(name=recurso, page=to_save)
        p.save()
        return HttpResponse("<p>Pagina guardada: " + to_save +"</p>")
开发者ID:isolanilla,项目名称:X-Serv-CSS-Elaborado,代码行数:34,代码来源:views.py

示例2: index

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def index(request, pagina):
	if request.user.is_authenticated():
		respuesta = 'Hola ' + request.user.username + ' <a href="/logout">Logout</a>' + '<br/>'
	else:
		respuesta = 'Por favor, registrate ' + '<a href="/login">login</a>' + '<br/>'
	if request.method == 'GET':
		try:
			listado = Pages.objects.get(name=pagina)
		except Pages.DoesNotExist:
			respuesta += 'Lo sentimos, esta pagina no ha sido almacenada.'
			return HttpResponse(respuesta)
		respuesta += str(listado.page)
	elif request.method == 'PUT':
		if request.user.is_authenticated():
			try:
				listado = Pages.objects.get(name=pagina)
				respuesta += "Esta url ya ha sido incluida, introduzca otra nueva."
			except Pages.DoesNotExist:
				info = request.body
				p = Pages(name=pagina, page=info)
				p.save()
				respuesta += "La url se ha incluido con exito"	
		else:
			respuesta += 'Para poder incluir una pagina nueva debe de estar registrado. Por favor, registrese.'
	return HttpResponse(respuesta)
开发者ID:LuciaVima,项目名称:X-Serv-15.9-Django-CMS-Templates,代码行数:27,代码来源:views.py

示例3: contentapp

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def contentapp(request,resourceName):
    response = '<h1>Welcome to Contentapp</h1>'
    if request.method == "GET":
        try:
            content = Pages.objects.get(name=resourceName)
            return HttpResponse(response + content.page)
        except Pages.DoesNotExist:
            response += '<body> GET </body>'
            form = "<form action='' method='POST'>\n"
            form += "Page: <input type='text' name='name' value=''><br>\n"
            form += "Content page: <input type='text' name='page'><br>\n"
            form += "<input type='submit' value='enviar'>\n"
            form += "</form>\n"
            response += form
            return HttpResponse(response)
    elif request.method == "POST":
        response += '<body> POST </body>' 
        newPage = Pages(name=request.POST['name'], page=request.POST['page'])
        newPage.save()
        response += "--Page: " + request.POST['name'] 
        response += ", Content Page: " + request.POST['page']
        return HttpResponse(response)
    elif request.method == "PUT":
        response += '<body> PUT </body>'
        (namePage, Page) = request.body.split(';')
        newPage = Page(name=namePage, page=Page)
        newPage.save()
        response += "--Page: " + request.POST['name'] 
        response += ", Content Page: " + request.POST['page']
        return HttpResponse(response)
    else:
        response += '<body> Fucking else </body>'
        return HttpResponse(response)
开发者ID:SGjorge,项目名称:X-Serv-15.6-Django-CMS_PUT,代码行数:35,代码来源:views.py

示例4: getpage

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def getpage(request,resourceName):
	if request.method == "GET":
		try:
			content = Pages.objects.get(name=resourceName)
			return content.page
		except Pages.DoesNotExist:
			response = '<body> GET </body>'
			response += getform()
			return response
	elif request.method == "POST":
		response = '<body> POST </body>' 
		newPage = Pages(name=request.POST['name'], page=request.POST['page'])
		newPage.save()
		response += "--Page: " + request.POST['name'] 
		response += ", Content Page: " + request.POST['page']
		return response
	elif request.method == "PUT":
		response = '<body> PUT </body>'
		(namePage, Page) = request.body.split(';')
		newPage = Page(name=namePage, page=Page)
		newPage.save()
		response += "--Page: " + request.POST['name'] 
		response += ", Content Page: " + request.POST['page']
		return response
	else:
		response = '<body> you do DELETE </body>'
		return response
开发者ID:SGjorge,项目名称:X-Serv-15.9-Django-CMS-Templates,代码行数:29,代码来源:views.py

示例5: cms_annotated

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def cms_annotated(request, recurso):
    if request.user.is_authenticated():
        estado = ("Eres " + request.user.username + "Logout")
    else:
        estado = ("No estas registrado. " + "Haz login")

    if request.method == 'GET':
        try:
            page = Pages.objects.get(name=recurso)
            salida = (page.page)
        except Pages.DoesNotExist:
            salida = "Recurso no encontrado"

    elif request.method == 'PUT':
        if request.user.is_authenticated():
            pagina = Pages(name=recurso, page=request.body)
            pagina.save()
            salida = ("Pagina guardada: " + request.body)
        else:
            salida = ("No se puede añadir pagina ")
    else:
        salida = "No esta disponible el metodo"

    # plantilla
    template = get_template("index.html")
    # contexto
    c = Context({'mensaje': salida, 'loggin': estado})
    renderizar = template.render(c)

    return HttpResponse(renderizar)
开发者ID:arubiopa,项目名称:X-Serv-15.9-Django-CMS-Templates,代码行数:32,代码来源:views.py

示例6: name_to_page

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def name_to_page(request, recurso):
    http_Auth = administracion(request)
    metodo = request.method
    if metodo == "GET":
        try:
            elementos = Pages.objects.get(name=recurso)
            http_Resp = elementos.page
        except Pages.DoesNotExist:
            http_Error = "<h3><font color='red'>Error! No existe dicho recurso " +\
                        " en el modelo Pages!</font></h3>"
    elif metodo == "PUT":
        autentificacion = request.user.is_authenticated()
        if autentificacion == True:
            try:
                elementos = Pages.objects.get(name=recurso)
                http_Error = "Cuidado! Este recurso ya esta en la base de datos!"
            except Pages.DoesNotExist:
                cuerpo = request.body
                new_page = Pages(name=recurso, page=cuerpo)
                new_page.save()
                http_Resp = "<p>Se ha introducido el recurso " + recurso +\
                            " en la base de datos.</p>" +\
                            "<p>Accede a la lista de a traves de /pages</p>"
        else:
            http_Error = "Error! No puedes cambiar el contenido de la pagina. " + \
                        "Solo usuarios que esten autentificados"
    else:
        http_Error = "<h3><font color='red'>Error! Metodo no valido. Solo " +\
                        "GET o PUT</font></h3>"

    try:
        return HttpResponse(http_Auth + http_Resp)
    except UnboundLocalError:
        return HttpResponse(http_Error)
开发者ID:jgalanb,项目名称:X-Serv-15.9-Django-CMS-Templates,代码行数:36,代码来源:views.py

示例7: name_to_page

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def name_to_page(request, recurso):
    metodo = request.method
    if metodo == "GET":
        try:
            elementos = Pages.objects.get(name=recurso)
            http_Resp = elementos.page
        except Pages.DoesNotExist:
            http_Error = "<h3><font color='red'>Error! El recurso introducido no " +\
                        "corresponde con ningun elemento de la tabla!</font></h3>"
    elif metodo == "PUT":
        try:
            elementos = Pages.objects.get(name=recurso)
            http_Error = "Cuidado! Este recurso ya esta en la base de datos!"
        except Pages.DoesNotExist:
            cuerpo = request.body
            new_page = Pages(name=recurso, page=cuerpo)
            new_page.save()
            http_Resp = "<p>Se ha introducido el recurso " + recurso +\
                        " en la base de datos.</p>" +\
                        "<p>Accede a la lista de a traves de /pages</p>"
    else:
        http_Error = "<h3><font color='red'>Error! Metodo no valido</font></h3>"

    try:
        html_Barrapunto = obtener_titulares()
        return HttpResponse(http_Resp + html_Barrapunto)
    except UnboundLocalError:
        return HttpResponse(http_Error)
开发者ID:jgalanb,项目名称:X-Serv-XML-ContentApp-Barrapunto,代码行数:30,代码来源:views.py

示例8: mostrar

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def mostrar(request, resource):

	cont_type = "text/html"

	if request.method == "GET":
		try:
			res = Pages.objects.get(name=resource)
			respuesta = res.page
			if res.name[0:3] == "css":
				cont_type = "text/css"
			else:
				template = get_template('index.html')
				return HttpResponse(template.render(Context({'page' : respuesta})), content_type='text/html')
		except ObjectDoesNotExist:
			return HttpResponse(resource + " does not exist")

	elif request.method == "PUT":
		body = request.body
		page = Pages(name=resource, content=body)
		page.save()
		respuesta = "Nuevo contenido insertado correctamente!"

	else:
		return HttpResponse("Metodo incorrecto")

	return HttpResponse(respuesta, content_type=cont_type)
开发者ID:scantero,项目名称:X-Serv-CSS-Elaborado,代码行数:28,代码来源:views.py

示例9: cms_users_put

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def cms_users_put(request, recurso):

    estado = ""
    if request.user.is_authenticated():
        estado += ("</br>Eres " + request.user.username +
                   "<a href='/logout'>Logout</a>")
    else:
        estado += ("No estas autenticado. " + "<a href=" +
                   "'http://127.0.0.1:8000/admin/login/'>Haz login</a>")

    if request.method == 'GET':
        try:
            page = Pages.objects.get(name=recurso.split("/", 1)[0])

            return HttpResponse(page.page + estado)
        except Pages.DoesNotExist:
            return HttpResponseNotFound("Page not found" + estado)

    elif request.method == 'PUT':
        if request.user.is_authenticated():
            newpage = Pages(name=recurso, page=request.body)
            newpage.save()
            return HttpResponse("Pagina guardada: " + request.body)
        else:
            return HttpResponse("No se puede añadir pagina " + estado)
    else:
        return HttpResponse("No esta disponible el metodo" + request.method)

    return HttpResponseNotFound(estado)
开发者ID:anombela,项目名称:X-Serv-15.9-Django-CMS-Templates,代码行数:31,代码来源:views.py

示例10: acortador

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def acortador(request, recurso):
    cuerpo = request.body
    if request.method == "GET":
        if recurso == "":
            return HttpResponse(formulario() + printmodels())
        else:
            try:
                retorno = Pages.objects.get(id=recurso)
                return HttpResponseRedirect(str(retorno.pagina))
            except Pages.DoesNotExist:
                return HttpResponseNotFound ( "<h1>PAGINA NO ENCONTRADA </h1><p><a href='http://localhost:8000'>formulario</a></p>")

    if request.method == "POST":
        respuesta = ""
        cuerpo = cuerpo.split('=')[1]

        if cuerpo.find("http%3A%2F%2F") >=  0:
            cuerpo = cuerpo.split('http%3A%2F%2F')[1]

        cuerpo = "http://" + cuerpo

        try:
            retorno = Pages.objects.get(pagina = cuerpo)
            respuesta += "URL: " + cuerpo + " ya acortada como: " + str(retorno.id)
        except Pages.DoesNotExist:
            p = Pages(pagina=cuerpo)
            p.save()
            respuesta = "<p> Pagina acortada: " + cuerpo + " </p>" + printmodels()



        return HttpResponse(respuesta  + "<p><a href='http://localhost:8000'>formulario</a></p>")
开发者ID:isolanilla,项目名称:X-Serv-18.2-Practica2,代码行数:34,代码来源:views.py

示例11: cms_annotated

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def cms_annotated(request, recurso):
    
    status = "logout"
    if not request.user.is_authenticated():
        salida = "No esta logueado"
        status = "loggin"
    else:
        if request.method == 'GET':
            try:
                pages = Pages.objects.get(name=recurso)
                salida = "pagina de: " + pages.page
            except Pages.DoesNotExist:
                salida = "Recurso no encontrado"
        elif request.method == 'PUT':
                p = Pages(name=recurso, page=request.body)
                p.save()
                salida = "Pagina guardada: " + request.body
        else:
            salida = "metodo no disponible"

    #Indicamos plantilla
    template = get_template("index.html")
    #Marcamos contexto:
    c = Context({'mensaje' : salida, 'loggin': status})
    renderizado = template.render(c)
    return HttpResponse(renderizado)
开发者ID:isolanilla,项目名称:X-Serv-15.9-Django-CMS-Templates,代码行数:28,代码来源:views.py

示例12: acortaurl

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def acortaurl(request, recurso):
    cuerpo = request.body
    if request.method == "GET":
        if recurso == "":
            return HttpResponse(formulario() + imprimourls())
        else:
            try:
        		contenido = Pages.objects.get(id=recurso)
        		return HttpResponseRedirect(contenido.pagina)
            except Pages.DoesNotExist:
        		return HttpResponseNotFound("<h1>Pagina no encontrada:</h1><p><a href='http://127.0.0.1:8000'>formulario</a></p>")

    if request.method == "POST":
        resultado = ""
        cuerpo = request.body.split('=')[1]
        if cuerpo.find("http%3A%2F%2F") >=  0:
            cuerpo = cuerpo.split('http%3A%2F%2F')[1]
        cuerpo = "http://" + cuerpo
        if cuerpo == "":
            return HttpResponseNotFound(formulario() + "URL no introducida")
        try:
            contenido = Pages.objects.get(pagina=cuerpo)
            resultado += "URL original: " + cuerpo + " ---->URL ya acortada: " + str(contenido.id)
        except Pages.DoesNotExist:
            pagina = Pages(pagina=cuerpo)
            pagina.save()
            resultado = "<p> Pagina acortada: " + cuerpo + " </p>" + imprimourls()

        return HttpResponse(resultado +"<p><a href='http://127.0.0.1:8000'>formulario</a></p>")
开发者ID:arubiopa,项目名称:X-Serv-18.2-Practica2,代码行数:31,代码来源:views.py

示例13: pagina_nueva

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def pagina_nueva(request, nombre, contenido):
    if request.method == "GET":
        pag_nueva = Pages(name = nombre, page = contenido)
        pag_nueva.save()
    elif request.method == "PUT" or request.method == "POST":
        pag_nueva = Pages(name= nombre, page = request.body)
        pag_nueva.save()
    return HttpResponse("Pagina anadida")
开发者ID:lauratrabas,项目名称:X-Serv-15.6-Django-CMS_PUT,代码行数:10,代码来源:views.py

示例14: nueva_pagina

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
def nueva_pagina(request, nombre, contenido):
    if request.method == "GET":
        nueva_pag = Pages(name = nombre, page = contenido)
        nueva_pag.save()
    elif request.method == "PUT" or request.method == "POST":
        nueva_pag = Pages(name = nombre, page = request.body)
        nueva_pag.save()
    return HttpResponse("Pagina anadida correctamente")
开发者ID:aalberca,项目名称:X-Serv-15.6-Django-CMS_PUT,代码行数:10,代码来源:views.py

示例15: _insertUrl

# 需要导入模块: from models import Pages [as 别名]
# 或者: from models.Pages import save [as 别名]
 def _insertUrl(self, url, hasher):
     urlinfo = Urls()
     urlinfo.urlhash = hasher
     urlinfo.url = url
     urlinfo.save()
     page = Pages()
     page.url = urlinfo
     page.save()
     return urlinfo
开发者ID:old-kasthack-s-projects,项目名称:ImageFetcher,代码行数:11,代码来源:views.py


注:本文中的models.Pages.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。