一篇介绍Nevow的非常好的文章,推荐

Pandas入门教程(二十二):股票数据分析实战——yfinance 获取数据、技术指标与收益率分析 把 Pandas 用在真实场景,才能体会它的价值。本文以茅台股票为例,用 yfinance 获取历史行情,完成缺失值处理与列筛选,绘制收盘价曲线,计算 SMA 移动平均线与 RSI 相对强弱指数,并通过日收益率、累计收益率和波动率完成完整的量化分析流程。 阅读详情

Nevow: A Web Application Construction Kit

Donovan Preston <dp@divmod.org>

Summary

Nevow is a web application construction kit, based on the ideas developed in the Twisted Woven package. Its main focus is on separating the HTML template from both the business logic and the display logic, while allowing the programmer to write pure Python code as much as possible. It has various parts which can be used individually or as a whole, integrated web solution:

  • XHTML templates: contain no programming logic, only nodes tagged with special nevow attributes
  • data/render methods: simplified MVC
  • stan: An s-expression-like syntax for expressing xml in pure python
  • formless: For describing the types of objects which may be passed to methods of your classes, validating and coercing string input from either web or command-line sources, and calling your methods automatically once validation passes
  • freeform: For rendering web forms based on formless type descriptions, accepting form posts and passing them to formless validators, and rendering error forms in the event validation fails
  • livepage: Cross-browser JavaScript glue for sending client side events to the server and server side events to the client after the page has loaded, without causing the entire page to refresh

Dependencies

Before you begin, make sure you acquire the dependencies:

- http://twistedmatrix.com/products/download
- http://nevow.com/nevow-0.1.tar.gz

Then get the examples:

- http://nevow.com/Nevow2004Examples.zip

You might also be interested in this tutorial in presentation format (PDF):

- http://nevow.com/Nevow2004.pdf

Why Nevow?

Nevow was created to help the author build several very large, complicated, web applications. It builds on many ideas the author was exposed to while using various other web frameworks, and attempts to borrow useful concepts from each while still remaining lightweight and as unobtrusive as possible.

Nevow's templating semantics use ideas from various other templating languages, including Quixote, ZPT, and XMLC (from the Enhydra project). It allows for the use of strict, validating XHTML templates tagged with special attributes called 'directives', similar to ZPT. It allows programmers to render HTML views in pure Python instead of forcing them to learn a new language which is embedded in HTML, similar to Quixote. Finally, it uses a DOM, or Document Object Model, to represent the document in memory during the rendering process, similar to XMLC.

Nevow also contains an Object Publishing framework similar to the ideas present in twisted.web and Zope. Each URL is mapped to an instance of the Page class using a simple traversal interface. An application server and HTTP server built using twisted.web is included which can get you started very quickly.

Nevow is built to be embedded in an environment which uses asynchronous I/O, such as twisted.web. It builds a stack of 'context' objects which it uses to keep track of state during the rendering process, and uses this to provide support for "pausing" rendering and resuming when an I/O operation has completed.

Nevow Tutorial

The rest of this paper will step you through building a web application using Nevow. The application we have chosen to build is a simple Calendar and Scheduling application, which can render a calendar for any month and year and integrates with a third party iCalendar parsing module to populate the calendar with events. To see the final result, change to the Example4 directory and run the following command:

twistd -noy sched.tac

Then, navigate to the following URL using the web browser of your choice:

http://localhost:8080/

You should then see a calendar for the current month. You should be able to choose any month to display, click on an events link to see the events for that day, and add an event to any day. Now, we will step through the process of building this application, introducing elements of nevow in the process.

HTML based templates

Nevow includes the ability to load HTML templates off disk. These templates may have processing directives which cause the execution of python methods at render time. The attribute technique was inspired by the attributes used by ZPT. However, no actual code may be embedded in the HTML template.

A Directive is a command to Nevow to invoke some Python code. Nevow uses data directives and render directives. The presence of a nevow:data or nevow:render attribute on an HTML node in a template will cause the related data_* or render_* method to be located and invoked.

A Pattern is a node which Python code can locate by name. When a node has a nevow:pattern attribute, Python code can use the context methods 'onePattern(name)', 'allPatterns(name)', and 'patternGenerator(name)' to locate and clone that pattern node.

A Slot is a fake node which Python code can replace with real content. When a node has a nevow:slot attribute, Python code can use the context method 'fillSlot(name, value)' to cause a slot to replace itself with the given value when the slot is rendered.

The first HTML template we will use in our Schedule example is a full HTML document which when viewed in a browser will show an approximation of what the final application will look like, with dummy data in place. Open the Example1/Month.html file in a browser and observe how it gives a reasonable preview of the final application. A designer may open this template in a graphical HTML editor and style it, and the directives we have placed in the document should be preserved.

