在Symfony中手动创建表单(Creating a form manually in Symfony)
我正在Symfony中构建一个电子商务应用程序,并且我有一个列出特定类别中的产品的页面,例如URL“/ categories / list / id / 1”:
Product 1 Product 2 ...我想要一些形式的东西:
Product 1 * Add [ 1 ] of these to your shopping cart [Go] Product 2 * Add [ 1 ] of these to your shopping cart [Go]在同一页面上,所以我认为我需要从sfForm类派生出来并构建自己的表单,就像自动生成的表单一样。 是否应该根据类别模型命名? 或者根据“购物车”模型(我的购物车将被存储在何处)进行命名会更合适? 这将如何链接到例如我的listProductsByCategorySuccess.php模板?
希望以上是有道理的!
谢谢,
-丰富
I'm constructing an ecommerce application in Symfony, and I have a page which lists the products within a specific category, eg at the URL "/categories/list/id/1":
Product 1 Product 2 ...I'd like to have something of the form:
Product 1 * Add [ 1 ] of these to your shopping cart [Go] Product 2 * Add [ 1 ] of these to your shopping cart [Go]on the same page, so I presume I'm going to need to derive from the sfForm class and construct my own form, as the automatically-generated forms have been. Should this be named according to the categories model? Or would it be more appropriate to be named according to the "cart" model (where my shopping cart will be stored)? and how would this link into eg my listProductsByCategorySuccess.php template?
Hope the above makes sense!
Thanks,
-rich
原文:https://stackoverflow.com/questions/1024854
满意答案
它看起来像只有一个http请求被发送。 在这一行上:
timelink = requests.get('http://example.com/somelink')
abcStart()函数正在接收http响应,并在其运行的整个时间内使用该值。 这会导致我们每次都刮同一页。 如果我们想要有一个不同的页面来抓取每个循环迭代,我们需要每次执行另一个http请求。 像这样的东西:
def abcStart(timeLink): while True: res = requests.get(timeLink) # send request here res.raise_for_status() timestamp = BeautifulSoup(res.content, 'html.parser').find_all('b') if timestamp[0].text == otherTimestamp[0].text: work on something break if timestamp[0].text > otherTimestamp[0].text: continue else: print('not yet') time.sleep(30) break timeLink = 'http://example.com/somelink' # declare url threadobj = threading.Thread(target=abcStart, args=(timelink)) threadobj.start() threadobj.join()
It looks like there is only one http request being sent. On this line:
timelink = requests.get('http://example.com/somelink')
the abcStart() function is receiving the http response, and using that one value the whole time it is running. This will cause us to scrape the same page every time. If we want to have a different page to scrape for each loop iteration, we need to perform another http request each time. Something like this:
def abcStart(timeLink): while True: res = requests.get(timeLink) # send request here res.raise_for_status() timestamp = BeautifulSoup(res.content, 'html.parser').find_all('b') if timestamp[0].text == otherTimestamp[0].text: work on something break if timestamp[0].text > otherTimestamp[0].text: continue else: print('not yet') time.sleep(30) break timeLink = 'http://example.com/somelink' # declare url threadobj = threading.Thread(target=abcStart, args=(timelink)) threadobj.start() threadobj.join()
相关问答
更多如果传递给注释函数的参数类型与指定的参数不匹配,是否有可能产生python抛出错误?(Is it possible to make python throw errors if the type of the argument passed to the annotated function doesn't match the one specified?)
子程序参数未正确地从Python传递到Fortran(Subroutine argument not passed correctly from Python to Fortran)
Python获取参数(Python get passed arguments)
从命令行传递的json参数与python无法解码(json argument passed from the command line with python can't be decoded)
Python C API:使用引用传递的参数调用Python函数(Python C API: Call a Python function with argument(s) passed by reference)
Python - 如何获取作为参数传递的更新链接?(Python - how to get updated link that was passed as an argument?)
如何获得与Python3链接的boost.python教程示例?(How to get boost.python tutorial example to link with Python3?)
检查通过python cmd模块传递的参数(Check argument passed via python cmd module)
Python获取作为参数传递的文件夹中文件的完整路径(Python get full path for files in folder passed as argument)
论证没有通过部分(Argument not being passed through partial)
相关文章
更多Symfony2网站开发
HTML5 智能form表单新属性
关于一个页面多个form问题????????
form中如何接收传入的值
Drupal Forums instead of phpBB or vBulletin: A casestudy
ext里window里放form的布局?
form load 的问题
如何把复选框中的值传到form里?
a favorite song
ServletOutputStream cannot be resolved to a type
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!