Let's take a closer look at the directives, patterns, and slots present in the template:

<span nevow:data="currentMonth" nevow:render="month">
<h1> <nevow:slot name="label"> The label goes here </nevow:slot> </h1>
<table height="50%" width="50%" border="1">
<tr>
<td>Sunday</td>
...
<td>Saturday</td>
</tr>
<tr nevow:pattern="calendarWeek" nevow:render="remove">
<td nevow:pattern="calendarDay" align="center"></td>
...
</tr>
<nevow:slot name="calendarBody" />
...

In this case, we have a dummy <span> node around the interesting portion of the template. This span node will not affect the presentation of the document, and is merely a carrier for some directives which will affect some nodes inside of the span. On this node, we see two directives: nevow:data="currentMonth" and nevow:render="month". When nevow begins to render this span node, it will first invoke a method named data_currentMonth, and pass the resulting data to a method named render_month. The return value of the render_month method will replace the entire span in the rendering DOM and further processing will take place on it.

Inside of the span node, there are two slots: <nevow:slot name="label"> and <nevow:slot name="calendarBody" />. render_currentMonth will be sure to provide values to fill these slots before returning.

Finally, inside of the span node there are two patterns: nevow:pattern="calendarWeek" and nevow:pattern="calendarDay". The render_currentMonth method will make clones of these pattern nodes as it renders the calendar.

One last note: The <tr nevow:pattern="calendarWeek"> pattern node has a nevow:render="remove" directive. Nevow does not currently automatically remove pattern nodes from the template, so to prevent the dummy data from ending up in the output we use the render_remove method. render_remove is defined on the Page class, and simply returns ''.

data/render methods

When nevow locates a data directive in a template, it calls the associated data_* method on the Page class. In our example, the data method named data_currentMonth is invoked. The return value from the data method is remembered using the current context object and is passed as the 'data' parameter during the rendering of that node.

Similarly, a render directive in a template will invoke an appropriately named render_* method. In the example, the 'render_month' method will be invoked. The data will be located by looking in the current context object.

To tie our HTML template to our implementations of our data_* and render_* methods, we subclass the Page class. The skeleton implementation looks like this:

class ScheduleRoot(rend.Page):
docFactory = rend.htmlfile('Month.html')

def data_currentMonth(self, context, data):
...

def render_month(self, context, data):
...

The signature of a data_* or render_* method is always (self, context, data). Self is the Page instance itself, context is the Context instance currently on top of the context stack, and data is the most recent data placed on the context stack.

In this case, our data_currentMonth method is going to produce some data for use during the rendering process by our render_month method. By default data_currentMonth will return a tuple of the year, month, and a list of lists of weeks and days in that month. However, we are also going to parameterize the data method so that the month and year to return can be specified as arguments in the URL:

def data_currentMonth(self, context, data):
curtime = time.localtime()
# We either get the year from the request, or if there is no
# year argument in the request, use the current year
year = int(context.arg('year', curtime[0]))
# We either get the month from the request or the current month
month = int(context.arg('month', curtime[1]))

# Return a 3-tuple of the year, the month, and the list of lists
# of the weeks and days
return year, month, calendar.monthcalendar(year, month)

Our render_month method is going to use the data produced by our data method, as well as APIs available from the context object, to modify the render context. It will make copies of pattern nodes which it locates in the HTML template by name, populate these pattern nodes with data, and insert the final DOM construct into the final page using the context.fillSlots method:

def render_month(self, context, data):
# Unpack our 3-tuple
year, month, weeksAndDays = data

weekPattern = context.patternGenerator('calendarWeek')
dayPattern = context.with(weekPattern()).patternGenerator('calendarDay')

calendarBody = []
for week in weeksAndDays:
currentWeek = weekPattern().clear()
calendarBody.append(currentWeek)
for day in week:
currentDay = dayPattern().clear()
if day != 0:
currentDay.children.append(str(day))
currentWeek.children.append(currentDay)

context.fillSlots('label', "%s %s" % (calendar.month_name[month], year))
context.fillSlots('calendarBody', calendarBody)
return context.tag

Notice how this method, which does some fairly complicated view generation, is easy to read since it is pure python, and does not contain any knowledge of the layout or format of the HTML template since it uses named patterns and slots to manipulate it.

We have now completed the initial Example1 application. Change to the Example1 directory and start the application:

twistd -noy sched.tac

Visit the application on the URL:

http://localhost:8080/

You will see an accurate rendering of the current month's calendar. The application also contains a view which renders several years worth of links which you can click on to see the corresponding month.

Integrating with an External Data Source

Nevow was designed to easily allow you to provide a web ui for a third-party piece of code without modifying the original code. Nevow makes heavy use of adapters and interfaces to provide a component-based architecture where classes can provide implementations of aspects of functionality of another class.

However, it is not necessary to understand components in order to be able to use Nevow effectively. In our example, we are going to show a more explicit example of wrapping an external data source and exposing it to the web.

In order to support our Scheduling example, I did a web search for a python module which could parse the industry standard iCalendar format and present some simple Python objects. I located a module which was specifically designed for parsing the data files used by Apple's iCal application. With a few small modifications I generalized it to be more crossplatform. The original module can be found here:

http://www.devoesquared.com/Software/iCal_Module

The modified module, along with a sample .ics file, can be found in the Example2 directory. To begin integrating with this external data source, we override the __init__ method on our ScheduleRoot class:

def __init__(self, calendarEntries):
self.calendarEntries = calendarEntries
super(ScheduleRoot, self).__init__()

Then, we modify the configuration file, which creates our ScheduleRoot instance and starts a web server, creating an ICalReader instance and passing it to ScheduleRoot:

import iCal, schedule
from nevow import appserver
from twisted.application import service, internet

application = service.Application('Schedule')
webservice = internet.TCPServer(
8080,
appserver.NevowSite(schedule.ScheduleRoot(iCal.ICalReader()))
)
webservice.setServiceParent(application)

This configuration file, sched.tac, is a standard twisted application configuration file. When executed using 'twistd -y', the Application instance assigned to the 'application' variable will be started and will listen on any configured ports.

Finally, we modify our 'render_month' method to take this additional data source into account when rendering the page:

calendarBody = []
for week in weeksAndDays:
currentWeek = weekPattern().clear()
calendarBody.append(currentWeek)
for day in week:
if day != 0:
events = self.calendarEntries.eventsFor(date(year, month, day))
else:
events = []
currentDay = dayPattern(
render=self.render_day, data=(year, month, day, events))
currentWeek.children.append(currentDay)

In this example, we are calling the 'eventsFor' api on our ICalReader instance to discover if there are any events for the day we are about to render:

events = self.calendarEntries.eventsFor(date(year, month, day))

Then we delegate the rendering of the actual day fragment to the render_day method, passing it a tuple of (year, month, day, events) as data:

currentDay = dayPattern(
render=self.render_day, data=(year, month, day, events))

Setting the renderer and the data on a node using Python code is similar to what happens when Nevow encounters a render directive or a data directive in an HTML template, except we are able to pass Python references more directly. When control returns from the render_month method and Nevow continues to render the DOM, it will encounter these nodes with additional processing directives on them and render them accordingly.

Generating URLs using the url module

We are going to set up our web application so that day detail pages are available at URLs in the format http://localhost:8080/2004/3/21. We will implement render_day such that it renders a link to a day detail page when a day contains events. To do this, we will use the url module. The url module contains several useful constructs, including a class which contains APIs for generating links programatically, and several useful instances of this class. In this case, we are going to use the 'here' instance, which represents the URL of the page which is currently being rendered:

def render_day(self, context, data):
year, month, day, events = data
if events:
from nevow.url import here
# Construct URL to child page
url = here.child(str(year)).child(str(month)).child(str(day))
eventsDOM = context.onePattern('events').clear()
eventsDOM.attributes['href'] = url
eventsDOM.children.append(
"%s event%s" % (len(events), len(events) > 1 and 's' or ''))
else:
eventsDOM = ''

context.fillSlots('date', day)
context.fillSlots('events', eventsDOM)
# The return value of a render method replaces the template node
# We wish to use the template node after modifying the context
return context.tag

We have now completed Example2. Changing to the Example2 directory, running twistd, and visiting the application's URL will present us with a modified calendar which renders an informative link if there are any events on any particular day. However, clicking on a link will result in a 404 error page, because we have not yet implemented the day detail page.

URL Traversal and Object Publishing

Nevow uses the concept of Object Publishing. Object Publishing is a web application construction methodology which dictates that every URL presented by a web application is published, or rendered, by an instance of a Python object. In Nevow's case, every URL is rendered by a subclass of the Page class. In our Schedule example, we have so far had one instance of the Page class, the root Page instance. In order to add more web pages to our application, we need to implement one of Nevow's URL Traversal APIs.

Nevow has one required URL Traversal API, locateChild. locateChild is defined as the following:

def locateChild(self, request, segments):
"""Locate another object which can be adapted to IResource given the tuple 'segments'
Return a tuple of resource, path segments
"""

The Page class defines a default implementation of locateChild which provides additional convenient ways of specifying children: child_* methods and getDynamicChild. However, in this tutorial we are simply going to focus on locateChild briefly.

Example3 contains an implementation of locateChild on our ScheduleRoot class which prevents the day detail URLs from resulting in a 404 page. Since our earlier URL-generation code generated URLs of the form http://localhost:8080/2004/3/21 we attempt to map the segments ('2004', '3', '21') to year, month, and date integers. A request for any other URL, excluding http://localhost:8080/, results in a 404 Not Found page:

def locateChild(self, request, childSegments):
# Handle the URL http://localhost:8080/
if childSegments == ('',):
return self, ()
try:
year, month, date = map(int, childSegments)
import day
return day.DayDetail(self.calendarEntries, year, month, date), ()
except ValueError:
# If the url doesn't consist of a tuple of year, month, day, or the segments
# are not integers, then we render a 404 page.
return rend.NotFound

In each case, we return a tuple of a Page instance and a tuple of the remaining, unhandled segments. All of the cases shown here return an empty tuple as the unhandled segments, indicating that the Page instance being returned is the Page instance which will be responsible for rendering this URL.

(Note: rend.NotFound is a tuple of a default Page instance which renders a 404, and an empty tuple)

Next, we are going to implement the DayDetail page subclass using a different technique than before.

Stan

One of the most powerful things about nevow is stan, an s-expression-like syntax for producing XML fragments in pure Python syntax. Stan is not required for using nevow, but it is both a simple and powerful way to both lay out your XHTML templates and express your display logic. Stan is merely a lightweight DOM built using basic Python types, such as strings, lists, and generators. It was created because the W3C DOM, which was used by Woven to represent the page as it was being rendered, was too cumbersome, heavyweight and slow to be truely useful. At the most basic level, Nevow's use of stan means you can write your render methods very consisely and conveniently:

def render_date(self, context, data):
return "%s %s, %s" % (calendar.month_name[self.month], self.date, self.year)

In this case, we simply return a Python string as our view rendering logic. We could also return a list, tuple, integer, or our function could even be a generator. In fact, almost all basic Python types are supported (except dictionaries, which do not have a natural display order).

Stan also defines a Tag class. Tag instances have a 'tagName' string, an 'attributes' dictionary, and a 'children' list. Instead of providing baroque and cumbersome node-access APIs like the W3C dom, programmers simply use the normal python APIs for changing these attributes.

Nevow also ships with the 'tags' module, a module which defines instances of the special Proto class for every tag name defined by the XHTML 1.0 specification. A Proto is simply a Tag factory which sets the tagName attribute of the Tag instance.

However, the real utility of stan lies in how it overrides the special methods __call__ and __getitem__ on both the Proto and Tag classes. The __call__ implementation takes the keyword arguments passed to the call and updates the 'attributes' dictionary, and the __getitem__ implementation makes sure the object passed is a sequence and then calls extend on the 'children' list.

If you choose to use the stan Tag syntax, you will find that it is a readable, fast, and consise way to rapidly prototype HTML layouts. For example:

from nevow import tags as T

class DayDetail(rend.Page):
def render_events(self, context, data):
events = self.calendarEntries.eventsFor(
date(self.year, self.month, self.date))
if not events: return "No events yet."
return T.ol[
[
T.li[str(e)]
for e in events
]
]

If the 'eventsFor' method returned a single event for the day we were rendering, 'Full Moon', the HTML output resulting from this stan expression being inserted into the DOM would look like this:

<ol>
<li>Full Moon</li>
</ol>

The rend module also contains a stan document factory which you can use to rapidly prototype your Page templates using stan instead of HTML:

docFactory = rend.stan(
T.html[
T.head[
T.title[
"Detail for ", render_date]],
T.body[
T.a(href=root)["Back"],
T.h1[
"Detail for ", render_date],
T.h2[
"Events:"],
render_events]])

If your requirements do not include designer interaction, you can develop an entire application without writing a single line of HTML.

With the implementation of URL Traversal and the addition of the day module, our Example3 application is now capable of rendering a day detail page for any day. Run the example using twistd and try it out. The included .ics file contains events for various moon-phase days, such as full moon, new moon, etc.

Formless

Form posting is one of the most tedious parts of developing a web application. Rendering the required html, post location generation and handling, type coercions, error handling and message rendering, and finally invoking some action when done adds up to a lot of error prone code. Handling forms using a higher level API while still retaining enough flexibility to render the form how you would like turns out to be a very difficult challenge. Nevow contains a third-generation implementation of some concepts originally developed for Woven in the twisted.python.formmethod and twisted.web.woven.form modules. The formless and freeform modules separate the concerns of type description from form rendering/handling.

Python is dynamically typed, which means it has no built-in controls for enforcing the types of objects which are passed to your methods. This is great for programmers, but not necessarily great if you are going to be passing user-entered input to those methods. Formless is a simple way to describe the types of objects that can be passed to your methods, as well as coerce from string input to those types. Other code can then accept user input from a command line or from a web form, validate the input against the types described using formless, and call the method once validation has passed.

Example4 will use Formless to add type descriptions to our code so that a form post may be handled automatically. We will create a subclass of formless.TypedInterface whose sole purpose is to carry type information for later introspection during the form rendering/handling process:

class IEventsAddable(formless.TypedInterface):
def addEvent(self, description=formless.Text()):
"""Add Event

Add an event to this day.
"""
pass
addEvent = formless.autocallable(addEvent)

In this case, we are declaring that the 'description' parameter to the 'addEvent' method of an instance which declares it implements the 'IEventsAddable' interface should be of type 'Text'. The formless module contains many subclasses of 'Typed' such as Integer, Boolean, and Choice. Typed is designed to be easily subclassed and implemented so you may provide additional type coercion and validation logic.

In addition, the IEventsAddable.addEvent method is declared to be autocallable, which means that as long as all validation as specified by the types passes, Nevow is allowed to automatically call this method with the appropriately coerced arguments.

Next, we will implement the autocallable method in our DayDetail page to add an event to the current day. First, we declare that DayDetail implements IEventsAddable, and then we provide an implementation of addEvent:

class DayDetail(rend.Page):
__implements__ = IEventsAddable, rend.Page.__implements__

def addEvent(self, description):
newEvent = iCal.ICalEvent()
newEvent.summary = description
newEvent.startDate = date(self.year, self.month, self.date)
self.calendarEntries.events.append(newEvent)

Now all that is left is to create a properly-formatted form which, when posted, will call our addEvent method. The form post implementation in Nevow is designed to be easy to recreate by hand, in addition to the automatic form rendering capabilities:

<form action="freeform_post!!addEvent" method="POST">
<input type="text" name="description" />
<input type="submit" />
</form>

However, we won't actually use this form in Example4, because we can have a nicer form rendered automatically using freeform.

Freeform: Forms for Free

Freeform is a nevow module which will automatically render web forms and accept form posts based on types described using the classes in formless. To use this ability, call freeform.renderForms() and pass information about which forms you want rendered. Place the return value of this function in the DOM, either in a stan tree or as the return result of a render_* method. Passing nothing to the freeform.renderForms function instructs freeform to render all available forms:

docFactory = rend.stan(
T.html[
...
T.body[
...
T.p[
freeform.renderForms()]]])

There are also functions to aid you in rendering custom forms. Each is able to render a small portion of the overall form required for posting to an autocallable method.

  • binding
  • action
  • argument
  • value
  • error

We have now completed the tutorial scheduling application. Change into the Example4 directory, run the application with twistd, and visit it. You should be able to go to any day detail page and add an event to that day. Note that these events are only saved in memory and are not persisted to disk anywhere, so when you shut down the server they will be lost. The iCal module does not implement generation of .ics files or provide a convenient API for adding an event to an existing calendar, but it could be added.

Our final example application is a web-based chat application. It showcases an experimental Nevow technology called LivePage.

LivePage

LivePage is a Nevow technology which allows programmers to receive server-side notification of client-side JavaScript events, and to send JavaScript to the client in response to a server-side event. Woven included a fairly extensive implementation of LivePage, including publish-and-subscribe model changed notification with implicit view rerendering. Nevow has taken a different approach, attempting to keep the implementation as simple and understandable as possible. Currently, the LivePage implementation is Mozilla (and Firefox) only, although work is underway to write an IE implementation. Since the technique that can be used to send and recieve out of band events is highly browser dependent, the Nevow LivePage implementation will attempt to abstract these differences behind a common interface, and select the appropriate implementation based on which browser is being used.

The Nevow LivePage implementation is in a module named 'liveevil', and primarily consists of the function 'handler'. The following incomplete code fragment should illustrate how it is to be used:

from nevow import liveevil

def greeter(user, nodeName):
user.sendScript("alert('Greetings. You clicked the %s node.')" % nodeName)

# Any string arguments after the event handler function will be evaluated
# as JavaScript in the context of the web browser and results passed to the
# Python event handler
H = liveevil.handler(greeter, 'this.name')

class Live(renderer.Renderer):
document = tags.html[
tags.body[
ol[
li(onclick=handler, name="one")["One"]
li(onclick=handler, name="two")["Two"]
li(onclick=handler, name="three")["Three"]
]
]
]

The included 'Chatola' demo application contains a full implementation of a web based chat application in around 100 lines of Python. If you are interested in using LivePage in your application, you are encouraged to experiment, and while the current implementation is quite usable, it should still be considered experimental.

Note also that the current implementation is cookie session based, so you will need to use multiple machines or browser versions (such as Mozilla and Firefox) to see the multi user aspects of the application in action.

Conclusion

The Nevow package contains many tools which are useful for performing web and XML related tasks, from generating simple XML documents using easy-to-write pure-python syntax to building a full-blown, highly interactive web application. Nevow was designed to allow application programmers to remove all logic constructs from HTML templates and to give them the power of pure Python as often as possible. It attempts to provide tools for writing your application which allow you to do so as expressively as possible, so you can focus on the important parts of your application instead of the mechanics of the web, while still allowing access to the low level details of HTML and HTTP when necessary.


Trace back: http://www6.uniovi.es/python/pycon/dc2004/papers/60/

如何处理动态语言(Python / JS)的“隐形”调用链? 本文揭示动态语言(Python/JS)中静态AST解析导致调用链“断链”的核心问题,提出通过运行时追踪补全图谱的解决方案。基于Code-Graph-RAG的cgr trace机制,分别利用pytest插件与V8 Profiler捕获真实调用路径,将动态边合并至静态图谱,并在权重体系中提升动态边优先级。实践表明,该方法可显著提升图谱覆盖率,实现“结构+行为”双视角理解代码,为MCP与Rerank系统提供可靠支持。 阅读详情

相关推荐

nevow:Web 应用程序构建工具包

divmod 更新 Divmod Nevow 是一个用 Python 编写的 Web 应用程序构建工具包。 它旨在允许程序员根据需要在 Python 中表达尽可能多的视图逻辑,并包含一个名为 stan 的纯 Python XML 表达式语法来促进这一点。 然而,它还为设计者编辑的模板提供了丰富的支持,使用非常小的 XML 属性语言来提供双向模板操作能力。 Nevow 还包括 Divmod Athena,这是一个“双向网络”或“ ”实现,提供了服务器上的 Python 代码和客户端上的 JavaScript 代码之间的双向桥梁。 页面的模块化部分,在服务器 python 中称为“athena 片段”,在客户端 javascript 中称为“athena 小部件”,可以单独开发并放置在任何带有小型模板渲染器的 Nevow 渲染页面上。 Athena 在一个简单的远程方法调用接口背后抽象了

小型Python Web框架 Nevow

Nevow ,python web, zhoubols, 周波

周波的个人博客 1195

华为OD机试真题2026双机位C卷 C语言 实现【明日之星选举】

给定一组选票votes。votes[i]代表第 i 张选票的内容,包含一个字符串"zhangsan,hanmei",表示推荐zhangsan为明日之星,反对 hanmei 称为明日之星。赞成或反对使用逗号(,)分割。 给定一个数组n,表示最后将筛选出赞成票最多的n个人,如果赞成票相同,则反对票越少,排序越靠前;如果赞成票和反对票都相同,则按照姓名字典序升序排序。

MISAYAONE的博客 184

使用twisted+nevow框架简单实例

 1. 首先,编写一个HTML文件,helloword.html      Hello, world!        Hello, world!  2. 编写一个Nevow控制程序文件,helloword.pyfrom nevow import loaders, rendclass HelloWorld(rend.Pa

pythoner的专栏 878

DeepLabv3+改进专栏

🔥【DeepLabv3+改进专栏!探索语义分割新高度】🌟 你是否在为图像分割的精度与效率发愁?📢 本专栏重磅推出:✅ 独家改进策略:融合注意力机制、轻量化设计与多尺度优化✅ 即插即用模块:ASPP+升级、解码器。

AIcurator的博客 2576

华为OD机试真题 新系统 2026-09-26 Java&Go&C【数据中心最佳维护时间窗】

数据中心使用一个整数数组 scores,记录 N 小时内每小时的服务器得分(可正可负)。0 表示服务器故障(无效小时)。

MISAYAONE的博客 99

Nevow拥有很好的新特性

引用:Nevow , a python based web construction toolkit , has a lot of nice features, that deserve attention:1 - LivePage ( Ajax ).2 - Canvas ( Flash to server ).3 - XUL , the python way.4 - Stan ( Python

pythoner的专栏 565

CANoe之I/O功能采集电压

在进入ECU自动化测试中,有时会用到采集ECU电压,CANoe除了可以仿真、监听CAN、ETH、LIN等网络报文外,部分设备(如VN5650、VN1630等)上还有一个I/O口,这个I/O口就可以用来满足我们自动化测试中采集电压的需求。CANoe上的I/O功能用处还是特别大,比如网络管理测试、相关诊断都会用到。

测试领域技术分享 4827

Nevow XML Templates

 1Nevow XML Templates2===================34Stan syntax is cool, but eventually you are going to want to integrate your5Python code with a template designed by an HTML monkey. Nevow a

pythoner的专栏 537

YOLOv11改进 | 融合改进篇 | 利用尺度统一检测头DynamicHead融合P2增加小目标检测层(让小目标无所遁形)

本文给大家带来的最新改进机制是针对性的改进,针对于小目标检测增加P2层针对于大目标检测增加P6层利用DynamicHead(原版本一比一复现,全网独一份,不同于网上魔改版本)进行检测,其中我们增加P2层其拥有更高的分辨率,这使得模型能够更好地捕捉到小尺寸目标的细节。我们增加P6层是一个较低分辨率但具有更大感受野的特征层。对于大尺寸目标,这意味着模型可以更有效地捕捉到整体的结构信息。在这些的基础上我们配合DynamicHead可以使模型根据不同尺寸的目标动态调整其检测策略,进一步提升模型的精度。

Snu77的博客 3951

微信电脑版本不会自动下载图片吗?——没有找到解决方法。——只会默认下载doc等文件,图片不行,需要自己另存为——有什么办法解决吗?

微信电脑版本不会自动下载图片吗?——没有找到解决方法。——只会默认下载doc等文件,图片不行,需要自己另存为——有什么办法解决吗?此外,用户还可以选择将接收到的图片、视频和文件保存到指定的文件夹中。‌用户可以在微信设置中调整这一设置。

qq_15963745的博客 5088

Nevow render用法(转)

_uacct = "UA-99018-3";urchinTracker();1Nevow Object Publishing2=======================34In Nevow Object Traversal, we learned about the5nevow.inevow.IResource.renderHTT

pythoner的专栏 816

手把手教你学PCIE(1.38)--基本概念:ATU(地址转换单元)

ATU(Address Translation Unit)是一种硬件单元,用于在PCIe系统中进行地址转换。它将设备的本地地址(外部地址)转换为系统内存或配置空间中的全局地址(内部地址),反之亦然。ATU的工作原理:通过地址匹配和转换,确保事务能够在不同的地址空间之间正确路由。配置寄存器:通过配置寄存器来设置地址转换规则。应用场景:地址空间隔离、访问控制、动态地址管理、虚拟化和多租户。

MHD0815的博客 2057

AI全栈实战 | 3.9-01 爬虫入门:requests 加 BeautifulSoup 三分钟跑通,但 90% 的人栽在这 4 个“礼貌“问题上

⚠️:本文内容仅用于。请遵守目标站点的服务条款与相关法律法规,不得对目标服务造成负担,不得采集、传播个人隐私数据。技术是中性的,边界在你手里。爬虫的入门技术(requests 发请求 + BeautifulSoup 解析)三分钟就能学会。真正区分"会用爬虫"和"会做爬虫的人"的,是这篇我们跑通"请求→解析→存储"的最小闭环,然后重点把"合规与礼貌"这根弦给你绷上。

源码获取 | 运行部署 | 定制二开修改,如果回复不及时请耐心等待,请见谅。 409

Unreal5从入门到精通 专栏目录

欢迎来到“UE5从入门到精通”专栏!在这里,我们将带您踏上一段精彩的旅程,深入探索虚幻引擎5(Unreal Engine 5)的无限可能。不论您是游戏开发的新手,还是希望提升技能的开发者,这里都有适合您的内容。基础知识:了解虚幻引擎5的界面、功能和基本操作,为您的学习打下坚实的基础。项目实战:通过实际项目案例,帮助您从理论走向实践,真实体验游戏开发的每个环节。高级技巧:分享各种高级功能和技巧,包括蓝图、C++编程、材质编辑、光照和渲染等,让您能够创作出更具专业水准的作品。

TxNet 2987

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

从一段视频到可漫游的 4D 有声场景:思路拆解与最小复现手记

只需一段手机视频,你就能生成可"走进去"的 4D 有声场景:转头时狗叫声方向随之变化,走近时声音更清晰。本文拆解 Video-to-4DAVScene 的核心思路,手把手带你用几十行 Python 搭出最小管线,把视频中的运动物体变成带空间位置的声源,并附上三个真实踩坑的排障经验,代码可直接跑。🎧

helloagent的博客 235

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

【每天一个 Python 小案例30】Python 基础知识综合小项目:我的工具盒

作为系列收官,本篇把前 29 篇的知识点合成一个能直接用的命令行工具"我的工具盒":计算器(用 ast 解析表达式,不碰 eval)、单位换算与温度转换(一张换算表 + 特例分支)、记账与分类统计(Decimal + JSON 持久化)、以及用"字典当命令表"把菜单和业务逻辑解耦的主循环。文中对比了 eval 的安全隐患与 ast 白名单的做法,解释了 lambda 闭包在字典里的写法与晚绑定陷阱,并在最后给出整个系列的知识地图,把变量、数据结构、控制流、函数、类、异常、文件、标准库八块内容对应到具体篇目。

xinjiyaya的博客 427

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

详解Python条件语句

在 Python 中,if...else 是一种条件语句,可以根据给定的条件执行不同的操作。这个语句通常用于控制程序的流程。

2601_96798737的博客 208

Python3 协程:异步编程的核心机制与实战

协程是解决I/O密集型任务等待瓶颈的高效机制,相比线程更轻量、无锁开销。从yield到async/await的演进,使异步编程语义清晰、易于理解。通过async/await可实现并发执行多个任务(如gather、create_task),显著提升网络请求、爬虫等场景性能。关键在于使用异步库(如aiohttp)替代同步库,避免阻塞事件循环。合理控制超时与并发数,才能发挥协程最大优势。

Lxn2zh的博客 159

torch.compile 差异仅 1e-6,边界样本预测为何翻转

torch.compile 加速后输出与 eager 不一致,部分预测翻转。逐层对比与 graph break 分析定位到动态分支翻转根因。容差回归仅适用于无分支翻转场景,零容忍场景应禁用编译。

昨日种种,皆成今我。今日种种,皆成新我。 159

二进制木马免杀-Python 分离免杀与 Web 挂马

二进制木马免杀-Python 分离免杀与 Web 挂马

2503_94637398的博客 268

蓝桥杯·全国青少年信息素养大赛·电子学会Python/C++考级 备考:莫队算法离线区间查询详解

备赛进行时:第十八届蓝桥杯软件赛报名已于 2026-10-08 10:00 开启、12-18 14:00 截止,省赛定在 2027-04-10(C/C++·Python 程序设计 9:00–13:00);中国电子学会 2026 年 12 月软件编程(C/C++ 一级至十级、Python 一级至六级)考级报名 9/23–12/2 16:00、统考 12-12;全国青少年信息素养大赛 2026—2027 赛季算法应用主题赛也已进入复盘练兵窗口。

IT_Scratch的博客 139

【Python】国家中小学智慧教育平台电子教材批量下载与 PDF 合成实战

成果:两本语文电子课本(一年级上册 118 页 / 23MB、三年级上册 130 页 / 30.3MB),合计 248 页、约 54MB,单本下载加合成 40~60 秒,PDF 页数校验全部通过。经验教训SPA 站点的数据接口优先从 bundle 里挖,比抓页面稳得多;资源链接要按 private/public 分组看待,只取平台公开部分;页数、目录名这类“可推断”的信息,永远用实际响应验证一次;受限环境里“能不能跑浏览器”要在方案定稿前确认。后续计划:这版 PDF 是图片版,没有文字层;

木头大左的博客 138

魔塔社区微调训练Qwen2-1.5B-Instruct模型并烧录到‌RK3568开发板教程

本文基于Ubuntu 22.04 + CUDA 13.0.3环境,使用LLaMA-Factory框架对Qwen2-1.5B-Instruct模型进行LoRA微调,训练儿童故事生成专用模型。通过配置qwen模板、制作alpaca格式数据集、执行sft训练并合并LoRA权重,最终将模型转换为GGUF格式,并量化为Q4_K_M以适配RK3568嵌入式平台。全程支持国产镜像加速下载与显存优化,实现高效轻量化部署。

浅清秋慕夏的博客 186

【回眸】DeepSeek V4.1 Flash 快速上手与实战

本文介绍如何高效本地部署开源大模型,通过现代化工具链实现分钟级环境搭建。聚焦显存优化、一键安装、代码调用与多轮对话实现,解决“显存不足”“连接超时”等痛点,提供参数调优与结构化输出技巧,助力开发者在离线场景下快速构建稳定、高效的本地推理系统。

啤酒鸭的物联网开发记录博客 223
上一篇: wxWidges类列表
下一篇: 一篇介绍Nevow的非常好的文章,推荐
pythoner
博客等级 码龄18年 15粉丝 89原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值